mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 09:38:33 +08:00
feat(router): make the billing country for apple pay as optional field (#3188)
This commit is contained in:
@ -3004,7 +3004,7 @@ pub struct SecretInfoToInitiateSdk {
|
|||||||
pub struct ApplePayPaymentRequest {
|
pub struct ApplePayPaymentRequest {
|
||||||
/// The code for country
|
/// The code for country
|
||||||
#[schema(value_type = CountryAlpha2, example = "US")]
|
#[schema(value_type = CountryAlpha2, example = "US")]
|
||||||
pub country_code: api_enums::CountryAlpha2,
|
pub country_code: Option<api_enums::CountryAlpha2>,
|
||||||
/// The code for currency
|
/// The code for currency
|
||||||
#[schema(value_type = Currency, example = "USD")]
|
#[schema(value_type = Currency, example = "USD")]
|
||||||
pub currency_code: api_enums::Currency,
|
pub currency_code: api_enums::Currency,
|
||||||
|
|||||||
@ -529,7 +529,7 @@ impl TryFrom<types::PaymentsSessionResponseRouterData<BluesnapWalletTokenRespons
|
|||||||
session_response,
|
session_response,
|
||||||
),
|
),
|
||||||
payment_request_data: Some(api_models::payments::ApplePayPaymentRequest {
|
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,
|
currency_code: item.data.request.currency,
|
||||||
total: api_models::payments::AmountInfo {
|
total: api_models::payments::AmountInfo {
|
||||||
label: payment_request_data.label,
|
label: payment_request_data.label,
|
||||||
|
|||||||
@ -545,6 +545,13 @@ impl<F>
|
|||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let currency_code = item.data.request.get_currency()?;
|
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 = item.data.request.get_amount()?;
|
||||||
let amount_in_base_unit = utils::to_currency_base_unit(amount, currency_code)?;
|
let amount_in_base_unit = utils::to_currency_base_unit(amount, currency_code)?;
|
||||||
let pmd = item.data.request.payment_method_data.to_owned();
|
let pmd = item.data.request.payment_method_data.to_owned();
|
||||||
@ -559,7 +566,7 @@ impl<F>
|
|||||||
api_models::payments::ApplePaySessionResponse::NoSessionResponse,
|
api_models::payments::ApplePaySessionResponse::NoSessionResponse,
|
||||||
payment_request_data: Some(
|
payment_request_data: Some(
|
||||||
api_models::payments::ApplePayPaymentRequest {
|
api_models::payments::ApplePayPaymentRequest {
|
||||||
country_code: item.data.get_billing_country()?,
|
country_code,
|
||||||
currency_code,
|
currency_code,
|
||||||
total: api_models::payments::AmountInfo {
|
total: api_models::payments::AmountInfo {
|
||||||
label: "Apple Pay".to_string(),
|
label: "Apple Pay".to_string(),
|
||||||
|
|||||||
@ -1181,7 +1181,7 @@ pub fn get_apple_pay_session<F, T>(
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
payment_request_data: Some(api_models::payments::ApplePayPaymentRequest {
|
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,
|
currency_code: apple_pay_init_result.currency_code,
|
||||||
supported_networks: Some(apple_pay_init_result.supported_networks.clone()),
|
supported_networks: Some(apple_pay_init_result.supported_networks.clone()),
|
||||||
merchant_capabilities: Some(
|
merchant_capabilities: Some(
|
||||||
|
|||||||
@ -371,13 +371,7 @@ fn get_apple_pay_payment_request(
|
|||||||
merchant_identifier: &str,
|
merchant_identifier: &str,
|
||||||
) -> RouterResult<payment_types::ApplePayPaymentRequest> {
|
) -> RouterResult<payment_types::ApplePayPaymentRequest> {
|
||||||
let applepay_payment_request = payment_types::ApplePayPaymentRequest {
|
let applepay_payment_request = payment_types::ApplePayPaymentRequest {
|
||||||
country_code: session_data
|
country_code: session_data.country,
|
||||||
.country
|
|
||||||
.to_owned()
|
|
||||||
.get_required_value("country_code")
|
|
||||||
.change_context(errors::ApiErrorResponse::MissingRequiredField {
|
|
||||||
field_name: "country_code",
|
|
||||||
})?,
|
|
||||||
currency_code: session_data.currency,
|
currency_code: session_data.currency,
|
||||||
total: amount_info,
|
total: amount_info,
|
||||||
merchant_capabilities: Some(payment_request_data.merchant_capabilities),
|
merchant_capabilities: Some(payment_request_data.merchant_capabilities),
|
||||||
|
|||||||
Reference in New Issue
Block a user