-
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(payments_v2): implement create and confirm setup intent flow #7106
base: main
Are you sure you want to change the base?
Conversation
Changed Files
|
@@ -1405,6 +1405,18 @@ impl PaymentAttemptUpdate { | |||
} | |||
} | |||
|
|||
#[cfg(feature = "v2")] | |||
#[derive(Debug, Clone, Serialize)] | |||
pub struct ConfirmIntentResponseUpdate { |
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.
Had to move this as a separate struct because of the clippy::large_enum_variant
lint being thrown.
impl | ||
TrackerPostUpdateObjects< | ||
router_flow_types::SetupMandate, | ||
router_request_types::SetupMandateRequestData, | ||
payments::PaymentConfirmData<router_flow_types::SetupMandate>, | ||
> | ||
for RouterData< | ||
router_flow_types::SetupMandate, | ||
router_request_types::SetupMandateRequestData, | ||
router_response_types::PaymentsResponseData, | ||
> |
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 almost entirely a copy-paste of the implementation of the Autorize flow. Didn't bother to reduce code duplication between these two implementations.
impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::SetupMandateRequestData> | ||
for PaymentResponse |
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.
Again, a copy-paste of the authorize flow implementation.
.route(web::post().to(payments::payments_create_intent)), | ||
) | ||
.service( | ||
web::resource("/setup-intent") |
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.
Let me know if the path needs to be changed.
@@ -592,7 +592,6 @@ async fn handle_response( | |||
|
|||
match status_code { | |||
200..=202 | 302 | 204 => { | |||
logger::debug!(response=?response); |
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.
Removed this redundant log line, since the response is being logged (with the same key) on line 589, before the match
block.
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 API is not setup-intent, it is just /payments
. The term we need to use payments
and not setup-intent
.
|
||
let payload = payments_api::PaymentsCreateIntentRequest::from(&request); | ||
|
||
let create_intent_response = Box::pin(payments_intent_core::< |
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 can be a normal payments_intent_core(PaymentCreateIntent), why we need a separate one?
Type of Change
Description
This PR introduces the setup intent flow for payments v2. As of now, this PR includes a single endpoint that handles both the create intent and confirm intent steps. This is done so as to allow the payment methods v2 endpoints to create multiple-use tokens for a specified customer's payment method. The implementation mostly builds on top of payment create intent v2 and payment confirm intent v2 implementations. Note that the API contract is not finalized and is possibly subject to change.
Let me know if I should include this endpoint in the OpenAPI specification and Mintlify reference.
Additional Changes
This PR introduces a new setup intent endpoint for payments v2.
Motivation and Context
The endpoint introduced in this PR would allow the creation of multiple-use tokens by the payments methods v2 endpoints.
How did you test it?
Using the v2 endpoints, create an organization, merchant account, profile, API key and merchant connector account.
Call the setup intent endpoint:
amount_details
,payment_method_data
,payment_method_type
andpayment_method_subtype
.The request and response are included below:
customer_id
, etc. which would be reflected in the response and database entries.Checklist
cargo +nightly fmt --all
cargo clippy