Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(router): make the billing country for apple pay as optional field (#3188)

Shankar Singh C15987cc81ecb
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 5efebb14f8..d2df44a9b2 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -3004,7 +3004,7 @@ pub struct SecretInfoToInitiateSdk {
pub struct ApplePayPaymentRequest {
/// The code for country
#[schema(value_type = CountryAlpha2, example = "US")]
- pub country_code: api_enums::CountryAlpha2,
+ pub country_code: Option<api_enums::CountryAlpha2>,
/// The code for currency
#[schema(value_type = Currency, example = "USD")]
pub currency_code: api_enums::Currency,
diff --git a/crates/router/src/connector/bluesnap/transformers.rs b/crates/router/src/connector/bluesnap/transformers.rs
index 3a980aee81..17cdf3b519 100644
--- a/crates/router/src/connector/bluesnap/transformers.rs
+++ b/crates/router/src/connector/bluesnap/transformers.rs
@@ -529,7 +529,7 @@ impl TryFrom<types::PaymentsSessionResponseRouterData<BluesnapWalletTokenRespons
session_response,
),
payment_request_data: Some(api_models::payments::ApplePayPaymentRequest {
- country_code: item.data.get_billing_country()?,
+ country_code: item.data.request.country,
currency_code: item.data.request.currency,
total: api_models::payments::AmountInfo {
label: payment_request_data.label,
diff --git a/crates/router/src/connector/payme/transformers.rs b/crates/router/src/connector/payme/transformers.rs
index e3d54881f1..a865b8fec3 100644
--- a/crates/router/src/connector/payme/transformers.rs
+++ b/crates/router/src/connector/payme/transformers.rs
@@ -545,6 +545,13 @@ impl<F>
}
_ => {
let currency_code = item.data.request.get_currency()?;
+ let country_code = item
+ .data
+ .address
+ .billing
+ .as_ref()
+ .and_then(|billing| billing.address.as_ref())
+ .and_then(|address| address.country);
let amount = item.data.request.get_amount()?;
let amount_in_base_unit = utils::to_currency_base_unit(amount, currency_code)?;
let pmd = item.data.request.payment_method_data.to_owned();
@@ -559,7 +566,7 @@ impl<F>
api_models::payments::ApplePaySessionResponse::NoSessionResponse,
payment_request_data: Some(
api_models::payments::ApplePayPaymentRequest {
- country_code: item.data.get_billing_country()?,
+ country_code,
currency_code,
total: api_models::payments::AmountInfo {
label: "Apple Pay".to_string(),
diff --git a/crates/router/src/connector/trustpay/transformers.rs b/crates/router/src/connector/trustpay/transformers.rs
index cca0c2d989..8ae12622fb 100644
--- a/crates/router/src/connector/trustpay/transformers.rs
+++ b/crates/router/src/connector/trustpay/transformers.rs
@@ -1181,7 +1181,7 @@ pub fn get_apple_pay_session<F, T>(
},
),
payment_request_data: Some(api_models::payments::ApplePayPaymentRequest {
- country_code: apple_pay_init_result.country_code,
+ country_code: Some(apple_pay_init_result.country_code),
currency_code: apple_pay_init_result.currency_code,
supported_networks: Some(apple_pay_init_result.supported_networks.clone()),
merchant_capabilities: Some(
diff --git a/crates/router/src/core/payments/flows/session_flow.rs b/crates/router/src/core/payments/flows/session_flow.rs
index 9151301917..de697e02f7 100644
--- a/crates/router/src/core/payments/flows/session_flow.rs
+++ b/crates/router/src/core/payments/flows/session_flow.rs
@@ -371,13 +371,7 @@ fn get_apple_pay_payment_request(
merchant_identifier: &str,
) -> RouterResult<payment_types::ApplePayPaymentRequest> {
let applepay_payment_request = payment_types::ApplePayPaymentRequest {
- country_code: session_data
- .country
- .to_owned()
- .get_required_value("country_code")
- .change_context(errors::ApiErrorResponse::MissingRequiredField {
- field_name: "country_code",
- })?,
+ country_code: session_data.country,
currency_code: session_data.currency,
total: amount_info,
merchant_capabilities: Some(payment_request_data.merchant_capabilities),