-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat(core): Add support for partial auth in proxy payments [V2] #9503
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
base: main
Are you sure you want to change the base?
Conversation
crates/api_models/src/payments.rs
Outdated
pub merchant_connector_details: Option<common_types::domain::MerchantConnectorAuthDetails>, | ||
|
||
/// Allow partial authorization for this payment | ||
pub enable_partial_authorization: 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.
Introduce a wrapper type for this bool.
Refer to RequestIncrementalAuthorization
Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, diesel::expression::AsExpression, | ||
)] | ||
#[diesel(sql_type = diesel::sql_types::Bool)] | ||
pub struct EnablePartialAuthorizationBool(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.
You don't need to define in two places
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
fn get_is_partial_approval(&self) -> Option<PartialApprovalFlag> { | ||
self.enable_partial_authorization | ||
.map(PartialApprovalFlag::from) | ||
.map(|partial_auth| PartialApprovalFlag::from(partial_auth.is_true())) |
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.
You can have from implementation on PartialApprovalFlag.
PartialApprovalFlag::from(EnablePartialAuthorizationBool).
This change can be eliminated
Self::ReviewForFailedPayment(attempt_triggered_by) | ||
} | ||
(enums::IntentStatus::Succeeded, _, _) => Self::ReviewForSuccessfulPayment, | ||
(enums::IntentStatus::Succeeded | enums::IntentStatus::PartiallyCaptured, _, _) => { |
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 only succeded and partially_captiured?
(enums::IntentStatus::Succeeded | enums::IntentStatus::PartiallyCaptured, _, _) => { | ||
Self::ReviewForSuccessfulPayment | ||
} |
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.
(enums::IntentStatus::Succeeded | enums::IntentStatus::PartiallyCaptured, _, _) => { | |
Self::ReviewForSuccessfulPayment | |
} | |
(intent_status, _, _) => { | |
if intent_status.some_impl_function(){ | |
Self::ReviewForSuccessfulPayment | |
} | |
else{ | |
Self::InvalidDecision | |
} | |
} |
@@ -1,3 +1,4 @@ | |||
use common_types::primitive_wrappers::EnablePartialAuthorizationBool; |
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.
use common_types::primitive_wrappers::EnablePartialAuthorizationBool; | |
use common_types::primitive_wrappers; |
pub payment_channel: Option<common_enums::PaymentChannel>, | ||
pub feature_metadata: Option<Secret<serde_json::Value>>, | ||
pub enable_partial_authorization: Option<bool>, | ||
pub enable_partial_authorization: Option<EnablePartialAuthorizationBool>, |
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.
pub enable_partial_authorization: Option<EnablePartialAuthorizationBool>, | |
pub enable_partial_authorization: Option< primitive_wrappers::EnablePartialAuthorizationBool>, |
Type of Change
Description
This PR adds support for partial auth in proxy payments which is triggered in revenue recovery workflow.
enable_partial_authorization
is passed in/recovery
flow, which update payment intent with enable_partial_authorization to true. Proxy(authorize) will gets triggered by recovery execute workflow, which will then send the same to connector. Based onamount_captured
send by connector we either move the payment to success/ PartialCharged.NOTE : changes are still pending for normal payments partial auth.
This PR also contains few changes regarding revenue recovery workflow where we consider PartialCharged payments as Succeeded. We will the resume later when auto retries system is enabled for partial charged payments.
Additional Changes
Motivation and Context
How did you test it?
Reference doc for partial auth testing via worldpay vantiv : http://support.worldpay.com/support/CNP-API/content/testauthincind.htm#TABLE2-1
TEST CASE 1 :
set up revenue recovery payment and billing mca with worldpay vantiv and billing mca
Trigger failed invoice
-> Pass enable_partial_authorization to false , this should make payment succeeded/Fail.
-> Pass enable_partial_authorization to true and pass normal card which will debit complete amount.
Checklist
cargo +nightly fmt --all
cargo clippy