Repository navigation
[FEATURE] Return the created payment_method_id in the payment-method-sessions confirm response #15196
dmatviichuk
started this conversation in
Ideas / Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Moved from #10573. That issue can no longer be opened now that issues are turned off for this repository.
Feature description
Return the ID of the payment method that
POST /v2/payment-method-sessions/{id}/confirmcreates in its response.Motivation
Right now the confirm response gives
associated_payment_methods, which only holds a temporary session token (for exampletoken_KpNynVfRrSoFound1nec). That token is meant for the web SDK. It does not work with the proxy endpoint or other APIs that need a permanent identifier.The proxy endpoint takes:
token_type: "payment_method_id"with a permanent payment method ID (for example12345_pm_...)token_type: "tokenization_id"with a tokenization ID (for example12345_tok_...)Confirming the session already creates the payment method, so the response can return its permanent ID and callers can use it with the proxy right away.
Possible implementation
associated_payment_method_id: Option<GlobalPaymentMethodId>toPaymentMethodSessionResponse(crates/api_models/src/payment_methods.rs).generate_payment_method_session_responseapayment_method_idparameter and copy it into the response (crates/router/src/core/payment_methods/transformers.rs).payment_methods_session_confirm, pass the ID of the payment method it just created. Every other caller passesNone(crates/router/src/core/payment_methods.rs).The field is optional, so existing clients keep working.
Example response:
{ "id": "12345_pms_019affa4e0c97ce0a804aa5d8d083019", "customer_id": "12345_cus_019aff8c0d857502bba0ccc88cc81ba2", "associated_payment_methods": [ { "payment_method_token": { "type": "payment_method_session_token", "data": "token_03zTec4iQZEAJR7qzsvk" } } ], "associated_payment_method_id": "12345_pm_01926c58bc6e77c09e809964e72af8c8" }The caller can then use the proxy endpoint:
{ "token": "12345_pm_01926c58bc6e77c09e809964e72af8c8", "token_type": "payment_method_id" }Implementation
PR #15198
All reactions