-
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 an api to migrate the payment method #5186
Conversation
496e480
to
0d2cfbb
Compare
…spay/hyperswitch into payment_methods/migration_api
acd993a
to
e70bbc2
Compare
…ment_methods/migration_api
last_modified: current_time, | ||
last_used_at: current_time, | ||
payment_method_billing_address, | ||
updated_by: None, |
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.
update this field to appropriate value
…ment_methods/migration_api
…ment_methods/migration_api
…spay/hyperswitch into payment_methods/migration_api
let card_details = req | ||
.card | ||
.as_ref() | ||
.ok_or(errors::ApiErrorResponse::InvalidRequestData { |
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.
.ok_or(errors::ApiErrorResponse::InvalidRequestData { | |
get_required_value("card") |
if crd.saved_to_locker { | ||
crd.scheme.clone_from(&pm.scheme); | ||
Some(crd) | ||
} else { |
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.
@Aprabhat19 is it safe to remove this?
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 its safe to remove
let db = &*state.store; | ||
let customer_id = req.customer_id.clone().get_required_value("customer_id")?; | ||
|
||
let connector_mandate_details = req |
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.
this field should be mandatory during migration api
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.
this field should be mandatory during migration api
This is an internal API, and I will be creating another PR on this. I will include this mandatory field change in that upcoming PR.
|
||
let payment_method_id = generate_id(consts::ID_LENGTH, "pm"); | ||
|
||
let client_secret = generate_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.
why we are creating client_secret here?
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.
7f876bc
7f876bc
to
a0e1195
Compare
/// in order to call /payment_methods | ||
/// Client secret will be generated whenever a new | ||
/// payment method is created | ||
pub client_secret: Option<String>, |
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.
This is suppose to be server to server right? so client_secret is not required.
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 correct, as client secret is only required while adding a payment method through sdk it can be removed in this migration api.
4e6b2cd
to
2e9c20b
Compare
2e9c20b
to
9bf49b3
Compare
Type of Change
Description
This is the API that will be used to migrate card details and associated data stored in another service to Hyperswitch.
How does this API differ from the existing payment method creation API?
connector_mandate_details
andnetwork_transaction_id
if present.If the masked card number is provided as input, a payment method entry is created in Hyperswitch, and no data is stored in the locker. If a valid card number is present, the card details are stored in the locker, the same as in the save card flow.
Additional Changes
Motivation and Context
How did you test it?
-> Create merchant connector account for cybersource
Test on_session saved payment
-> Crate a payment with
setup_future_usage: on_session
-> Create payment with confirm false for the same customer
-> Do payment method list with the client_secret
-> Confirm the payment with the payment_token
Test off_session saved payment
-> Create payment with setup_future_usage: off_session
-> Create a payment and payment method list with the client_secret
-> Confirm the payment with token
Test payment method migration api with connector mandate details
-> use the appropriate
connector_mandate_id
save the above payment method for a customer-> Create a payment for the customer with confirm false and perform payment
-> Payment method list with the client secret
-> Confirm the payment with the token, in this case payment will go through even without the card details as the connector mandate details are present
Test payment method migration api with network_transaction_id
-> Enable the is_connector_agnostic_mit_enabled for the business profile
-> Create payment with confirm false
-> list payment methods for customer
-> Confirm the payment with the token
Checklist
cargo +nightly fmt --all
cargo clippy