1
- use api_models:: {
2
- enums:: DisputeStage , payments:: MandateReferenceId , webhooks:: IncomingWebhookEvent ,
3
- } ;
1
+ use api_models:: { enums, payments, webhooks} ;
4
2
use cards:: CardNumber ;
5
3
use masking:: PeekInterface ;
6
4
use reqwest:: Url ;
@@ -280,6 +278,17 @@ pub enum AdyenPaymentMethod<'a> {
280
278
Trustly ( Box < BankRedirectionPMData > ) ,
281
279
Walley ( Box < WalleyData > ) ,
282
280
WeChatPayWeb ( Box < WeChatPayWebData > ) ,
281
+ AchDirectDebit ( Box < AchDirectDebitData > ) ,
282
+ }
283
+
284
+ #[ derive( Debug , Clone , Serialize ) ]
285
+ #[ serde( rename_all = "camelCase" ) ]
286
+ pub struct AchDirectDebitData {
287
+ #[ serde( rename = "type" ) ]
288
+ payment_type : PaymentType ,
289
+ bank_account_number : Secret < String > ,
290
+ bank_location_id : Secret < String > ,
291
+ owner_name : Secret < String > ,
283
292
}
284
293
285
294
#[ derive( Debug , Clone , Serialize ) ]
@@ -652,6 +661,8 @@ pub enum PaymentType {
652
661
Walley ,
653
662
#[ serde( rename = "wechatpayWeb" ) ]
654
663
WeChatPayWeb ,
664
+ #[ serde( rename = "ach" ) ]
665
+ AchDirectDebit ,
655
666
}
656
667
657
668
pub struct AdyenTestBankNames < ' a > ( & ' a str ) ;
@@ -755,6 +766,9 @@ impl<'a> TryFrom<&types::PaymentsAuthorizeRouterData> for AdyenPaymentRequest<'a
755
766
api_models:: payments:: PaymentMethodData :: BankRedirect ( ref bank_redirect) => {
756
767
AdyenPaymentRequest :: try_from ( ( item, bank_redirect) )
757
768
}
769
+ api_models:: payments:: PaymentMethodData :: BankDebit ( ref bank_debit) => {
770
+ AdyenPaymentRequest :: try_from ( ( item, bank_debit) )
771
+ }
758
772
_ => Err ( errors:: ConnectorError :: NotSupported {
759
773
message : format ! ( "{:?}" , item. request. payment_method_type) ,
760
774
connector : "Adyen" ,
@@ -905,6 +919,35 @@ fn get_country_code(item: &types::PaymentsAuthorizeRouterData) -> Option<api_enu
905
919
. and_then ( |billing| billing. address . as_ref ( ) . and_then ( |address| address. country ) )
906
920
}
907
921
922
+ impl < ' a > TryFrom < & api_models:: payments:: BankDebitData > for AdyenPaymentMethod < ' a > {
923
+ type Error = Error ;
924
+ fn try_from (
925
+ bank_debit_data : & api_models:: payments:: BankDebitData ,
926
+ ) -> Result < Self , Self :: Error > {
927
+ match bank_debit_data {
928
+ payments:: BankDebitData :: AchBankDebit {
929
+ account_number,
930
+ routing_number,
931
+ billing_details : _,
932
+ bank_account_holder_name,
933
+ } => Ok ( AdyenPaymentMethod :: AchDirectDebit ( Box :: new (
934
+ AchDirectDebitData {
935
+ payment_type : PaymentType :: AchDirectDebit ,
936
+ bank_account_number : account_number. clone ( ) ,
937
+ bank_location_id : routing_number. clone ( ) ,
938
+ owner_name : bank_account_holder_name. clone ( ) . ok_or (
939
+ errors:: ConnectorError :: MissingRequiredField {
940
+ field_name : "bank_account_holder_name" ,
941
+ } ,
942
+ ) ?,
943
+ } ,
944
+ ) ) ) ,
945
+
946
+ _ => Err ( errors:: ConnectorError :: NotImplemented ( "Payment method" . to_string ( ) ) . into ( ) ) ,
947
+ }
948
+ }
949
+ }
950
+
908
951
impl < ' a > TryFrom < & api:: Card > for AdyenPaymentMethod < ' a > {
909
952
type Error = Error ;
910
953
fn try_from ( card : & api:: Card ) -> Result < Self , Self :: Error > {
@@ -1107,12 +1150,18 @@ impl<'a> TryFrom<&api_models::payments::BankRedirectData> for AdyenPaymentMethod
1107
1150
}
1108
1151
}
1109
1152
1110
- impl < ' a > TryFrom < ( & types:: PaymentsAuthorizeRouterData , MandateReferenceId ) >
1111
- for AdyenPaymentRequest < ' a >
1153
+ impl < ' a >
1154
+ TryFrom < (
1155
+ & types:: PaymentsAuthorizeRouterData ,
1156
+ payments:: MandateReferenceId ,
1157
+ ) > for AdyenPaymentRequest < ' a >
1112
1158
{
1113
1159
type Error = Error ;
1114
1160
fn try_from (
1115
- value : ( & types:: PaymentsAuthorizeRouterData , MandateReferenceId ) ,
1161
+ value : (
1162
+ & types:: PaymentsAuthorizeRouterData ,
1163
+ payments:: MandateReferenceId ,
1164
+ ) ,
1116
1165
) -> Result < Self , Self :: Error > {
1117
1166
let ( item, mandate_ref_id) = value;
1118
1167
let amount = get_amount_data ( item) ;
@@ -1124,7 +1173,7 @@ impl<'a> TryFrom<(&types::PaymentsAuthorizeRouterData, MandateReferenceId)>
1124
1173
let additional_data = get_additional_data ( item) ;
1125
1174
let return_url = item. request . get_return_url ( ) ?;
1126
1175
let payment_method = match mandate_ref_id {
1127
- MandateReferenceId :: ConnectorMandateId ( connector_mandate_ids) => {
1176
+ payments :: MandateReferenceId :: ConnectorMandateId ( connector_mandate_ids) => {
1128
1177
let adyen_mandate = AdyenMandate {
1129
1178
payment_type : PaymentType :: Scheme ,
1130
1179
stored_payment_method_id : connector_mandate_ids. get_connector_mandate_id ( ) ?,
@@ -1133,7 +1182,7 @@ impl<'a> TryFrom<(&types::PaymentsAuthorizeRouterData, MandateReferenceId)>
1133
1182
adyen_mandate,
1134
1183
) ) )
1135
1184
}
1136
- MandateReferenceId :: NetworkMandateId ( network_mandate_id) => {
1185
+ payments :: MandateReferenceId :: NetworkMandateId ( network_mandate_id) => {
1137
1186
match item. request . payment_method_data {
1138
1187
api:: PaymentMethodData :: Card ( ref card) => {
1139
1188
let card_issuer = card. get_card_issuer ( ) ?;
@@ -1220,6 +1269,55 @@ impl<'a> TryFrom<(&types::PaymentsAuthorizeRouterData, &api::Card)> for AdyenPay
1220
1269
}
1221
1270
}
1222
1271
1272
+ impl < ' a >
1273
+ TryFrom < (
1274
+ & types:: PaymentsAuthorizeRouterData ,
1275
+ & api_models:: payments:: BankDebitData ,
1276
+ ) > for AdyenPaymentRequest < ' a >
1277
+ {
1278
+ type Error = Error ;
1279
+
1280
+ fn try_from (
1281
+ value : (
1282
+ & types:: PaymentsAuthorizeRouterData ,
1283
+ & api_models:: payments:: BankDebitData ,
1284
+ ) ,
1285
+ ) -> Result < Self , Self :: Error > {
1286
+ let ( item, bank_debit_data) = value;
1287
+ let amount = get_amount_data ( item) ;
1288
+ let auth_type = AdyenAuthType :: try_from ( & item. connector_auth_type ) ?;
1289
+ let shopper_interaction = AdyenShopperInteraction :: from ( item) ;
1290
+ let recurring_processing_model = get_recurring_processing_model ( item) ?. 0 ;
1291
+ let browser_info = get_browser_info ( item) ;
1292
+ let additional_data = get_additional_data ( item) ;
1293
+ let return_url = item. request . get_return_url ( ) ?;
1294
+ let payment_method = AdyenPaymentMethod :: try_from ( bank_debit_data) ?;
1295
+ let country_code = get_country_code ( item) ;
1296
+ let request = AdyenPaymentRequest {
1297
+ amount,
1298
+ merchant_account : auth_type. merchant_account ,
1299
+ payment_method,
1300
+ reference : item. payment_id . to_string ( ) ,
1301
+ return_url,
1302
+ browser_info,
1303
+ shopper_interaction,
1304
+ recurring_processing_model,
1305
+ additional_data,
1306
+ shopper_name : None ,
1307
+ shopper_locale : None ,
1308
+ shopper_email : item. request . email . clone ( ) ,
1309
+ telephone_number : None ,
1310
+ billing_address : None ,
1311
+ delivery_address : None ,
1312
+ country_code,
1313
+ line_items : None ,
1314
+ shopper_reference : None ,
1315
+ store_payment_method : None ,
1316
+ } ;
1317
+ Ok ( request)
1318
+ }
1319
+ }
1320
+
1223
1321
impl < ' a >
1224
1322
TryFrom < (
1225
1323
& types:: PaymentsAuthorizeRouterData ,
@@ -1790,7 +1888,7 @@ pub fn is_chargeback_event(event_code: &WebhookEventCode) -> bool {
1790
1888
)
1791
1889
}
1792
1890
1793
- impl ForeignFrom < ( WebhookEventCode , Option < DisputeStatus > ) > for IncomingWebhookEvent {
1891
+ impl ForeignFrom < ( WebhookEventCode , Option < DisputeStatus > ) > for webhooks :: IncomingWebhookEvent {
1794
1892
fn foreign_from ( ( code, status) : ( WebhookEventCode , Option < DisputeStatus > ) ) -> Self {
1795
1893
match ( code, status) {
1796
1894
( WebhookEventCode :: Authorisation , _) => Self :: PaymentIntentSuccess ,
@@ -1816,7 +1914,7 @@ impl ForeignFrom<(WebhookEventCode, Option<DisputeStatus>)> for IncomingWebhookE
1816
1914
}
1817
1915
}
1818
1916
1819
- impl From < WebhookEventCode > for DisputeStage {
1917
+ impl From < WebhookEventCode > for enums :: DisputeStage {
1820
1918
fn from ( code : WebhookEventCode ) -> Self {
1821
1919
match code {
1822
1920
WebhookEventCode :: NotificationOfChargeback => Self :: PreDispute ,
0 commit comments