-
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
refactor(core): Refactor Payment method vaulting APIs for v2 #5041
base: main
Are you sure you want to change the base?
Conversation
…itch into refactor-pm-create
…itch into refactor-pm-create
…itch into refactor-pm-create
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))] | ||
pub struct PaymentMethodVaultingData { | ||
pub pm_id: Option<String>, | ||
pub payment_method: Option<diesel_models::PaymentMethod>, |
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 don't have a equivalent domain type for 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.
Not yet, will implement domain model for Payment Method along with the diesel related changes.
} | ||
|
||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))] | ||
pub async fn perform_surcharge_decision_management_for_saved_cards( |
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.
what us surcharge_decision_management. write a comment explaining that or change the function name to give more specific meaning
…itch into refactor-pm-create
…itch into refactor-pm-create
@@ -660,6 +681,89 @@ pub async fn get_client_secret_or_add_payment_method( | |||
} | |||
} | |||
|
|||
#[cfg(all(feature = "v2", feature = "payment_methods_v2"))] | |||
#[instrument(skip_all)] | |||
pub async fn get_client_secret_or_add_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.
What is the client_secret part here?, the function implementation says only about adding a 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.
In case the payment_method_data is present in body, we take the data and vault directly (S2S call).
In case it is not present, we create a payment_method entry along with a client_secret and send back the response. This client_secret can be used to vault payment_method using SDK (the /save
endpoint)
status: Some(enums::PaymentMethodStatus::Inactive), | ||
}; | ||
|
||
db.update_payment_method(payment_method, pm_update, merchant_account.storage_scheme) |
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.
Already we are updating the payment_method then why we do have get_or_insert_payment_method below 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.
There are two different payment_methods involved here. For the /save
endpoint, i.e. vault a payment_method using SDK, if the data for payment_method is duplicated, we deactivate the current record for the payment_method and fetch the already existing one.
Type of Change
Description
This PR does -
Additional Changes
Motivation and Context
How did you test it?
Response
/payment_methods
to getclient_secret
Response -
/save
Response -
Checklist
cargo +nightly fmt --all
cargo clippy