feat: add associated_payment_method_id to payment method session confirm response #10574
+11
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…irm response
Type of Change
Description
Include the payment_method_id in the response returned by the payment-method-sessions/confirm endpoint.
Fixes #10573
Additional Changes
Motivation and Context
The /v2/payment-method-sessions/{id}/confirm endpoint returns associated_payment_methods containing temporary Redis tokens (e.g., "token_KpNynVfRrSoFound1nec"). These are for internal web SDK use and cannot be used with the proxy endpoint or other APIs that require permanent identifiers.
The proxy endpoint requires:
token_type: "payment_method_id" with a permanent payment method ID (e.g., 12345_pm_...)
token_type: "tokenization_id" with a tokenization ID (e.g., 12345_tok_...)
Since a payment method is created during session confirmation, we should include the permanent payment_method_id in the response so it can be used with the proxy endpoint and other APIs.
Use case:
After confirming a payment method session, users can now use associated_payment_method_id in the proxy endpoint:
{ "token": "12345_pm_01926c58bc6e77c09e809964e72af8c8", "token_type": "payment_method_id"}
This change is backward compatible as the new field is optional and doesn't break existing clients.
How did you test it?
Checklist
cargo +nightly fmt --allcargo clippy