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