Issue:
[FEATURE]: Save Payment Method on Payments Confirm (V2)

Add functionality to save a payment method after a successful payment

Resolution:
<think>
PR Context:
- Title: feat(router): Save payment method on payments confirm (V2)
- Merged: 2025-06-06T15:55:49Z
- Files changed: 26 files
- Commits: 30 commits

Implementation approach:
## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [x] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
<!-- Describe your changes in detail -->
- Added a field `payment_token` to customer PML response
- During `/confirm-intent`, in case of card, an inactive payment method method is created before `call_conector_service`
- After the payment has completed, depending on its status the 
</think>

To implement this, you'll need to modify:


**Detailed Implementation:**


**Commit 1:** feat(router): Save payment method on payments confirm (V2) (#8090)
Co-authored-by: hyperswitch-bot[b
Files to modify:


**crates/api_models/src/events/payment.rs**
  Modify existing code

**crates/api_models/src/payment_methods.rs**
  Add:
    - struct: pub::PaymentMethodListResponseForSession

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

**crates/diesel_models/src/payment_attempt.rs**
  Modify existing code

**crates/hyperswitch_domain_models/src/payment_method_data.rs**
  Add:
    - function: private::from
    - function: private::from
    - impl: impl From<(
        payment_methods::CardDetail,
        Secret<String>,
        Option<Secret<String>>,
    )> for Card
    - impl: impl From<Card> for payment_methods::CardDetail

**crates/hyperswitch_domain_models/src/payments.rs**
  Add:
    - function: pub::update_payment_method_data
    - function: pub::update_payment_method_and_pm_id

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

**crates/openapi/src/openapi_v2.rs**
  Modify existing code

**crates/openapi/src/routes/payment_method.rs**
  Modify existing code

**crates/router/src/core/payment_methods.rs**
  Add:
    - function: private::get_pm_list_token_data

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

**crates/router/src/core/payment_methods/transformers.rs**
  Remove:
    - impl: impl transformers::ForeignTryFrom<domain::PaymentMethod> for api::CustomerPaymentMethod
  Add:
    - function: private::foreign_try_from
    - impl: impl transformers::ForeignTryFrom<(domain::PaymentMethod, String)> for api::CustomerPaymentMethodResponseItem
    - impl: impl transformers::ForeignTryFrom<domain::PaymentMethod> for PaymentMethodResponseItem

**crates/router/src/core/payment_methods/utils.rs**
  Add:
    - function: pub::retrieve_payment_token_data
    - function: pub::delete_payment_token_data

**crates/router/src/core/payment_methods/vault.rs**
  Add:
    - function: pub::retrieve_payment_method_from_vault_using_payment_token
    - function: pub::delete_payment_token

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

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

**crates/router/src/core/payments/operations.rs**
  Add:
    - function: private::create_or_fetch_payment_method

**crates/router/src/core/payments/operations/payment_confirm_intent.rs**
  Add:
    - function: private::create_or_fetch_payment_method

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

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

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

**crates/router/src/routes/payment_methods.rs**
  Add:
    - function: pub::return_key_for_token

**crates/router/src/types/api/payment_methods.rs**
  Modify existing code

**crates/router/src/types/storage/payment_method.rs**
  Add:
    - function: pub::is_permanent_card
    - enum: pub::PaymentTokenData

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