feat(router): pass fields to indicate if the customer address details to be connector from wallets (#5210)

This commit is contained in:
Shankar Singh C
2024-07-05 16:26:39 +05:30
committed by GitHub
parent a2c0d7f095
commit c642d9dcf5
4 changed files with 67 additions and 21 deletions

View File

@ -14287,6 +14287,16 @@
"type": "boolean", "type": "boolean",
"description": "flag to indicate whether to perform external 3ds authentication", "description": "flag to indicate whether to perform external 3ds authentication",
"example": true "example": true
},
"collect_shipping_details_from_wallets": {
"type": "boolean",
"description": "flag that indicates whether to collect shipping details from wallets or from the customer",
"nullable": true
},
"collect_billing_details_from_wallets": {
"type": "boolean",
"description": "flag that indicates whether to collect billing details from wallets or from the customer",
"nullable": true
} }
} }
}, },

View File

@ -795,6 +795,12 @@ pub struct PaymentMethodListResponse {
/// flag to indicate whether to perform external 3ds authentication /// flag to indicate whether to perform external 3ds authentication
#[schema(example = true)] #[schema(example = true)]
pub request_external_three_ds_authentication: bool, pub request_external_three_ds_authentication: bool,
/// flag that indicates whether to collect shipping details from wallets or from the customer
pub collect_shipping_details_from_wallets: Option<bool>,
/// flag that indicates whether to collect billing details from wallets or from the customer
pub collect_billing_details_from_wallets: Option<bool>,
} }
#[derive(Eq, PartialEq, Hash, Debug, serde::Deserialize, ToSchema)] #[derive(Eq, PartialEq, Hash, Debug, serde::Deserialize, ToSchema)]

View File

@ -2703,14 +2703,14 @@ pub async fn list_payment_methods(
if let Some((payment_attempt, payment_intent, business_profile)) = payment_attempt if let Some((payment_attempt, payment_intent, business_profile)) = payment_attempt
.as_ref() .as_ref()
.zip(payment_intent) .zip(payment_intent)
.zip(business_profile) .zip(business_profile.as_ref())
.map(|((pa, pi), bp)| (pa, pi, bp)) .map(|((pa, pi), bp)| (pa, pi, bp))
{ {
Box::pin(call_surcharge_decision_management( Box::pin(call_surcharge_decision_management(
state, state,
&merchant_account, &merchant_account,
&key_store, &key_store,
&business_profile, business_profile,
payment_attempt, payment_attempt,
payment_intent, payment_intent,
billing_address, billing_address,
@ -2720,6 +2720,14 @@ pub async fn list_payment_methods(
} else { } else {
api_surcharge_decision_configs::MerchantSurchargeConfigs::default() api_surcharge_decision_configs::MerchantSurchargeConfigs::default()
}; };
let collect_shipping_details_from_wallets = business_profile
.as_ref()
.and_then(|bp| bp.collect_shipping_details_from_wallet_connector);
let collect_billing_details_from_wallets = business_profile
.as_ref()
.and_then(|bp| bp.collect_billing_details_from_wallet_connector);
Ok(services::ApplicationResponse::Json( Ok(services::ApplicationResponse::Json(
api::PaymentMethodListResponse { api::PaymentMethodListResponse {
redirect_url: merchant_account.return_url, redirect_url: merchant_account.return_url,
@ -2756,6 +2764,8 @@ pub async fn list_payment_methods(
.unwrap_or_default(), .unwrap_or_default(),
currency, currency,
request_external_three_ds_authentication, request_external_three_ds_authentication,
collect_shipping_details_from_wallets,
collect_billing_details_from_wallets,
}, },
)) ))
} }

View File

@ -170,6 +170,7 @@ async fn create_applepay_session_token(
connector.connector_name.to_string(), connector.connector_name.to_string(),
delayed_response, delayed_response,
payment_types::NextActionCall::Confirm, payment_types::NextActionCall::Confirm,
header_payload,
) )
} else { } else {
// Get the apple pay metadata // Get the apple pay metadata
@ -345,8 +346,8 @@ async fn create_applepay_session_token(
)?; )?;
let apple_pay_session_response = match ( let apple_pay_session_response = match (
header_payload.browser_name, header_payload.browser_name.clone(),
header_payload.x_client_platform, header_payload.x_client_platform.clone(),
) { ) {
(Some(common_enums::BrowserName::Safari), Some(common_enums::ClientPlatform::Web)) (Some(common_enums::BrowserName::Safari), Some(common_enums::ClientPlatform::Web))
| (None, None) => { | (None, None) => {
@ -406,6 +407,7 @@ async fn create_applepay_session_token(
connector.connector_name.to_string(), connector.connector_name.to_string(),
delayed_response, delayed_response,
payment_types::NextActionCall::Confirm, payment_types::NextActionCall::Confirm,
header_payload,
) )
} }
} }
@ -489,6 +491,7 @@ fn create_apple_pay_session_response(
connector_name: String, connector_name: String,
delayed_response: bool, delayed_response: bool,
next_action: payment_types::NextActionCall, next_action: payment_types::NextActionCall,
header_payload: api_models::payments::HeaderPayload,
) -> RouterResult<types::PaymentsSessionRouterData> { ) -> RouterResult<types::PaymentsSessionRouterData> {
match session_response { match session_response {
Some(response) => Ok(types::PaymentsSessionRouterData { Some(response) => Ok(types::PaymentsSessionRouterData {
@ -508,23 +511,40 @@ fn create_apple_pay_session_response(
}), }),
..router_data.clone() ..router_data.clone()
}), }),
None => Ok(types::PaymentsSessionRouterData { None => {
response: Ok(types::PaymentsResponseData::SessionResponse { match (
session_token: payment_types::SessionToken::ApplePay(Box::new( header_payload.browser_name,
payment_types::ApplepaySessionTokenResponse { header_payload.x_client_platform,
session_token_data: None, ) {
payment_request_data: apple_pay_payment_request, (
connector: connector_name, Some(common_enums::BrowserName::Safari),
delayed_session_token: delayed_response, Some(common_enums::ClientPlatform::Web),
sdk_next_action: { payment_types::SdkNextAction { next_action } }, )
connector_reference_id: None, | (None, None) => Ok(types::PaymentsSessionRouterData {
connector_sdk_public_key: None, response: Ok(types::PaymentsResponseData::SessionResponse {
connector_merchant_id: None, session_token: payment_types::SessionToken::NoSessionTokenReceived,
}, }),
)), ..router_data.clone()
}), }),
..router_data.clone() _ => Ok(types::PaymentsSessionRouterData {
}), response: Ok(types::PaymentsResponseData::SessionResponse {
session_token: payment_types::SessionToken::ApplePay(Box::new(
payment_types::ApplepaySessionTokenResponse {
session_token_data: None,
payment_request_data: apple_pay_payment_request,
connector: connector_name,
delayed_session_token: delayed_response,
sdk_next_action: { payment_types::SdkNextAction { next_action } },
connector_reference_id: None,
connector_sdk_public_key: None,
connector_merchant_id: None,
},
)),
}),
..router_data.clone()
}),
}
}
} }
} }