-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat(router): add routing support for token-based mit payments #4012
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vspecky
added
A-core
Area: Core flows
C-feature
Category: Feature request or enhancement
S-waiting-on-review
Status: This PR has been implemented and needs to be reviewed
A-routing
Area: Routing
labels
Mar 7, 2024
vspecky
requested review from
jagan-jaya,
Narayanbhat166,
Aprabhat19 and
SamraatBansal
March 8, 2024 11:43
Merged
15 tasks
jagan-jaya
requested changes
Mar 8, 2024
jagan-jaya
previously approved these changes
Mar 8, 2024
SamraatBansal
previously approved these changes
Mar 11, 2024
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.
Given approval from connectors crate
Aprabhat19
reviewed
Mar 11, 2024
Aprabhat19
previously approved these changes
Mar 11, 2024
Narayanbhat166
previously approved these changes
Mar 11, 2024
vspecky
dismissed stale reviews from Narayanbhat166, Aprabhat19, and SamraatBansal
via
March 11, 2024 08:49
936a291
jagan-jaya
approved these changes
Mar 11, 2024
Aprabhat19
approved these changes
Mar 11, 2024
SamraatBansal
approved these changes
Mar 11, 2024
bernard-eugine
approved these changes
Mar 11, 2024
jarnura
approved these changes
Mar 11, 2024
15 tasks
SanchithHegde
removed
the
S-waiting-on-review
Status: This PR has been implemented and needs to be reviewed
label
Mar 17, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Type of Change
Description
This PR adds routing support for token-based MIT payments. Basically, the merchant can have their customers set up their payment method for off session payments with Hyperswitch. Behind the scenes, Hyperswitch sets up an MIT/Mandate with the connector.
Now, when the merchant wants to do off-session payments using the customer's saved payment method by using a token to select the payment method, the backend needs to ensure that the payment goes through only those connectors for which that payment method is set up for MITs. This PR adds this check.
Additional Changes
Motivation and Context
The merchant may want to do off-session payments by passing a payment method token on behalf of their customers. This would require the smart router to choose an appropriate connector for the payment on the basis of whether the selected payment method is set up with the connector for off-session MIT payments.
How did you test it?
Setup Mandate
requestthis will set the given card up for token-based MIT payments, and associate the connector MIT/Mandate details with the saved payment method in DB as shown below in the
connector_mandate_details
columnsetup_future_usage = off_session
card_cvc
)This is treated as a token-based MIT payment since we passed
setup_future_usage = off_session
in create, and are confirming the payment with the token. Routing will detect this, get theconnector_mandate_details
from the payment method object associated with the token, and do a recurring mandate payment using the connector mandate details. Additionally, routing will ensure that the connector will be picked for a token-based MIT payment if and only if it has some connector mandate details saved in the payment method object. Following is the connector request sent by the backend to cybersource.We can see that
paymentInstrument
was set to the connector mandate ID by Routing, thus turning it into a recurring MIT payment.Y
."routing"
value to force straight through routing to pickY
.Even tho we are forcing connector
Y
for the token-based MIT payment, Routing will detect that the chosen payment method does not have any MIT/Mandate set up withY
by checking theconnector_mandate_details
field in the payment method record, and automatically fall back to the first connector.Checklist
cargo +nightly fmt --all
cargo clippy