File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
crates/router/src/core/payment_methods Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -1316,6 +1316,47 @@ pub async fn list_payment_methods(
1316
1316
. await ?;
1317
1317
}
1318
1318
1319
+ // Filter out applepay payment method from mca if customer has already saved it
1320
+ response
1321
+ . iter ( )
1322
+ . position ( |pm| {
1323
+ pm. payment_method == enums:: PaymentMethod :: Wallet
1324
+ && pm. payment_method_type == enums:: PaymentMethodType :: ApplePay
1325
+ } )
1326
+ . as_ref ( )
1327
+ . zip ( customer. as_ref ( ) )
1328
+ . async_map ( |( index, customer) | async {
1329
+ match db
1330
+ . find_payment_method_by_customer_id_merchant_id_list (
1331
+ & customer. customer_id ,
1332
+ & merchant_account. merchant_id ,
1333
+ None ,
1334
+ )
1335
+ . await
1336
+ {
1337
+ Ok ( customer_payment_methods) => {
1338
+ if customer_payment_methods. iter ( ) . any ( |pm| {
1339
+ pm. payment_method == enums:: PaymentMethod :: Wallet
1340
+ && pm. payment_method_type == Some ( enums:: PaymentMethodType :: ApplePay )
1341
+ } ) {
1342
+ response. remove ( * index) ;
1343
+ }
1344
+ Ok ( ( ) )
1345
+ }
1346
+ Err ( error) => {
1347
+ if error. current_context ( ) . is_db_not_found ( ) {
1348
+ Ok ( ( ) )
1349
+ } else {
1350
+ Err ( error)
1351
+ . change_context ( errors:: ApiErrorResponse :: InternalServerError )
1352
+ . attach_printable ( "failed to find payment methods for a customer" )
1353
+ }
1354
+ }
1355
+ }
1356
+ } )
1357
+ . await
1358
+ . transpose ( ) ?;
1359
+
1319
1360
let mut pmt_to_auth_connector = HashMap :: new ( ) ;
1320
1361
1321
1362
if let Some ( ( payment_attempt, payment_intent) ) =
You can’t perform that action at this time.
0 commit comments