@@ -57,9 +57,10 @@ use crate::{
57
57
SubmitEvidenceRouterData ,
58
58
} ,
59
59
utils:: {
60
- self , is_manual_capture, missing_field_err, AddressDetailsData , BrowserInformationData ,
61
- CardData , ForeignTryFrom , NetworkTokenData as UtilsNetworkTokenData ,
62
- PaymentsAuthorizeRequestData , PhoneDetailsData , RouterData as OtherRouterData ,
60
+ self , is_manual_capture, missing_field_err, AddressDetailsData , ApplePayDecrypt ,
61
+ BrowserInformationData , CardData , ForeignTryFrom ,
62
+ NetworkTokenData as UtilsNetworkTokenData , PaymentsAuthorizeRequestData , PhoneDetailsData ,
63
+ RouterData as OtherRouterData ,
63
64
} ,
64
65
} ;
65
66
@@ -309,7 +310,8 @@ struct AdyenSplitData {
309
310
struct AdyenMpiData {
310
311
directory_response : String ,
311
312
authentication_response : String ,
312
- token_authentication_verification_value : Secret < String > ,
313
+ cavv : Option < Secret < String > > ,
314
+ token_authentication_verification_value : Option < Secret < String > > ,
313
315
eci : Option < String > ,
314
316
}
315
317
@@ -675,6 +677,7 @@ pub enum AdyenPaymentMethod<'a> {
675
677
#[ serde( rename = "alipay_hk" ) ]
676
678
AliPayHk ,
677
679
ApplePay ( Box < AdyenApplePay > ) ,
680
+ ApplePayDecrypt ( Box < AdyenApplePayDecryptData > ) ,
678
681
Atome ,
679
682
#[ serde( rename = "scheme" ) ]
680
683
BancontactCard ( Box < AdyenCard > ) ,
@@ -1253,6 +1256,18 @@ pub struct AdyenPazeData {
1253
1256
network_payment_reference : Option < Secret < String > > ,
1254
1257
}
1255
1258
1259
+ #[ serde_with:: skip_serializing_none]
1260
+ #[ derive( Debug , Clone , Serialize , Deserialize ) ]
1261
+ #[ serde( rename_all = "camelCase" ) ]
1262
+ pub struct AdyenApplePayDecryptData {
1263
+ number : Secret < String > ,
1264
+ expiry_month : Secret < String > ,
1265
+ expiry_year : Secret < String > ,
1266
+ brand : String ,
1267
+ #[ serde( rename = "type" ) ]
1268
+ payment_type : PaymentType ,
1269
+ }
1270
+
1256
1271
#[ derive( Debug , Clone , Serialize , Deserialize ) ]
1257
1272
#[ serde( rename_all = "lowercase" ) ]
1258
1273
pub enum CardBrand {
@@ -2194,11 +2209,27 @@ impl TryFrom<(&WalletData, &PaymentsAuthorizeRouterData)> for AdyenPaymentMethod
2194
2209
Ok ( AdyenPaymentMethod :: Gpay ( Box :: new ( gpay_data) ) )
2195
2210
}
2196
2211
WalletData :: ApplePay ( data) => {
2197
- let apple_pay_data = AdyenApplePay {
2198
- apple_pay_token : Secret :: new ( data. payment_data . to_string ( ) ) ,
2199
- } ;
2200
-
2201
- Ok ( AdyenPaymentMethod :: ApplePay ( Box :: new ( apple_pay_data) ) )
2212
+ if let Some ( PaymentMethodToken :: ApplePayDecrypt ( apple_pay_decrypte) ) =
2213
+ item. payment_method_token . clone ( )
2214
+ {
2215
+ let expiry_year_4_digit = apple_pay_decrypte. get_four_digit_expiry_year ( ) ?;
2216
+ let exp_month = apple_pay_decrypte. get_expiry_month ( ) ?;
2217
+ let apple_pay_decrypted_data = AdyenApplePayDecryptData {
2218
+ number : apple_pay_decrypte. application_primary_account_number ,
2219
+ expiry_month : exp_month,
2220
+ expiry_year : expiry_year_4_digit,
2221
+ brand : "applepay" . to_string ( ) ,
2222
+ payment_type : PaymentType :: Scheme ,
2223
+ } ;
2224
+ Ok ( AdyenPaymentMethod :: ApplePayDecrypt ( Box :: new (
2225
+ apple_pay_decrypted_data,
2226
+ ) ) )
2227
+ } else {
2228
+ let apple_pay_data = AdyenApplePay {
2229
+ apple_pay_token : Secret :: new ( data. payment_data . to_string ( ) ) ,
2230
+ } ;
2231
+ Ok ( AdyenPaymentMethod :: ApplePay ( Box :: new ( apple_pay_data) ) )
2232
+ }
2202
2233
}
2203
2234
WalletData :: PaypalRedirect ( _) => Ok ( AdyenPaymentMethod :: AdyenPaypal ) ,
2204
2235
WalletData :: AliPayRedirect ( _) => Ok ( AdyenPaymentMethod :: AliPay ) ,
@@ -3428,15 +3459,23 @@ impl TryFrom<(&AdyenRouterData<&PaymentsAuthorizeRouterData>, &WalletData)>
3428
3459
let shopper_email = get_shopper_email ( item. router_data , store_payment_method. is_some ( ) ) ?;
3429
3460
let billing_address =
3430
3461
get_address_info ( item. router_data . get_optional_billing ( ) ) . and_then ( Result :: ok) ;
3431
- let mpi_data = if let WalletData :: Paze ( _) = wallet_data {
3462
+ let mpi_data = if matches ! ( wallet_data , WalletData :: Paze ( _) | WalletData :: ApplePay ( _ ) ) {
3432
3463
match item. router_data . payment_method_token . clone ( ) {
3433
- Some ( PaymentMethodToken :: PazeDecrypt ( paze_decrypted_data ) ) => Some ( AdyenMpiData {
3464
+ Some ( PaymentMethodToken :: PazeDecrypt ( paze_data ) ) => Some ( AdyenMpiData {
3434
3465
directory_response : "Y" . to_string ( ) ,
3435
3466
authentication_response : "Y" . to_string ( ) ,
3436
- token_authentication_verification_value : paze_decrypted_data
3437
- . token
3438
- . payment_account_reference ,
3439
- eci : paze_decrypted_data. eci ,
3467
+ cavv : None ,
3468
+ token_authentication_verification_value : Some (
3469
+ paze_data. token . payment_account_reference ,
3470
+ ) ,
3471
+ eci : paze_data. eci ,
3472
+ } ) ,
3473
+ Some ( PaymentMethodToken :: ApplePayDecrypt ( apple_data) ) => Some ( AdyenMpiData {
3474
+ directory_response : "Y" . to_string ( ) ,
3475
+ authentication_response : "Y" . to_string ( ) ,
3476
+ cavv : Some ( apple_data. payment_data . online_payment_cryptogram ) ,
3477
+ token_authentication_verification_value : None ,
3478
+ eci : apple_data. payment_data . eci_indicator ,
3440
3479
} ) ,
3441
3480
_ => None ,
3442
3481
}
@@ -5854,10 +5893,10 @@ impl
5854
5893
let mpi_data = AdyenMpiData {
5855
5894
directory_response : "Y" . to_string ( ) ,
5856
5895
authentication_response : "Y" . to_string ( ) ,
5857
- token_authentication_verification_value : token_data
5858
- . get_cryptogram ( )
5859
- . clone ( )
5860
- . unwrap_or_default ( ) ,
5896
+ cavv : None ,
5897
+ token_authentication_verification_value : Some (
5898
+ token_data . get_cryptogram ( ) . clone ( ) . unwrap_or_default ( ) ,
5899
+ ) ,
5861
5900
eci : Some ( "02" . to_string ( ) ) ,
5862
5901
} ;
5863
5902
let ( store, splits) = match item. router_data . request . split_payments . as_ref ( ) {
0 commit comments