-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat(platform): implement payment method sharing model for platform-connected setup #10458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…onality This change introduces provider context support throughout the payment methods module, enabling better handling of provider-specific configurations and enhancing the flexibility of payment method operations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10458 +/- ##
=======================================
Coverage ? 6.46%
=======================================
Files ? 1251
Lines ? 311788
Branches ? 0
=======================================
Hits ? 20164
Misses ? 291624
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
apoorvdixit88
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can consider making wrapper wherever we are making direct db call with platform.
| let mut updated_card_expiry = false; | ||
|
|
||
| let payment_method = db | ||
| .find_payment_method( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we can consider making the wrapper, i think its already there in the get_tracker PR, we can use the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will take this up in a separate PR, once the wrapper setup is finalized
| let response = db | ||
| .update_payment_method( | ||
| platform.get_processor().get_key_store(), | ||
| platform.get_provider().get_key_store(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here as well we can consider making platform wrapper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will take this up in a separate PR, once the wrapper setup is finalized
| let mut updated_card_expiry = false; | ||
|
|
||
| let payment_method = db | ||
| .find_payment_method( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
| let response = db | ||
| .update_payment_method( | ||
| platform.get_processor().get_key_store(), | ||
| platform.get_provider().get_key_store(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
|
|
||
| #[cfg(feature = "v1")] | ||
| let payment_intent = db | ||
| .find_payment_intent_by_payment_id_merchant_id( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrapper needed, and we need to check working of this function, in this flow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified this to use processor, queries also need to be changed later to query on processor_merchant_id.
Wrappers will be added in a subsequent PR.
| customer_id, | ||
| &payment_method_id, | ||
| Some(stored_resp.card_reference.clone()), | ||
| platform.get_processor().get_account().get_id(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't it be provider?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should be. But this change was done only to remove the error as I had changed platform to provider in PmCards struct.
I haven't touched this flow yet, as it comes under payouts.
Will modify this in a separate PR when working on adding the provider context in payouts.
5231ff5
Type of Change
Description
This PR introduces provider context support for Payment Methods, extending the platform-connected model that already exists for customers. The objective is to ensure that payment methods are consistently treated as platform-owned resources, while still allowing connected merchants within the same organization to access and use them.
Key Changes
1. Provider Context for Payment Methods
X-Connected-Merchant-Idheader (acting on behalf of a connected merchant).2. Provider / Processor Role Separation
3. Updated Payment Method Endpoints
4. Core Refactoring
5. Webhook and Compatibility Adjustments
Scope Clarification (Important)
This PR does not include:
These enhancements will be implemented in follow-up PRs.
Motivation and Context
Problems Addressed
Solution Summary
APIs Affected
POST /payment_methods(v1, v2)GET /payment_methods/:id(v1, v2)GET /payment_methods(list) (v1, v2)PATCH /payment_methods/:id(v1, v2)DELETE /payment_methods/:id(v1, v2)Diagram: Current (Incorrect) Merchant-Scoped Model
Diagram: Proposed Platform-Scoped Model
How did you test it?
Checklist
cargo +nightly fmt --allcargo clippy