@@ -31,6 +31,38 @@ pub enum TransactionType {
31
31
#[ serde( rename = "authCaptureContinueTransaction" ) ]
32
32
ContinueCapture ,
33
33
}
34
+
35
+ #[ derive( Debug , Serialize ) ]
36
+ pub struct AuthorizedotnetRouterData < T > {
37
+ pub amount : f64 ,
38
+ pub router_data : T ,
39
+ }
40
+
41
+ impl < T >
42
+ TryFrom < (
43
+ & types:: api:: CurrencyUnit ,
44
+ types:: storage:: enums:: Currency ,
45
+ i64 ,
46
+ T ,
47
+ ) > for AuthorizedotnetRouterData < T >
48
+ {
49
+ type Error = error_stack:: Report < errors:: ConnectorError > ;
50
+ fn try_from (
51
+ ( currency_unit, currency, amount, item) : (
52
+ & types:: api:: CurrencyUnit ,
53
+ types:: storage:: enums:: Currency ,
54
+ i64 ,
55
+ T ,
56
+ ) ,
57
+ ) -> Result < Self , Self :: Error > {
58
+ let amount = utils:: get_amount_as_f64 ( currency_unit, amount, currency) ?;
59
+ Ok ( Self {
60
+ amount,
61
+ router_data : item,
62
+ } )
63
+ }
64
+ }
65
+
34
66
#[ derive( Debug , Serialize ) ]
35
67
#[ serde( rename_all = "camelCase" ) ]
36
68
pub struct AuthorizedotnetAuthType {
@@ -99,7 +131,7 @@ pub enum WalletMethod {
99
131
}
100
132
101
133
fn get_pm_and_subsequent_auth_detail (
102
- item : & types:: PaymentsAuthorizeRouterData ,
134
+ item : & AuthorizedotnetRouterData < & types:: PaymentsAuthorizeRouterData > ,
103
135
) -> Result <
104
136
(
105
137
PaymentDetails ,
@@ -109,6 +141,7 @@ fn get_pm_and_subsequent_auth_detail(
109
141
error_stack:: Report < errors:: ConnectorError > ,
110
142
> {
111
143
match item
144
+ . router_data
112
145
. request
113
146
. mandate_id
114
147
. to_owned ( )
@@ -124,7 +157,7 @@ fn get_pm_and_subsequent_auth_detail(
124
157
original_network_trans_id,
125
158
reason : Reason :: Resubmission ,
126
159
} ) ;
127
- match item. request . payment_method_data {
160
+ match item. router_data . request . payment_method_data {
128
161
api:: PaymentMethodData :: Card ( ref ccard) => {
129
162
let payment_details = PaymentDetails :: CreditCard ( CreditCardDetails {
130
163
card_number : ( * ccard. card_number ) . clone ( ) ,
@@ -134,12 +167,12 @@ fn get_pm_and_subsequent_auth_detail(
134
167
Ok ( ( payment_details, processing_options, subseuent_auth_info) )
135
168
}
136
169
_ => Err ( errors:: ConnectorError :: NotSupported {
137
- message : format ! ( "{:?}" , item. request. payment_method_data) ,
170
+ message : format ! ( "{:?}" , item. router_data . request. payment_method_data) ,
138
171
connector : "AuthorizeDotNet" ,
139
172
} ) ?,
140
173
}
141
174
}
142
- _ => match item. request . payment_method_data {
175
+ _ => match item. router_data . request . payment_method_data {
143
176
api:: PaymentMethodData :: Card ( ref ccard) => {
144
177
Ok ( (
145
178
PaymentDetails :: CreditCard ( CreditCardDetails {
@@ -155,12 +188,15 @@ fn get_pm_and_subsequent_auth_detail(
155
188
) )
156
189
}
157
190
api:: PaymentMethodData :: Wallet ( ref wallet_data) => Ok ( (
158
- get_wallet_data ( wallet_data, & item. request . complete_authorize_url ) ?,
191
+ get_wallet_data (
192
+ wallet_data,
193
+ & item. router_data . request . complete_authorize_url ,
194
+ ) ?,
159
195
None ,
160
196
None ,
161
197
) ) ,
162
198
_ => Err ( errors:: ConnectorError :: NotSupported {
163
- message : format ! ( "{:?}" , item. request. payment_method_data) ,
199
+ message : format ! ( "{:?}" , item. router_data . request. payment_method_data) ,
164
200
connector : "AuthorizeDotNet" ,
165
201
} ) ?,
166
202
} ,
@@ -263,26 +299,34 @@ impl From<enums::CaptureMethod> for AuthorizationType {
263
299
}
264
300
}
265
301
266
- impl TryFrom < & types:: PaymentsAuthorizeRouterData > for CreateTransactionRequest {
302
+ impl TryFrom < & AuthorizedotnetRouterData < & types:: PaymentsAuthorizeRouterData > >
303
+ for CreateTransactionRequest
304
+ {
267
305
type Error = error_stack:: Report < errors:: ConnectorError > ;
268
- fn try_from ( item : & types:: PaymentsAuthorizeRouterData ) -> Result < Self , Self :: Error > {
306
+ fn try_from (
307
+ item : & AuthorizedotnetRouterData < & types:: PaymentsAuthorizeRouterData > ,
308
+ ) -> Result < Self , Self :: Error > {
269
309
let ( payment_details, processing_options, subsequent_auth_information) =
270
310
get_pm_and_subsequent_auth_detail ( item) ?;
271
311
let authorization_indicator_type =
272
- item. request . capture_method . map ( |c| AuthorizationIndicator {
273
- authorization_indicator : c. into ( ) ,
274
- } ) ;
312
+ item. router_data
313
+ . request
314
+ . capture_method
315
+ . map ( |c| AuthorizationIndicator {
316
+ authorization_indicator : c. into ( ) ,
317
+ } ) ;
275
318
let transaction_request = TransactionRequest {
276
- transaction_type : TransactionType :: from ( item. request . capture_method ) ,
277
- amount : utils :: to_currency_base_unit_asf64 ( item. request . amount , item . request . currency ) ? ,
319
+ transaction_type : TransactionType :: from ( item. router_data . request . capture_method ) ,
320
+ amount : item. amount ,
278
321
payment : payment_details,
279
- currency_code : item. request . currency . to_string ( ) ,
322
+ currency_code : item. router_data . request . currency . to_string ( ) ,
280
323
processing_options,
281
324
subsequent_auth_information,
282
325
authorization_indicator_type,
283
326
} ;
284
327
285
- let merchant_authentication = AuthorizedotnetAuthType :: try_from ( & item. connector_auth_type ) ?;
328
+ let merchant_authentication =
329
+ AuthorizedotnetAuthType :: try_from ( & item. router_data . connector_auth_type ) ?;
286
330
287
331
Ok ( Self {
288
332
create_transaction_request : AuthorizedotnetPaymentsRequest {
@@ -313,19 +357,25 @@ impl TryFrom<&types::PaymentsCancelRouterData> for CancelOrCaptureTransactionReq
313
357
}
314
358
}
315
359
316
- impl TryFrom < & types:: PaymentsCaptureRouterData > for CancelOrCaptureTransactionRequest {
360
+ impl TryFrom < & AuthorizedotnetRouterData < & types:: PaymentsCaptureRouterData > >
361
+ for CancelOrCaptureTransactionRequest
362
+ {
317
363
type Error = error_stack:: Report < errors:: ConnectorError > ;
318
- fn try_from ( item : & types:: PaymentsCaptureRouterData ) -> Result < Self , Self :: Error > {
364
+ fn try_from (
365
+ item : & AuthorizedotnetRouterData < & types:: PaymentsCaptureRouterData > ,
366
+ ) -> Result < Self , Self :: Error > {
319
367
let transaction_request = TransactionVoidOrCaptureRequest {
320
- amount : Some ( utils:: to_currency_base_unit_asf64 (
321
- item. request . amount_to_capture ,
322
- item. request . currency ,
323
- ) ?) ,
368
+ amount : Some ( item. amount ) ,
324
369
transaction_type : TransactionType :: Capture ,
325
- ref_trans_id : item. request . connector_transaction_id . to_string ( ) ,
370
+ ref_trans_id : item
371
+ . router_data
372
+ . request
373
+ . connector_transaction_id
374
+ . to_string ( ) ,
326
375
} ;
327
376
328
- let merchant_authentication = AuthorizedotnetAuthType :: try_from ( & item. connector_auth_type ) ?;
377
+ let merchant_authentication =
378
+ AuthorizedotnetAuthType :: try_from ( & item. router_data . connector_auth_type ) ?;
329
379
330
380
Ok ( Self {
331
381
create_transaction_request : AuthorizedotnetPaymentCancelOrCaptureRequest {
@@ -648,10 +698,13 @@ pub struct CreateRefundRequest {
648
698
create_transaction_request : AuthorizedotnetRefundRequest ,
649
699
}
650
700
651
- impl < F > TryFrom < & types:: RefundsRouterData < F > > for CreateRefundRequest {
701
+ impl < F > TryFrom < & AuthorizedotnetRouterData < & types:: RefundsRouterData < F > > > for CreateRefundRequest {
652
702
type Error = error_stack:: Report < errors:: ConnectorError > ;
653
- fn try_from ( item : & types:: RefundsRouterData < F > ) -> Result < Self , Self :: Error > {
703
+ fn try_from (
704
+ item : & AuthorizedotnetRouterData < & types:: RefundsRouterData < F > > ,
705
+ ) -> Result < Self , Self :: Error > {
654
706
let payment_details = item
707
+ . router_data
655
708
. request
656
709
. connector_metadata
657
710
. as_ref ( )
@@ -661,21 +714,19 @@ impl<F> TryFrom<&types::RefundsRouterData<F>> for CreateRefundRequest {
661
714
} ) ?
662
715
. clone ( ) ;
663
716
664
- let merchant_authentication = AuthorizedotnetAuthType :: try_from ( & item. connector_auth_type ) ?;
717
+ let merchant_authentication =
718
+ AuthorizedotnetAuthType :: try_from ( & item. router_data . connector_auth_type ) ?;
665
719
666
720
let transaction_request = RefundTransactionRequest {
667
721
transaction_type : TransactionType :: Refund ,
668
- amount : utils:: to_currency_base_unit_asf64 (
669
- item. request . refund_amount ,
670
- item. request . currency ,
671
- ) ?,
722
+ amount : item. amount ,
672
723
payment : payment_details
673
724
. parse_value ( "PaymentDetails" )
674
725
. change_context ( errors:: ConnectorError :: MissingRequiredField {
675
726
field_name : "payment_details" ,
676
727
} ) ?,
677
- currency_code : item. request . currency . to_string ( ) ,
678
- reference_transaction_id : item. request . connector_transaction_id . clone ( ) ,
728
+ currency_code : item. router_data . request . currency . to_string ( ) ,
729
+ reference_transaction_id : item. router_data . request . connector_transaction_id . clone ( ) ,
679
730
} ;
680
731
681
732
Ok ( Self {
@@ -750,12 +801,17 @@ pub struct AuthorizedotnetCreateSyncRequest {
750
801
get_transaction_details_request : TransactionDetails ,
751
802
}
752
803
753
- impl < F > TryFrom < & types:: RefundsRouterData < F > > for AuthorizedotnetCreateSyncRequest {
804
+ impl < F > TryFrom < & AuthorizedotnetRouterData < & types:: RefundsRouterData < F > > >
805
+ for AuthorizedotnetCreateSyncRequest
806
+ {
754
807
type Error = error_stack:: Report < errors:: ConnectorError > ;
755
808
756
- fn try_from ( item : & types:: RefundsRouterData < F > ) -> Result < Self , Self :: Error > {
757
- let transaction_id = item. request . get_connector_refund_id ( ) ?;
758
- let merchant_authentication = AuthorizedotnetAuthType :: try_from ( & item. connector_auth_type ) ?;
809
+ fn try_from (
810
+ item : & AuthorizedotnetRouterData < & types:: RefundsRouterData < F > > ,
811
+ ) -> Result < Self , Self :: Error > {
812
+ let transaction_id = item. router_data . request . get_connector_refund_id ( ) ?;
813
+ let merchant_authentication =
814
+ AuthorizedotnetAuthType :: try_from ( & item. router_data . connector_auth_type ) ?;
759
815
760
816
let payload = Self {
761
817
get_transaction_details_request : TransactionDetails {
@@ -1131,10 +1187,15 @@ pub struct PaypalQueryParams {
1131
1187
payer_id : String ,
1132
1188
}
1133
1189
1134
- impl TryFrom < & types:: PaymentsCompleteAuthorizeRouterData > for PaypalConfirmRequest {
1190
+ impl TryFrom < & AuthorizedotnetRouterData < & types:: PaymentsCompleteAuthorizeRouterData > >
1191
+ for PaypalConfirmRequest
1192
+ {
1135
1193
type Error = error_stack:: Report < errors:: ConnectorError > ;
1136
- fn try_from ( item : & types:: PaymentsCompleteAuthorizeRouterData ) -> Result < Self , Self :: Error > {
1194
+ fn try_from (
1195
+ item : & AuthorizedotnetRouterData < & types:: PaymentsCompleteAuthorizeRouterData > ,
1196
+ ) -> Result < Self , Self :: Error > {
1137
1197
let params = item
1198
+ . router_data
1138
1199
. request
1139
1200
. redirect_response
1140
1201
. as_ref ( )
@@ -1146,7 +1207,7 @@ impl TryFrom<&types::PaymentsCompleteAuthorizeRouterData> for PaypalConfirmReque
1146
1207
. change_context ( errors:: ConnectorError :: ResponseDeserializationFailed ) ?
1147
1208
. payer_id ,
1148
1209
) ;
1149
- let transaction_type = match item. request . capture_method {
1210
+ let transaction_type = match item. router_data . request . capture_method {
1150
1211
Some ( enums:: CaptureMethod :: Manual ) => TransactionType :: ContinueAuthorization ,
1151
1212
_ => TransactionType :: ContinueCapture ,
1152
1213
} ;
@@ -1155,10 +1216,11 @@ impl TryFrom<&types::PaymentsCompleteAuthorizeRouterData> for PaypalConfirmReque
1155
1216
payment : PaypalPaymentConfirm {
1156
1217
pay_pal : Paypal { payer_id } ,
1157
1218
} ,
1158
- ref_trans_id : item. request . connector_transaction_id . clone ( ) ,
1219
+ ref_trans_id : item. router_data . request . connector_transaction_id . clone ( ) ,
1159
1220
} ;
1160
1221
1161
- let merchant_authentication = AuthorizedotnetAuthType :: try_from ( & item. connector_auth_type ) ?;
1222
+ let merchant_authentication =
1223
+ AuthorizedotnetAuthType :: try_from ( & item. router_data . connector_auth_type ) ?;
1162
1224
1163
1225
Ok ( Self {
1164
1226
create_transaction_request : PaypalConfirmTransactionRequest {
0 commit comments