-
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
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?
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.
Dashboard specific changes looks fine.
crates/api_models/src/admin.rs
Outdated
@@ -2370,6 +2378,10 @@ pub struct ProfileUpdate { | |||
/// Product authentication ids | |||
#[schema(value_type = Option<Object>, example = r#"{ "key1": "value-1", "key2": "value-2" }"#)] | |||
pub authentication_product_ids: Option<HashMap<String, id_type::MerchantConnectorAccountId>>, | |||
|
|||
/// Indicates if the overcapture is always requested or not. | |||
#[schema(default = false, example = false)] |
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's no default false during ProfileUpdate
request_overcapture: Option<api_enums::OverCaptureRequest>, | ||
) -> Result<(), errors::ApiErrorResponse> { | ||
utils::when( | ||
request_overcapture == Some(api_enums::OverCaptureRequest::Enable) |
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 can have impl based fns for these checks, something like request_overcapture.is_enabled() && !capture_method.is_manual()
|
||
/// Get the boolean value of the `OverCaptureStatus`. | ||
impl super::OverCaptureStatus { | ||
pub fn as_bool(&self) -> 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.
All of this bool conversions could simply be impl based fns, something like OverCaptureStatus::is_applicable()
@@ -1158,7 +1160,7 @@ impl PaymentCreate { | |||
}) | |||
.ok() | |||
}) | |||
.and_then(|pmd| match pmd { | |||
.and_then(|pmd: PaymentMethodsData| match pmd { |
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.
Is this change 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.
Not required, I will remove it
.always_request_overcapture | ||
.map(api_enums::OverCaptureRequest::from))), | ||
Some(_) => { | ||
match 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.
what's the case we are trying to handle 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.
This handles the case where request_overcapture is enabled, but capture method is not manual
d3ff1f3
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 (phase 2 )
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 and incremental authorization
-> Cypress test not added because it cannot be tested, via stripe. As this functionality has to be enabled by stripe.
-> Supported only for stripe card flow
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
Hardcoded testcases - cannot be tested in integ/sandbox/prod. These are tests triggered after hardcoding the amount values.
Response
Overcapture the authorized amount
Response
Refund
Response
Checklist
cargo +nightly fmt --all
cargo clippy