feat(router): Add support for updating wallet pm_data to PM update API#9388
feat(router): Add support for updating wallet pm_data to PM update API#9388likhinbopanna merged 8 commits intomainfrom
Conversation
Changed Files
|
| .await | ||
| .change_context(errors::ApiErrorResponse::InternalServerError) | ||
| .attach_printable("Failed to update payment method in db")?; | ||
|
|
There was a problem hiding this comment.
Can all the changes be accommodated in a single update DB call?
There was a problem hiding this comment.
Trying to have a single DB call for both card and wallet branches leads to convoluted code for response generation. It is cleaner to have 2 DB calls, contained within their branches.
There was a problem hiding this comment.
You can return storage::PaymentMethodUpdate from each of the branches and call update_payment_method once.
kashif-m
left a comment
There was a problem hiding this comment.
Added minor comments around refactoring the flow
7f6d03b
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9388 +/- ##
=======================================
Coverage ? 3.92%
=======================================
Files ? 1223
Lines ? 300980
Branches ? 0
=======================================
Hits ? 11803
Misses ? 289177
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| let pm = db | ||
| .find_payment_method( | ||
| &((&state).into()), | ||
| merchant_context.get_merchant_key_store(), | ||
| payment_method_id, | ||
| merchant_context.get_merchant_account().storage_scheme, | ||
| ) | ||
| .await | ||
| .to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?; |
There was a problem hiding this comment.
nit: we can fetch this after validating the client secret?
| .into()); | ||
| } | ||
|
|
||
| let updated_pmd = PaymentMethodsData::WalletDetails(wallet_update); |
There was a problem hiding this comment.
Suggestion:
Can we handle this similarly to how it's handled for cards [ref]
We should be able to update individual fields for wallet data (last4, card_type)
| @@ -481,6 +481,9 @@ pub struct PaymentMethodUpdate { | |||
| "card_holder_name": "John Doe"}))] | |||
| pub card: Option<CardDetailUpdate>, | |||
There was a problem hiding this comment.
PaymentMethodUpdate should be an enum. We shouldn't allow passing both card and wallet fields during update right?
Type of Change
Description
payment_method_datain case thepayment_method_typeis wallet.CustomerPaymentMethodUpdateResponseto include the wallet details being updated in responseFor wallets the following fields can be updated:
Additional Changes
Motivation and Context
Closes #9387
How did you test it?
Request:
Response:
{ "merchant_id": "merchant_1759320450", "customer_id": "customer123", "payment_method_id": "pm_FiEUWFVVyrcdp6o2NW4T", "payment_method": "wallet", "payment_method_type": "apple_pay", "card": null, "wallet": { "last4": "1024", "card_network": "Visa", "type": "credit" } "recurring_enabled": false, "installment_payment_enabled": false, "payment_experience": [ "redirect_to_url" ], "metadata": null, "created": "2025-10-01T12:10:05.824Z", "last_used_at": "2025-10-06T08:37:30.787Z", "client_secret": "pm_FiEUWFVVyrcdp6o2NW4T_secret_9o1ejWTPIzRzn4WdfoGm" }Checklist
cargo +nightly fmt --allcargo clippy