Issue:
feat(merchant_context): add struct `merchant_context` and replace all instances of `merchant_account` and `key_store` in core

# Introduction of MerchantContext: Unified Merchant Operation Context

## Challenge
Currently, merchant account and key store information are passed separately throughout the codebase, leading to scattered merchant context handling and reduced maintainability. Functions individually manage these components, making it difficult to implement platform-wide features or connected account capabilities.

## Proposed Changes
Introducing `MerchantContext`, a new type that encapsulates both merchant account and key store information:

```rust
pub enum MerchantContext {
    NormalMerchant(Box<Context>),
}

pub struct Context(pub MerchantAccount, pub MerchantKeyStore);
```

The type provides controlled access through methods:
- `get_merchant_account()`: Access merchant account details
- `get_merchant_key_store()`: Access cryptographic key store

## Why
1. **Unified Context**: Encapsulates merchant authentication and operational context in one place
2. **Cleaner Architecture**: Replaces scattered merchant account and key store parameters with a single context object
3. **Enhanced Control**: Method-based access enables validation, transformation, and future enhancements
4. **Maintainability**: Centralized merchant context management reduces code duplication and improves traceability

## How
The implementation follows a tree-like flow where the `MerchantContext` is:
1. Declared at the route handler level (root)
2. Passed down through core operation handlers (branches)
3. Finally consumed in database operations or other terminal functions (leaves)

This creates a clear, traceable flow of merchant context through the entire operation chain, making it easier to understand and maintain merchant-related operations.

## Future Objectives
1. **Operational Context extension**: The enum structure allows adding new variants for different operations, enabling:
   - Platform-level context inheritance
   - Connected account operations
   -  cherry picking context for individual fragment of flows

2. **Granular Context Control**:
   - Move context declaration to auth layer
   - Enable advanced platform features by implementing context creation logic for platform operations

This architectural change sets the foundation for future platform features while maintaining current functionality and improving code organization.


Resolution:
<think>
PR Context:
- Title: feat(merchant_context): add struct `merchant_context` and replace all instances of `merchant_account` and `key_store` in core
- Merged: 2025-04-29T09:43:05Z
- Files changed: 30 files
- Commits: 30 commits

Implementation approach:
## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [ ] New feature
- [x] Enhancement
- [x] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

This PR introduces a new `MerchantContext` type that unifies merchant account and key store information into a single, controlled-access context object. The implementation includes:

1. New `MerchantContext` enum and `Context` struct definitions
2. Method-based access control for merchant account 
</think>

To implement this, you'll need to modify:


**Detailed Implementation:**


**Commit 1:** feat(merchant_context): add struct `merchant_context` and replace all instances of `merchant_account
Files to modify:


**crates/hyperswitch_domain_models/src/lib.rs**
  Add:
    - mod: pub::merchant_context

**crates/hyperswitch_domain_models/src/merchant_context.rs**
  Add:
    - function: pub::get_merchant_account
    - function: pub::get_merchant_key_store
    - struct: pub::Context
    - enum: pub::MerchantContext
    - impl: impl MerchantContext

**crates/hyperswitch_domain_models/src/payments.rs**
  Modify existing code

**crates/router/src/compatibility/stripe/customers.rs**
  Modify existing code

**crates/router/src/compatibility/stripe/payment_intents.rs**
  Modify existing code

**crates/router/src/compatibility/stripe/refunds.rs**
  Modify existing code

**crates/router/src/compatibility/stripe/setup_intents.rs**
  Modify existing code

**crates/router/src/core/admin.rs**
  Modify existing code

**crates/router/src/core/blocklist.rs**
  Modify existing code

**crates/router/src/core/blocklist/utils.rs**
  Modify existing code

**crates/router/src/core/cards_info.rs**
  Modify existing code

**crates/router/src/core/conditional_config.rs**
  Modify existing code

**crates/router/src/core/customers.rs**
  Modify existing code

**crates/router/src/core/disputes.rs**
  Modify existing code

**crates/router/src/core/disputes/transformers.rs**
  Modify existing code

**crates/router/src/core/files.rs**
  Modify existing code

**crates/router/src/core/files/helpers.rs**
  Modify existing code

**crates/router/src/core/fraud_check.rs**
  Modify existing code

**crates/router/src/core/fraud_check/flows.rs**
  Modify existing code

**crates/router/src/core/fraud_check/flows/checkout_flow.rs**
  Modify existing code

**crates/router/src/core/fraud_check/flows/fulfillment_flow.rs**
  Modify existing code

**crates/router/src/core/fraud_check/flows/record_return.rs**
  Modify existing code

**crates/router/src/core/fraud_check/flows/sale_flow.rs**
  Modify existing code

**crates/router/src/core/fraud_check/flows/transaction_flow.rs**
  Modify existing code

**crates/router/src/core/fraud_check/operation.rs**
  Modify existing code

**crates/router/src/core/fraud_check/operation/fraud_check_post.rs**
  Modify existing code

**crates/router/src/core/fraud_check/operation/fraud_check_pre.rs**
  Modify existing code

**crates/router/src/core/locker_migration.rs**
  Modify existing code

**crates/router/src/core/mandate.rs**
  Modify existing code

**crates/router/src/core/mandate/helpers.rs**
  Modify existing code

**crates/router/src/core/mandate/utils.rs**
  Modify existing code

**crates/router/src/core/payment_link.rs**
  Modify existing code

**crates/router/src/core/payment_methods.rs**
  Modify existing code

**crates/router/src/core/payment_methods/cards.rs**
  Modify existing code

**crates/router/src/core/payment_methods/migration.rs**
  Modify existing code

**crates/router/src/core/payment_methods/tokenize.rs**
  Modify existing code

**crates/router/src/core/payment_methods/validator.rs**
  Modify existing code

**crates/router/src/core/payment_methods/vault.rs**
  Modify existing code

**crates/router/src/core/payments.rs**
  Modify existing code

**crates/router/src/core/payments/access_token.rs**
  Modify existing code

**crates/router/src/core/payments/flows.rs**
  Modify existing code

**crates/router/src/core/payments/flows/approve_flow.rs**
  Modify existing code

**crates/router/src/core/payments/flows/authorize_flow.rs**
  Modify existing code

**crates/router/src/core/payments/flows/cancel_flow.rs**
  Modify existing code

**crates/router/src/core/payments/flows/capture_flow.rs**
  Modify existing code

**crates/router/src/core/payments/flows/complete_authorize_flow.rs**
  Modify existing code

**crates/router/src/core/payments/flows/incremental_authorization_flow.rs**
  Modify existing code

**crates/router/src/core/payments/flows/post_session_tokens_flow.rs**
  Modify existing code

**crates/router/src/core/payments/flows/psync_flow.rs**
  Modify existing code

**crates/router/src/core/payments/flows/reject_flow.rs**
  Modify existing code

**crates/router/src/core/payments/flows/session_flow.rs**
  Modify existing code

**crates/router/src/core/payments/flows/session_update_flow.rs**
  Modify existing code

**crates/router/src/core/payments/flows/setup_mandate_flow.rs**
  Modify existing code

**crates/router/src/core/payments/flows/update_metadata_flow.rs**
  Modify existing code

**crates/router/src/core/payments/helpers.rs**
  Modify existing code

**crates/router/src/core/payments/operations.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payment_approve.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payment_attempt_record.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payment_cancel.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payment_capture.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payment_capture_v2.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payment_complete_authorize.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payment_confirm.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payment_confirm_intent.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payment_create.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payment_create_intent.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payment_get.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payment_get_intent.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payment_post_session_tokens.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payment_reject.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payment_response.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payment_session.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payment_session_intent.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payment_start.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payment_status.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payment_update.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payment_update_intent.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payment_update_metadata.rs**
  Modify existing code

**crates/router/src/core/payments/operations/payments_incremental_authorization.rs**
  Modify existing code

**crates/router/src/core/payments/operations/proxy_payments_intent.rs**
  Modify existing code

**crates/router/src/core/payments/operations/tax_calculation.rs**
  Modify existing code

**crates/router/src/core/payments/payment_methods.rs**
  Modify existing code

**crates/router/src/core/payments/retry.rs**
  Modify existing code

**crates/router/src/core/payments/session_operation.rs**
  Modify existing code

**crates/router/src/core/payments/tokenization.rs**
  Modify existing code

**crates/router/src/core/payments/transformers.rs**
  Modify existing code

**crates/router/src/core/payout_link.rs**
  Modify existing code

**crates/router/src/core/payouts.rs**
  Modify existing code

**crates/router/src/core/payouts/access_token.rs**
  Modify existing code

**crates/router/src/core/payouts/helpers.rs**
  Modify existing code

**crates/router/src/core/payouts/retry.rs**
  Modify existing code

**crates/router/src/core/payouts/validator.rs**
  Modify existing code

**crates/router/src/core/pm_auth.rs**
  Modify existing code

**crates/router/src/core/poll.rs**
  Modify existing code

**crates/router/src/core/refunds.rs**
  Modify existing code

**crates/router/src/core/refunds_v2.rs**
  Modify existing code

**crates/router/src/core/relay.rs**
  Modify existing code

**crates/router/src/core/revenue_recovery.rs**
  Modify existing code

**crates/router/src/core/revenue_recovery/types.rs**
  Modify existing code

**crates/router/src/core/routing.rs**
  Modify existing code

**crates/router/src/core/surcharge_decision_config.rs**
  Modify existing code

**crates/router/src/core/utils.rs**
  Modify existing code

**crates/router/src/core/webhooks/incoming.rs**
  Modify existing code

**crates/router/src/core/webhooks/incoming_v2.rs**
  Modify existing code

**crates/router/src/core/webhooks/outgoing.rs**
  Modify existing code

**crates/router/src/core/webhooks/recovery_incoming.rs**
  Modify existing code

**crates/router/src/core/webhooks/utils.rs**
  Modify existing code

**crates/router/src/routes/admin.rs**
  Modify existing code

**crates/router/src/routes/blocklist.rs**
  Modify existing code

**crates/router/src/routes/cards_info.rs**
  Modify existing code

**crates/router/src/routes/customers.rs**
  Modify existing code

**crates/router/src/routes/disputes.rs**
  Modify existing code

**crates/router/src/routes/ephemeral_key.rs**
  Modify existing code

**crates/router/src/routes/files.rs**
  Modify existing code

**crates/router/src/routes/fraud_check.rs**
  Modify existing code

**crates/router/src/routes/mandates.rs**
  Modify existing code

**crates/router/src/routes/payment_link.rs**
  Modify existing code

**crates/router/src/routes/payment_methods.rs**
  Modify existing code

**crates/router/src/routes/payments.rs**
  Modify existing code

**crates/router/src/routes/payout_link.rs**
  Modify existing code

**crates/router/src/routes/payouts.rs**
  Modify existing code

**crates/router/src/routes/pm_auth.rs**
  Modify existing code

**crates/router/src/routes/poll.rs**
  Modify existing code

**crates/router/src/routes/profiles.rs**
  Modify existing code

**crates/router/src/routes/recovery_webhooks.rs**
  Modify existing code

**crates/router/src/routes/refunds.rs**
  Modify existing code

**crates/router/src/routes/relay.rs**
  Modify existing code

**crates/router/src/routes/routing.rs**
  Modify existing code

**crates/router/src/routes/webhooks.rs**
  Modify existing code

**crates/router/src/types/domain.rs**
  Add:
    - mod: pub::merchant_context

**crates/router/src/types/domain/user.rs**
  Modify existing code

**crates/router/src/utils.rs**
  Modify existing code

**crates/router/src/utils/user/sample_data.rs**
  Modify existing code

**crates/router/src/workflows/attach_payout_account_workflow.rs**
  Modify existing code

**crates/router/src/workflows/outgoing_webhook_retry.rs**
  Modify existing code

**crates/router/src/workflows/payment_sync.rs**
  Modify existing code

**crates/router/src/workflows/revenue_recovery.rs**
  Modify existing code

**crates/router/tests/payments.rs**
  Modify existing code

**crates/router/tests/payments2.rs**
  Modify existing code