mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 19:42:27 +08:00
feat(payment_methods_list): add is_tax_connector_enabled boolean value in payment_methods_list call response (#5707)
Co-authored-by: Sagnik Mitra <sagnik.mitra@sagnikmitra-JNWPH6GQ9R.local> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -3626,6 +3626,10 @@ pub async fn list_payment_methods(
|
||||
});
|
||||
}
|
||||
let currency = payment_intent.as_ref().and_then(|pi| pi.currency);
|
||||
let skip_external_tax_calculation = payment_intent
|
||||
.as_ref()
|
||||
.and_then(|intent| intent.skip_external_tax_calculation)
|
||||
.unwrap_or(false);
|
||||
let request_external_three_ds_authentication = payment_intent
|
||||
.as_ref()
|
||||
.and_then(|intent| intent.request_external_three_ds_authentication)
|
||||
@ -3670,6 +3674,10 @@ pub async fn list_payment_methods(
|
||||
business_profile.collect_billing_details_from_wallet_connector
|
||||
}));
|
||||
|
||||
let is_tax_connector_enabled = business_profile.as_ref().map_or(false, |business_profile| {
|
||||
business_profile.get_is_tax_connector_enabled()
|
||||
});
|
||||
|
||||
Ok(services::ApplicationResponse::Json(
|
||||
api::PaymentMethodListResponse {
|
||||
redirect_url: business_profile
|
||||
@ -3710,6 +3718,7 @@ pub async fn list_payment_methods(
|
||||
request_external_three_ds_authentication,
|
||||
collect_shipping_details_from_wallets,
|
||||
collect_billing_details_from_wallets,
|
||||
is_tax_calculation_enabled: is_tax_connector_enabled && !skip_external_tax_calculation,
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
@ -3108,6 +3108,7 @@ mod tests {
|
||||
organization_id: id_type::OrganizationId::default(),
|
||||
shipping_cost: None,
|
||||
tax_details: None,
|
||||
skip_external_tax_calculation: None,
|
||||
};
|
||||
let req_cs = Some("1".to_string());
|
||||
assert!(authenticate_client_secret(req_cs.as_ref(), &payment_intent).is_ok());
|
||||
@ -3176,6 +3177,7 @@ mod tests {
|
||||
organization_id: id_type::OrganizationId::default(),
|
||||
shipping_cost: None,
|
||||
tax_details: None,
|
||||
skip_external_tax_calculation: None,
|
||||
};
|
||||
let req_cs = Some("1".to_string());
|
||||
assert!(authenticate_client_secret(req_cs.as_ref(), &payment_intent,).is_err())
|
||||
@ -3242,6 +3244,7 @@ mod tests {
|
||||
organization_id: id_type::OrganizationId::default(),
|
||||
shipping_cost: None,
|
||||
tax_details: None,
|
||||
skip_external_tax_calculation: None,
|
||||
};
|
||||
let req_cs = Some("1".to_string());
|
||||
assert!(authenticate_client_secret(req_cs.as_ref(), &payment_intent).is_err())
|
||||
|
||||
@ -1283,6 +1283,8 @@ impl PaymentCreate {
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||
.attach_printable("Unable to encrypt customer details")?;
|
||||
|
||||
let skip_external_tax_calculation = request.skip_external_tax_calculation;
|
||||
|
||||
Ok(storage::PaymentIntent {
|
||||
payment_id: payment_id.to_owned(),
|
||||
merchant_id: merchant_account.get_id().to_owned(),
|
||||
@ -1338,6 +1340,7 @@ impl PaymentCreate {
|
||||
organization_id: merchant_account.organization_id.clone(),
|
||||
shipping_cost: request.shipping_cost,
|
||||
tax_details: None,
|
||||
skip_external_tax_calculation,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user