1
1
use common_enums:: enums;
2
- use serde:: { Deserialize , Serialize } ;
3
- use masking:: Secret ;
4
- use common_utils:: types:: { StringMinorUnit } ;
2
+ use common_utils:: types:: StringMinorUnit ;
5
3
use hyperswitch_domain_models:: {
6
4
payment_method_data:: PaymentMethodData ,
7
5
router_data:: { ConnectorAuthType , RouterData } ,
@@ -11,6 +9,9 @@ use hyperswitch_domain_models::{
11
9
types:: { PaymentsAuthorizeRouterData , RefundsRouterData } ,
12
10
} ;
13
11
use hyperswitch_interfaces:: errors;
12
+ use masking:: Secret ;
13
+ use serde:: { Deserialize , Serialize } ;
14
+
14
15
use crate :: types:: { RefundsResponseRouterData , ResponseRouterData } ;
15
16
16
17
//TODO: Fill the struct with respective fields
@@ -19,19 +20,9 @@ pub struct BlackhawknetworkRouterData<T> {
19
20
pub router_data : T ,
20
21
}
21
22
22
- impl < T >
23
- From < (
24
- StringMinorUnit ,
25
- T ,
26
- ) > for BlackhawknetworkRouterData < T >
27
- {
28
- fn from (
29
- ( amount, item) : (
30
- StringMinorUnit ,
31
- T ,
32
- ) ,
33
- ) -> Self {
34
- //Todo : use utils to convert the amount to the type of amount that a connector accepts
23
+ impl < T > From < ( StringMinorUnit , T ) > for BlackhawknetworkRouterData < T > {
24
+ fn from ( ( amount, item) : ( StringMinorUnit , T ) ) -> Self {
25
+ //Todo : use utils to convert the amount to the type of amount that a connector accepts
35
26
Self {
36
27
amount,
37
28
router_data : item,
@@ -43,7 +34,7 @@ impl<T>
43
34
#[ derive( Default , Debug , Serialize , PartialEq ) ]
44
35
pub struct BlackhawknetworkPaymentsRequest {
45
36
amount : StringMinorUnit ,
46
- card : BlackhawknetworkCard
37
+ card : BlackhawknetworkCard ,
47
38
}
48
39
49
40
#[ derive( Default , Debug , Serialize , Eq , PartialEq ) ]
@@ -55,26 +46,30 @@ pub struct BlackhawknetworkCard {
55
46
complete : bool ,
56
47
}
57
48
58
- impl TryFrom < & BlackhawknetworkRouterData < & PaymentsAuthorizeRouterData > > for BlackhawknetworkPaymentsRequest {
49
+ impl TryFrom < & BlackhawknetworkRouterData < & PaymentsAuthorizeRouterData > >
50
+ for BlackhawknetworkPaymentsRequest
51
+ {
59
52
type Error = error_stack:: Report < errors:: ConnectorError > ;
60
- fn try_from ( item : & BlackhawknetworkRouterData < & PaymentsAuthorizeRouterData > ) -> Result < Self , Self :: Error > {
53
+ fn try_from (
54
+ item : & BlackhawknetworkRouterData < & PaymentsAuthorizeRouterData > ,
55
+ ) -> Result < Self , Self :: Error > {
61
56
match item. router_data . request . payment_method_data . clone ( ) {
62
- PaymentMethodData :: Card ( _) => {
63
- Err ( errors:: ConnectorError :: NotImplemented ( "Card payment method not implemented" . to_string ( ) ) . into ( ) )
64
- } ,
57
+ PaymentMethodData :: Card ( _) => Err ( errors:: ConnectorError :: NotImplemented (
58
+ "Card payment method not implemented" . to_string ( ) ,
59
+ )
60
+ . into ( ) ) ,
65
61
_ => Err ( errors:: ConnectorError :: NotImplemented ( "Payment method" . to_string ( ) ) . into ( ) ) ,
66
62
}
67
-
68
63
}
69
64
}
70
65
71
66
//TODO: Fill the struct with respective fields
72
67
// Auth Struct
73
68
pub struct BlackhawknetworkAuthType {
74
- pub ( super ) api_key : Secret < String >
69
+ pub ( super ) api_key : Secret < String > ,
75
70
}
76
71
77
- impl TryFrom < & ConnectorAuthType > for BlackhawknetworkAuthType {
72
+ impl TryFrom < & ConnectorAuthType > for BlackhawknetworkAuthType {
78
73
type Error = error_stack:: Report < errors:: ConnectorError > ;
79
74
fn try_from ( auth_type : & ConnectorAuthType ) -> Result < Self , Self :: Error > {
80
75
match auth_type {
@@ -113,9 +108,13 @@ pub struct BlackhawknetworkPaymentsResponse {
113
108
id : String ,
114
109
}
115
110
116
- impl < F , T > TryFrom < ResponseRouterData < F , BlackhawknetworkPaymentsResponse , T , PaymentsResponseData > > for RouterData < F , T , PaymentsResponseData > {
111
+ impl < F , T > TryFrom < ResponseRouterData < F , BlackhawknetworkPaymentsResponse , T , PaymentsResponseData > >
112
+ for RouterData < F , T , PaymentsResponseData >
113
+ {
117
114
type Error = error_stack:: Report < errors:: ConnectorError > ;
118
- fn try_from ( item : ResponseRouterData < F , BlackhawknetworkPaymentsResponse , T , PaymentsResponseData > ) -> Result < Self , Self :: Error > {
115
+ fn try_from (
116
+ item : ResponseRouterData < F , BlackhawknetworkPaymentsResponse , T , PaymentsResponseData > ,
117
+ ) -> Result < Self , Self :: Error > {
119
118
Ok ( Self {
120
119
status : common_enums:: AttemptStatus :: from ( item. response . status ) ,
121
120
response : Ok ( PaymentsResponseData :: TransactionResponse {
@@ -138,12 +137,16 @@ impl<F,T> TryFrom<ResponseRouterData<F, BlackhawknetworkPaymentsResponse, T, Pay
138
137
// Type definition for RefundRequest
139
138
#[ derive( Default , Debug , Serialize ) ]
140
139
pub struct BlackhawknetworkRefundRequest {
141
- pub amount : StringMinorUnit
140
+ pub amount : StringMinorUnit ,
142
141
}
143
142
144
- impl < F > TryFrom < & BlackhawknetworkRouterData < & RefundsRouterData < F > > > for BlackhawknetworkRefundRequest {
143
+ impl < F > TryFrom < & BlackhawknetworkRouterData < & RefundsRouterData < F > > >
144
+ for BlackhawknetworkRefundRequest
145
+ {
145
146
type Error = error_stack:: Report < errors:: ConnectorError > ;
146
- fn try_from ( item : & BlackhawknetworkRouterData < & RefundsRouterData < F > > ) -> Result < Self , Self :: Error > {
147
+ fn try_from (
148
+ item : & BlackhawknetworkRouterData < & RefundsRouterData < F > > ,
149
+ ) -> Result < Self , Self :: Error > {
147
150
Ok ( Self {
148
151
amount : item. amount . to_owned ( ) ,
149
152
} )
@@ -176,12 +179,10 @@ impl From<RefundStatus> for enums::RefundStatus {
176
179
#[ derive( Default , Debug , Clone , Serialize , Deserialize ) ]
177
180
pub struct RefundResponse {
178
181
id : String ,
179
- status : RefundStatus
182
+ status : RefundStatus ,
180
183
}
181
184
182
- impl TryFrom < RefundsResponseRouterData < Execute , RefundResponse > >
183
- for RefundsRouterData < Execute >
184
- {
185
+ impl TryFrom < RefundsResponseRouterData < Execute , RefundResponse > > for RefundsRouterData < Execute > {
185
186
type Error = error_stack:: Report < errors:: ConnectorError > ;
186
187
fn try_from (
187
188
item : RefundsResponseRouterData < Execute , RefundResponse > ,
@@ -196,19 +197,20 @@ impl TryFrom<RefundsResponseRouterData<Execute, RefundResponse>>
196
197
}
197
198
}
198
199
199
- impl TryFrom < RefundsResponseRouterData < RSync , RefundResponse > > for RefundsRouterData < RSync >
200
- {
201
- type Error = error_stack:: Report < errors:: ConnectorError > ;
202
- fn try_from ( item : RefundsResponseRouterData < RSync , RefundResponse > ) -> Result < Self , Self :: Error > {
200
+ impl TryFrom < RefundsResponseRouterData < RSync , RefundResponse > > for RefundsRouterData < RSync > {
201
+ type Error = error_stack:: Report < errors:: ConnectorError > ;
202
+ fn try_from (
203
+ item : RefundsResponseRouterData < RSync , RefundResponse > ,
204
+ ) -> Result < Self , Self :: Error > {
203
205
Ok ( Self {
204
206
response : Ok ( RefundsResponseData {
205
207
connector_refund_id : item. response . id . to_string ( ) ,
206
208
refund_status : enums:: RefundStatus :: from ( item. response . status ) ,
207
209
} ) ,
208
210
..item. data
209
211
} )
210
- }
211
- }
212
+ }
213
+ }
212
214
213
215
//TODO: Fill the struct with respective fields
214
216
#[ derive( Default , Debug , Serialize , Deserialize , PartialEq ) ]
0 commit comments