-
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(core): payments overcapture support for V1 #6824
base: main
Are you sure you want to change the base?
Conversation
61fe94c
to
1c1510f
Compare
…rable from connector_response
… request_overcapture in payment_attempt
payment_attempt.request_overcapture = request | ||
.request_overcapture | ||
.or(payment_attempt.request_overcapture); | ||
} |
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 cannot consider request_overcapture from request body in confirm flow, since it is a client call. request_overcapture must only be taken from either payment create or update request.
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.
Did corresponding changes but during confirm call, if the capture method is changed
manual to other_capture_methods -> an error is thown
other_capture_methods to manual -> request_overcapture
gets updated, according to profile config
pub(crate) fn validate_amount_to_capture( | ||
amount: i64, | ||
amount_to_capture: Option<i64>, | ||
is_overcapture_applied: Option<bool>, |
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.
amount_to_capture must be validated against amount_capturable if it is some. If it is None, then we will validate with net amount.
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.
As amount_capturable
is not a nullable value, we are not validating the amount with net_amount
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.
But amount_to_capture must not be greater than amount_capturable right?
Co-authored-by: Hrithikesh <[email protected]>
@@ -1289,6 +1309,7 @@ impl PaymentCreate { | |||
organization_id: organization_id.clone(), | |||
profile_id, | |||
connector_mandate_detail: None, | |||
request_overcapture, |
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.
Lets update this only in update_trackers of confirm flow.
@@ -819,6 +830,7 @@ impl<F: Clone + Sync> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for | |||
surcharge_amount, | |||
tax_amount, | |||
), | |||
request_overcapture, |
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.
request_overcapture in attempt must only be updated before calling connector in confirm flow.
@@ -4286,6 +4293,7 @@ impl AttemptType { | |||
organization_id: old_payment_attempt.organization_id, | |||
profile_id: old_payment_attempt.profile_id, | |||
connector_mandate_detail: None, | |||
request_overcapture: old_payment_attempt.request_overcapture, |
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 should be None. In smart retries, connector will change. we need to figure out if the new connector supports overcapture and then update in attempt.
pub(crate) fn validate_amount_to_capture( | ||
amount: i64, | ||
amount_to_capture: Option<i64>, | ||
is_overcapture_applied: Option<bool>, |
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.
But amount_to_capture must not be greater than amount_capturable right?
Type of Change
Description
Overcapture allows you to capture with an amount that’s higher than the authorised amount for a card payment. Unlike incremental authorisations, overcapture doesn’t result in additional authorisations with the card networks.
Additional Changes
API contract changes:
a) /payments create request to include
request_overcapture
booleanb) /payments response to include
c) Profile create request and response to include
always_request_overcapture
(boolean)d) Profile update request and response to include
always_request_overcapture
(boolean)DB changes:
a) request_overcapture enum(Enable/Skip) field to be introduced in payment_intent
b)ovecapture_status enum(Applicable/NotApplicable) to be introduced in payment_attempt
d) always_request_overcapture boolean field to be introduced in business_profiles table
Not Handled (These changes will be taken as a phase 2 change )
a) Error is not thrown, when overcapture is not supported by the connector/capture_type
b) List of supported connector and payment method not maintained.
c) Extend this feature for multiple manual capture
How did you test it?
"always_request_overcapture": true
Response
DB - business_profile will have a field called always_request_overcapture , marked as
true
request_overcapture
in the payment request"always_request_overcapture": false
Response
Response
Checklist
cargo +nightly fmt --all
cargo clippy