@@ -53,6 +53,38 @@ impl TryFrom<&types::PaymentsInitRouterData> for AirwallexIntentRequest {
53
53
}
54
54
}
55
55
56
+ #[ derive( Debug , Serialize ) ]
57
+ pub struct AirwallexRouterData < T > {
58
+ pub amount : String ,
59
+ pub router_data : T ,
60
+ }
61
+
62
+ impl < T >
63
+ TryFrom < (
64
+ & types:: api:: CurrencyUnit ,
65
+ types:: storage:: enums:: Currency ,
66
+ i64 ,
67
+ T ,
68
+ ) > for AirwallexRouterData < T >
69
+ {
70
+ type Error = error_stack:: Report < errors:: ConnectorError > ;
71
+
72
+ fn try_from (
73
+ ( currency_unit, currency, amount, router_data) : (
74
+ & types:: api:: CurrencyUnit ,
75
+ types:: storage:: enums:: Currency ,
76
+ i64 ,
77
+ T ,
78
+ ) ,
79
+ ) -> Result < Self , Self :: Error > {
80
+ let amount = utils:: get_amount_as_string ( currency_unit, amount, currency) ?;
81
+ Ok ( Self {
82
+ amount,
83
+ router_data,
84
+ } )
85
+ }
86
+ }
87
+
56
88
#[ derive( Debug , Serialize ) ]
57
89
pub struct AirwallexPaymentsRequest {
58
90
// Unique ID to be sent for each transaction/operation request to the connector
@@ -125,16 +157,21 @@ pub struct AirwallexCardPaymentOptions {
125
157
auto_capture : bool ,
126
158
}
127
159
128
- impl TryFrom < & types:: PaymentsAuthorizeRouterData > for AirwallexPaymentsRequest {
160
+ impl TryFrom < & AirwallexRouterData < & types:: PaymentsAuthorizeRouterData > >
161
+ for AirwallexPaymentsRequest
162
+ {
129
163
type Error = error_stack:: Report < errors:: ConnectorError > ;
130
- fn try_from ( item : & types:: PaymentsAuthorizeRouterData ) -> Result < Self , Self :: Error > {
164
+ fn try_from (
165
+ item : & AirwallexRouterData < & types:: PaymentsAuthorizeRouterData > ,
166
+ ) -> Result < Self , Self :: Error > {
131
167
let mut payment_method_options = None ;
132
- let payment_method = match item. request . payment_method_data . clone ( ) {
168
+ let request = & item. router_data . request ;
169
+ let payment_method = match request. payment_method_data . clone ( ) {
133
170
api:: PaymentMethodData :: Card ( ccard) => {
134
171
payment_method_options =
135
172
Some ( AirwallexPaymentOptions :: Card ( AirwallexCardPaymentOptions {
136
173
auto_capture : matches ! (
137
- item . request. capture_method,
174
+ request. capture_method,
138
175
Some ( enums:: CaptureMethod :: Automatic ) | None
139
176
) ,
140
177
} ) ) ;
@@ -158,7 +195,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for AirwallexPaymentsRequest {
158
195
request_id : Uuid :: new_v4 ( ) . to_string ( ) ,
159
196
payment_method,
160
197
payment_method_options,
161
- return_url : item . request . complete_authorize_url . clone ( ) ,
198
+ return_url : request. complete_authorize_url . clone ( ) ,
162
199
} )
163
200
}
164
201
}
@@ -538,17 +575,16 @@ pub struct AirwallexRefundRequest {
538
575
payment_intent_id : String ,
539
576
}
540
577
541
- impl < F > TryFrom < & types:: RefundsRouterData < F > > for AirwallexRefundRequest {
578
+ impl < F > TryFrom < & AirwallexRouterData < & types:: RefundsRouterData < F > > > for AirwallexRefundRequest {
542
579
type Error = error_stack:: Report < errors:: ConnectorError > ;
543
- fn try_from ( item : & types:: RefundsRouterData < F > ) -> Result < Self , Self :: Error > {
580
+ fn try_from (
581
+ item : & AirwallexRouterData < & types:: RefundsRouterData < F > > ,
582
+ ) -> Result < Self , Self :: Error > {
544
583
Ok ( Self {
545
584
request_id : Uuid :: new_v4 ( ) . to_string ( ) ,
546
- amount : Some ( utils:: to_currency_base_unit (
547
- item. request . refund_amount ,
548
- item. request . currency ,
549
- ) ?) ,
550
- reason : item. request . reason . clone ( ) ,
551
- payment_intent_id : item. request . connector_transaction_id . clone ( ) ,
585
+ amount : Some ( item. amount . to_owned ( ) ) ,
586
+ reason : item. router_data . request . reason . clone ( ) ,
587
+ payment_intent_id : item. router_data . request . connector_transaction_id . clone ( ) ,
552
588
} )
553
589
}
554
590
}
0 commit comments