Skip to content

Commit f4145ae

Browse files
ShankarSinghCNarayanbhat166
authored andcommitted
feat(router): pass fields to indicate if the customer address details to be connector from wallets (#5210)
1 parent 0644de4 commit f4145ae

File tree

4 files changed

+67
-21
lines changed

4 files changed

+67
-21
lines changed

api-reference/openapi_spec.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14288,6 +14288,16 @@
1428814288
"type": "boolean",
1428914289
"description": "flag to indicate whether to perform external 3ds authentication",
1429014290
"example": true
14291+
},
14292+
"collect_shipping_details_from_wallets": {
14293+
"type": "boolean",
14294+
"description": "flag that indicates whether to collect shipping details from wallets or from the customer",
14295+
"nullable": true
14296+
},
14297+
"collect_billing_details_from_wallets": {
14298+
"type": "boolean",
14299+
"description": "flag that indicates whether to collect billing details from wallets or from the customer",
14300+
"nullable": true
1429114301
}
1429214302
}
1429314303
},

crates/api_models/src/payment_methods.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,12 @@ pub struct PaymentMethodListResponse {
795795
/// flag to indicate whether to perform external 3ds authentication
796796
#[schema(example = true)]
797797
pub request_external_three_ds_authentication: bool,
798+
799+
/// flag that indicates whether to collect shipping details from wallets or from the customer
800+
pub collect_shipping_details_from_wallets: Option<bool>,
801+
802+
/// flag that indicates whether to collect billing details from wallets or from the customer
803+
pub collect_billing_details_from_wallets: Option<bool>,
798804
}
799805

800806
#[derive(Eq, PartialEq, Hash, Debug, serde::Deserialize, ToSchema)]

crates/router/src/core/payment_methods/cards.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,14 +2703,14 @@ pub async fn list_payment_methods(
27032703
if let Some((payment_attempt, payment_intent, business_profile)) = payment_attempt
27042704
.as_ref()
27052705
.zip(payment_intent)
2706-
.zip(business_profile)
2706+
.zip(business_profile.as_ref())
27072707
.map(|((pa, pi), bp)| (pa, pi, bp))
27082708
{
27092709
Box::pin(call_surcharge_decision_management(
27102710
state,
27112711
&merchant_account,
27122712
&key_store,
2713-
&business_profile,
2713+
business_profile,
27142714
payment_attempt,
27152715
payment_intent,
27162716
billing_address,
@@ -2720,6 +2720,14 @@ pub async fn list_payment_methods(
27202720
} else {
27212721
api_surcharge_decision_configs::MerchantSurchargeConfigs::default()
27222722
};
2723+
2724+
let collect_shipping_details_from_wallets = business_profile
2725+
.as_ref()
2726+
.and_then(|bp| bp.collect_shipping_details_from_wallet_connector);
2727+
2728+
let collect_billing_details_from_wallets = business_profile
2729+
.as_ref()
2730+
.and_then(|bp| bp.collect_billing_details_from_wallet_connector);
27232731
Ok(services::ApplicationResponse::Json(
27242732
api::PaymentMethodListResponse {
27252733
redirect_url: merchant_account.return_url,
@@ -2756,6 +2764,8 @@ pub async fn list_payment_methods(
27562764
.unwrap_or_default(),
27572765
currency,
27582766
request_external_three_ds_authentication,
2767+
collect_shipping_details_from_wallets,
2768+
collect_billing_details_from_wallets,
27592769
},
27602770
))
27612771
}

crates/router/src/core/payments/flows/session_flow.rs

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ async fn create_applepay_session_token(
170170
connector.connector_name.to_string(),
171171
delayed_response,
172172
payment_types::NextActionCall::Confirm,
173+
header_payload,
173174
)
174175
} else {
175176
// Get the apple pay metadata
@@ -345,8 +346,8 @@ async fn create_applepay_session_token(
345346
)?;
346347

347348
let apple_pay_session_response = match (
348-
header_payload.browser_name,
349-
header_payload.x_client_platform,
349+
header_payload.browser_name.clone(),
350+
header_payload.x_client_platform.clone(),
350351
) {
351352
(Some(common_enums::BrowserName::Safari), Some(common_enums::ClientPlatform::Web))
352353
| (None, None) => {
@@ -406,6 +407,7 @@ async fn create_applepay_session_token(
406407
connector.connector_name.to_string(),
407408
delayed_response,
408409
payment_types::NextActionCall::Confirm,
410+
header_payload,
409411
)
410412
}
411413
}
@@ -489,6 +491,7 @@ fn create_apple_pay_session_response(
489491
connector_name: String,
490492
delayed_response: bool,
491493
next_action: payment_types::NextActionCall,
494+
header_payload: api_models::payments::HeaderPayload,
492495
) -> RouterResult<types::PaymentsSessionRouterData> {
493496
match session_response {
494497
Some(response) => Ok(types::PaymentsSessionRouterData {
@@ -508,23 +511,40 @@ fn create_apple_pay_session_response(
508511
}),
509512
..router_data.clone()
510513
}),
511-
None => Ok(types::PaymentsSessionRouterData {
512-
response: Ok(types::PaymentsResponseData::SessionResponse {
513-
session_token: payment_types::SessionToken::ApplePay(Box::new(
514-
payment_types::ApplepaySessionTokenResponse {
515-
session_token_data: None,
516-
payment_request_data: apple_pay_payment_request,
517-
connector: connector_name,
518-
delayed_session_token: delayed_response,
519-
sdk_next_action: { payment_types::SdkNextAction { next_action } },
520-
connector_reference_id: None,
521-
connector_sdk_public_key: None,
522-
connector_merchant_id: None,
523-
},
524-
)),
525-
}),
526-
..router_data.clone()
527-
}),
514+
None => {
515+
match (
516+
header_payload.browser_name,
517+
header_payload.x_client_platform,
518+
) {
519+
(
520+
Some(common_enums::BrowserName::Safari),
521+
Some(common_enums::ClientPlatform::Web),
522+
)
523+
| (None, None) => Ok(types::PaymentsSessionRouterData {
524+
response: Ok(types::PaymentsResponseData::SessionResponse {
525+
session_token: payment_types::SessionToken::NoSessionTokenReceived,
526+
}),
527+
..router_data.clone()
528+
}),
529+
_ => Ok(types::PaymentsSessionRouterData {
530+
response: Ok(types::PaymentsResponseData::SessionResponse {
531+
session_token: payment_types::SessionToken::ApplePay(Box::new(
532+
payment_types::ApplepaySessionTokenResponse {
533+
session_token_data: None,
534+
payment_request_data: apple_pay_payment_request,
535+
connector: connector_name,
536+
delayed_session_token: delayed_response,
537+
sdk_next_action: { payment_types::SdkNextAction { next_action } },
538+
connector_reference_id: None,
539+
connector_sdk_public_key: None,
540+
connector_merchant_id: None,
541+
},
542+
)),
543+
}),
544+
..router_data.clone()
545+
}),
546+
}
547+
}
528548
}
529549
}
530550

0 commit comments

Comments
 (0)