Skip to content

Commit

Permalink
feat: enable updating capture_before and external_authentication_appl…
Browse files Browse the repository at this point in the history
…ied fields in payment_attempt during connector response handling
  • Loading branch information
hrithikesh026 committed Dec 6, 2024
1 parent 6002bb0 commit 83c0a49
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
53 changes: 53 additions & 0 deletions crates/diesel_models/src/payment_attempt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,8 @@ pub enum PaymentAttemptUpdate {
encoded_data: Option<String>,
unified_code: Option<Option<String>>,
unified_message: Option<Option<String>>,
capture_before: Option<PrimitiveDateTime>,
extended_authorization_applied: Option<ExtendedAuthorizationAppliedBool>,
payment_method_data: Option<serde_json::Value>,
charge_id: Option<String>,
connector_mandate_detail: Option<ConnectorMandateReferenceId>,
Expand Down Expand Up @@ -860,6 +862,8 @@ pub struct PaymentAttemptUpdateInternal {
pub client_version: Option<String>,
pub customer_acceptance: Option<pii::SecretSerdeValue>,
pub card_network: Option<String>,
pub capture_before: Option<PrimitiveDateTime>,
pub extended_authorization_applied: Option<ExtendedAuthorizationAppliedBool>,
pub shipping_cost: Option<MinorUnit>,
pub order_tax_amount: Option<MinorUnit>,
pub connector_transaction_data: Option<String>,
Expand Down Expand Up @@ -1047,6 +1051,8 @@ impl PaymentAttemptUpdate {
order_tax_amount,
connector_transaction_data,
connector_mandate_detail,
capture_before,
extended_authorization_applied,
} = PaymentAttemptUpdateInternal::from(self).populate_derived_fields(&source);
PaymentAttempt {
amount: amount.unwrap_or(source.amount),
Expand Down Expand Up @@ -1105,6 +1111,9 @@ impl PaymentAttemptUpdate {
connector_transaction_data: connector_transaction_data
.or(source.connector_transaction_data),
connector_mandate_detail: connector_mandate_detail.or(source.connector_mandate_detail),
capture_before: capture_before.or(source.capture_before),
extended_authorization_applied: extended_authorization_applied
.or(source.extended_authorization_applied),
..source
}
}
Expand Down Expand Up @@ -2154,6 +2163,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
customer_acceptance: None,
card_network: None,
shipping_cost: None,
capture_before: None,
extended_authorization_applied: None,
order_tax_amount: None,
connector_transaction_data: None,
connector_mandate_detail: None,
Expand Down Expand Up @@ -2211,6 +2222,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
card_network: None,
shipping_cost: None,
order_tax_amount: None,
capture_before: None,
extended_authorization_applied: None,
connector_transaction_data: None,
connector_mandate_detail: None,
},
Expand Down Expand Up @@ -2298,6 +2311,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
card_network: None,
shipping_cost,
order_tax_amount,
capture_before: None,
extended_authorization_applied: None,
connector_transaction_data: None,
connector_mandate_detail,
},
Expand Down Expand Up @@ -2355,6 +2370,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
card_network: None,
shipping_cost: None,
order_tax_amount: None,
capture_before: None,
extended_authorization_applied: None,
connector_transaction_data: None,
connector_mandate_detail: None,
},
Expand Down Expand Up @@ -2413,6 +2430,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
card_network: None,
shipping_cost: None,
order_tax_amount: None,
capture_before: None,
extended_authorization_applied: None,
connector_transaction_data: None,
connector_mandate_detail: None,
},
Expand Down Expand Up @@ -2471,6 +2490,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
card_network: None,
shipping_cost: None,
order_tax_amount: None,
capture_before: None,
extended_authorization_applied: None,
connector_transaction_data: None,
connector_mandate_detail: None,
},
Expand Down Expand Up @@ -2527,6 +2548,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
card_network: None,
shipping_cost: None,
order_tax_amount: None,
capture_before: None,
extended_authorization_applied: None,
connector_transaction_data: None,
connector_mandate_detail,
},
Expand Down Expand Up @@ -2583,6 +2606,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
card_network: None,
shipping_cost: None,
order_tax_amount: None,
capture_before: None,
extended_authorization_applied: None,
connector_transaction_data: None,
connector_mandate_detail: None,
},
Expand All @@ -2605,6 +2630,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
encoded_data,
unified_code,
unified_message,
capture_before,
extended_authorization_applied,
payment_method_data,
charge_id,
connector_mandate_detail,
Expand Down Expand Up @@ -2663,6 +2690,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
client_version: None,
customer_acceptance: None,
card_network: None,
capture_before,
extended_authorization_applied,
shipping_cost: None,
order_tax_amount: None,
connector_mandate_detail,
Expand Down Expand Up @@ -2736,6 +2765,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
client_version: None,
customer_acceptance: None,
card_network: None,
capture_before: None,
extended_authorization_applied: None,
shipping_cost: None,
order_tax_amount: None,
connector_mandate_detail: None,
Expand Down Expand Up @@ -2790,6 +2821,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
customer_acceptance: None,
card_network: None,
shipping_cost: None,
capture_before: None,
extended_authorization_applied: None,
order_tax_amount: None,
connector_transaction_data: None,
connector_mandate_detail: None,
Expand Down Expand Up @@ -2852,6 +2885,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
customer_acceptance: None,
card_network: None,
shipping_cost: None,
capture_before: None,
extended_authorization_applied: None,
order_tax_amount: None,
connector_transaction_data: None,
connector_mandate_detail: None,
Expand Down Expand Up @@ -2922,6 +2957,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
customer_acceptance: None,
card_network: None,
shipping_cost: None,
capture_before: None,
extended_authorization_applied: None,
order_tax_amount: None,
connector_mandate_detail: None,
}
Expand Down Expand Up @@ -2989,6 +3026,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
client_version: None,
customer_acceptance: None,
card_network: None,
capture_before: None,
extended_authorization_applied: None,
shipping_cost: None,
order_tax_amount: None,
connector_mandate_detail: None,
Expand Down Expand Up @@ -3048,6 +3087,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
card_network: None,
shipping_cost: None,
order_tax_amount: None,
capture_before: None,
extended_authorization_applied: None,
connector_transaction_data: None,
connector_mandate_detail: None,
},
Expand Down Expand Up @@ -3104,6 +3145,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
customer_acceptance: None,
card_network: None,
shipping_cost: None,
capture_before: None,
extended_authorization_applied: None,
order_tax_amount: None,
connector_transaction_data: None,
connector_mandate_detail: None,
Expand Down Expand Up @@ -3171,6 +3214,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
customer_acceptance: None,
card_network: None,
shipping_cost: None,
capture_before: None,
extended_authorization_applied: None,
order_tax_amount: None,
connector_mandate_detail: None,
}
Expand Down Expand Up @@ -3228,6 +3273,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
card_network: None,
shipping_cost: None,
order_tax_amount: None,
capture_before: None,
extended_authorization_applied: None,
connector_transaction_data: None,
connector_mandate_detail: None,
},
Expand Down Expand Up @@ -3287,6 +3334,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
card_network: None,
shipping_cost: None,
order_tax_amount: None,
capture_before: None,
extended_authorization_applied: None,
connector_transaction_data: None,
connector_mandate_detail: None,
},
Expand Down Expand Up @@ -3355,6 +3404,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
customer_acceptance: None,
card_network: None,
shipping_cost: None,
capture_before: None,
extended_authorization_applied: None,
order_tax_amount: None,
connector_mandate_detail: None,
}
Expand Down Expand Up @@ -3412,6 +3463,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
card_network: None,
shipping_cost: None,
order_tax_amount: None,
capture_before: None,
extended_authorization_applied: None,
connector_transaction_data: None,
connector_mandate_detail: None,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,8 @@ pub enum PaymentAttemptUpdate {
encoded_data: Option<String>,
unified_code: Option<Option<String>>,
unified_message: Option<Option<String>>,
capture_before: Option<PrimitiveDateTime>,
extended_authorization_applied: Option<ExtendedAuthorizationAppliedBool>,
payment_method_data: Option<serde_json::Value>,
charge_id: Option<String>,
connector_mandate_detail: Option<ConnectorMandateReferenceId>,
Expand Down Expand Up @@ -1141,6 +1143,8 @@ impl PaymentAttemptUpdate {
encoded_data,
unified_code,
unified_message,
capture_before,
extended_authorization_applied,
payment_method_data,
charge_id,
connector_mandate_detail,
Expand All @@ -1163,6 +1167,8 @@ impl PaymentAttemptUpdate {
encoded_data,
unified_code,
unified_message,
capture_before,
extended_authorization_applied,
payment_method_data,
charge_id,
connector_mandate_detail,
Expand Down
15 changes: 15 additions & 0 deletions crates/router/src/core/payments/operations/payment_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,19 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
payment_data.payment_attempt.connector.clone(),
payment_data.payment_attempt.merchant_id.clone(),
);
let (capture_before, extended_authorization_applied) = router_data
.connector_response
.as_ref()
.and_then(|connector_response| {
connector_response.get_extended_authorization_response_data()
})
.and_then(|extended_auth_resp| {
Some((
extended_auth_resp.capture_before,
extended_auth_resp.extended_authentication_applied,
))
})
.unwrap_or((None, None));
let (capture_updates, payment_attempt_update) = match payment_data
.multiple_capture_data
{
Expand Down Expand Up @@ -1728,6 +1741,8 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
authentication_data,
encoded_data,
payment_method_data: additional_payment_method_data,
capture_before,
extended_authorization_applied,
charge_id,
connector_mandate_detail: payment_data
.payment_attempt
Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/core/payments/retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@ where
encoded_data,
unified_code: None,
unified_message: None,
capture_before: None,
extended_authorization_applied: None,
payment_method_data: additional_payment_method_data,
charge_id,
connector_mandate_detail: None,
Expand Down

0 comments on commit 83c0a49

Please sign in to comment.