WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 31ed36c

Browse files
feat(wallet): add equivalent changes of UCS wallet payment support for PayPalSdk, Apple Pay (thidpartysdk), and Google Pay(thirdpartysdk) of braintree
1 parent 8ba4cfb commit 31ed36c

File tree

6 files changed

+105
-27
lines changed

6 files changed

+105
-27
lines changed

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

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,10 +1013,18 @@ async fn call_unified_connector_service_authorize(
10131013
}
10141014
}
10151015

1016-
let router_data_response = ucs_data.router_data_response.map(|(response, status)| {
1017-
router_data.status = status;
1018-
response
1019-
});
1016+
let router_data_response = match &ucs_data.router_data_response {
1017+
Ok((response, status)) => {
1018+
router_data.status = status.clone();
1019+
Ok(response.clone())
1020+
}
1021+
Err(error_response) => {
1022+
if let Some(attempt_status) = error_response.attempt_status {
1023+
router_data.status = attempt_status;
1024+
}
1025+
Err(error_response.clone())
1026+
}
1027+
};
10201028
router_data.response = router_data_response;
10211029
router_data.amount_captured = payment_authorize_response.captured_amount;
10221030
router_data.minor_amount_captured = payment_authorize_response
@@ -1327,10 +1335,18 @@ async fn call_unified_connector_service_repeat_payment(
13271335
}
13281336
}
13291337

1330-
let router_data_response = ucs_data.router_data_response.map(|(response, status)| {
1331-
router_data.status = status;
1332-
response
1333-
});
1338+
let router_data_response = match &ucs_data.router_data_response {
1339+
Ok((response, status)) => {
1340+
router_data.status = status.clone();
1341+
Ok(response.clone())
1342+
}
1343+
Err(error_response) => {
1344+
if let Some(attempt_status) = error_response.attempt_status {
1345+
router_data.status = attempt_status;
1346+
}
1347+
Err(error_response.clone())
1348+
}
1349+
};
13341350
router_data.response = router_data_response;
13351351
router_data.amount_captured = payment_repeat_response.captured_amount;
13361352
router_data.minor_amount_captured = payment_repeat_response

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,18 @@ impl Feature<api::ExternalVaultProxy, types::ExternalVaultProxyPaymentsData>
437437
.change_context(ApiErrorResponse::InternalServerError)
438438
.attach_printable("Failed to deserialize UCS response")?;
439439

440-
let router_data_response = ucs_data.router_data_response.map(|(response, status)|{
441-
router_data.status = status;
442-
response
443-
});
440+
let router_data_response = match &ucs_data.router_data_response {
441+
Ok((response, status)) => {
442+
router_data.status = status.clone();
443+
Ok(response.clone())
444+
}
445+
Err(error_response) => {
446+
if let Some(attempt_status) = error_response.attempt_status {
447+
router_data.status = attempt_status;
448+
}
449+
Err(error_response.clone())
450+
}
451+
};
444452
router_data.response = router_data_response;
445453
router_data.raw_connector_response = payment_authorize_response
446454
.raw_connector_response

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,18 @@ impl Feature<api::SetupMandate, types::SetupMandateRequestData> for types::Setup
371371
);
372372
}
373373
}
374-
let router_data_response =
375-
ucs_data.router_data_response.map(|(response, status)| {
376-
router_data.status = status;
377-
response
378-
});
374+
let router_data_response = match &ucs_data.router_data_response {
375+
Ok((response, status)) => {
376+
router_data.status = status.clone();
377+
Ok(response.clone())
378+
}
379+
Err(error_response) => {
380+
if let Some(attempt_status) = error_response.attempt_status {
381+
router_data.status = attempt_status;
382+
}
383+
Err(error_response.clone())
384+
}
385+
};
379386
router_data.response = router_data_response;
380387
router_data.connector_http_status_code = Some(ucs_data.status_code);
381388

crates/router/src/core/payments/gateway/authorize_gateway.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,18 @@ where
127127
)
128128
.attach_printable("Failed to deserialize UCS response")?;
129129

130-
let router_data_response =
131-
ucs_data.router_data_response.map(|(response, status)| {
132-
router_data.status = status;
133-
response
134-
});
130+
let router_data_response = match &ucs_data.router_data_response {
131+
Ok((response, status)) => {
132+
router_data.status = status.clone();
133+
Ok(response.clone())
134+
}
135+
Err(error_response) => {
136+
if let Some(attempt_status) = error_response.attempt_status {
137+
router_data.status = attempt_status;
138+
}
139+
Err(error_response.clone())
140+
}
141+
};
135142
router_data.response = router_data_response;
136143

137144
router_data.amount_captured = payment_authorize_response.captured_amount;

crates/router/src/core/payments/gateway/setup_mandate.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,18 @@ where
123123
)
124124
.attach_printable("Failed to deserialize UCS response")?;
125125

126-
let router_data_response =
127-
ucs_data.router_data_response.map(|(response, status)| {
128-
router_data.status = status;
129-
response
130-
});
126+
let router_data_response = match &ucs_data.router_data_response {
127+
Ok((response, status)) => {
128+
router_data.status = status.clone();
129+
Ok(response.clone())
130+
}
131+
Err(error_response) => {
132+
if let Some(attempt_status) = error_response.attempt_status {
133+
router_data.status = attempt_status;
134+
}
135+
Err(error_response.clone())
136+
}
137+
};
131138
router_data.response = router_data_response;
132139
router_data.connector_http_status_code = Some(ucs_data.status_code);
133140

crates/router/src/core/unified_connector_service.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,39 @@ pub fn build_unified_connector_service_payment_method(
896896
}),
897897
})),
898898
}),
899+
hyperswitch_domain_models::payment_method_data::WalletData::GooglePayThirdPartySdk(
900+
google_pay_sdk_data,
901+
) => {
902+
Ok(payments_grpc::PaymentMethod {
903+
payment_method: Some(PaymentMethod::GooglePayThirdPartySdk(
904+
payments_grpc::GooglePayThirdPartySdkWallet {
905+
token: google_pay_sdk_data.token.map(|t| t.expose().into()),
906+
}
907+
)),
908+
})
909+
},
910+
hyperswitch_domain_models::payment_method_data::WalletData::ApplePayThirdPartySdk(
911+
apple_pay_sdk_data,
912+
) => {
913+
Ok(payments_grpc::PaymentMethod {
914+
payment_method: Some(PaymentMethod::ApplePayThirdPartySdk(
915+
payments_grpc::ApplePayThirdPartySdkWallet {
916+
token: apple_pay_sdk_data.token.map(|t| t.expose().into()),
917+
}
918+
)),
919+
})
920+
},
921+
hyperswitch_domain_models::payment_method_data::WalletData::PaypalSdk(
922+
paypal_sdk_data,
923+
) => {
924+
Ok(payments_grpc::PaymentMethod {
925+
payment_method: Some(PaymentMethod::PaypalSdk(
926+
payments_grpc::PaypalSdkWallet {
927+
token: Some(paypal_sdk_data.token.into()),
928+
}
929+
)),
930+
})
931+
},
899932
_ => Err(UnifiedConnectorServiceError::NotImplemented(format!(
900933
"Unimplemented payment method subtype: {payment_method_type:?}"
901934
))

0 commit comments

Comments
 (0)