mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 21:07:58 +08:00
feat: core changes for extended authorization (#6766)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -3028,7 +3028,13 @@ where
|
||||
|
||||
operation
|
||||
.to_domain()?
|
||||
.populate_payment_data(state, payment_data, merchant_account)
|
||||
.populate_payment_data(
|
||||
state,
|
||||
payment_data,
|
||||
merchant_account,
|
||||
business_profile,
|
||||
&connector,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let (pd, tokenization_action) = get_connector_tokenization_action_when_confirm_true(
|
||||
|
||||
@ -309,6 +309,8 @@ pub trait Domain<F: Clone, R, D>: Send + Sync {
|
||||
_state: &SessionState,
|
||||
_payment_data: &mut D,
|
||||
_merchant_account: &domain::MerchantAccount,
|
||||
_business_profile: &domain::Profile,
|
||||
_connector_data: &api::ConnectorData,
|
||||
) -> CustomResult<(), errors::ApiErrorResponse> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -985,8 +985,19 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
|
||||
state: &SessionState,
|
||||
payment_data: &mut PaymentData<F>,
|
||||
_merchant_account: &domain::MerchantAccount,
|
||||
business_profile: &domain::Profile,
|
||||
connector_data: &api::ConnectorData,
|
||||
) -> CustomResult<(), errors::ApiErrorResponse> {
|
||||
populate_surcharge_details(state, payment_data).await
|
||||
populate_surcharge_details(state, payment_data).await?;
|
||||
payment_data.payment_attempt.request_extended_authorization = payment_data
|
||||
.payment_intent
|
||||
.get_request_extended_authorization_bool_if_connector_supports(
|
||||
connector_data.connector_name,
|
||||
business_profile.always_request_extended_authorization,
|
||||
payment_data.payment_attempt.payment_method,
|
||||
payment_data.payment_attempt.payment_method_type,
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
|
||||
@ -1572,7 +1572,7 @@ impl PaymentCreate {
|
||||
shipping_cost: request.shipping_cost,
|
||||
tax_details,
|
||||
skip_external_tax_calculation,
|
||||
request_extended_authorization: None,
|
||||
request_extended_authorization: request.request_extended_authorization,
|
||||
psd2_sca_exemption_type: request.psd2_sca_exemption_type,
|
||||
platform_merchant_id: platform_merchant_account
|
||||
.map(|platform_merchant_account| platform_merchant_account.get_id().to_owned()),
|
||||
|
||||
@ -1666,6 +1666,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()
|
||||
})
|
||||
.map(|extended_auth_resp| {
|
||||
(
|
||||
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
|
||||
{
|
||||
@ -1727,6 +1740,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,
|
||||
connector_mandate_detail: payment_data
|
||||
.payment_attempt
|
||||
.connector_mandate_detail
|
||||
|
||||
@ -485,6 +485,8 @@ where
|
||||
encoded_data,
|
||||
unified_code: None,
|
||||
unified_message: None,
|
||||
capture_before: None,
|
||||
extended_authorization_applied: None,
|
||||
payment_method_data: additional_payment_method_data,
|
||||
connector_mandate_detail: None,
|
||||
charges,
|
||||
|
||||
@ -291,6 +291,7 @@ pub async fn construct_payment_router_data_for_authorize<'a>(
|
||||
complete_authorize_url,
|
||||
customer_id: None,
|
||||
surcharge_details: None,
|
||||
request_extended_authorization: None,
|
||||
request_incremental_authorization: matches!(
|
||||
payment_data
|
||||
.payment_intent
|
||||
@ -3271,6 +3272,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
|
||||
.map(AuthenticationData::foreign_try_from)
|
||||
.transpose()?,
|
||||
customer_acceptance: payment_data.customer_acceptance,
|
||||
request_extended_authorization: attempt.request_extended_authorization,
|
||||
split_payments,
|
||||
merchant_order_reference_id,
|
||||
integrity_object: None,
|
||||
|
||||
@ -904,6 +904,7 @@ impl ForeignFrom<&SetupMandateRouterData> for PaymentsAuthorizeData {
|
||||
surcharge_details: None,
|
||||
request_incremental_authorization: data.request.request_incremental_authorization,
|
||||
metadata: None,
|
||||
request_extended_authorization: None,
|
||||
authentication_data: None,
|
||||
customer_acceptance: data.request.customer_acceptance.clone(),
|
||||
split_payments: None, // TODO: allow charges on mandates?
|
||||
|
||||
@ -52,6 +52,7 @@ impl VerifyConnectorData {
|
||||
complete_authorize_url: None,
|
||||
related_transaction_id: None,
|
||||
statement_descriptor_suffix: None,
|
||||
request_extended_authorization: None,
|
||||
request_incremental_authorization: false,
|
||||
authentication_data: None,
|
||||
customer_acceptance: None,
|
||||
|
||||
Reference in New Issue
Block a user