1
1
use common_utils:: {
2
- pii,
2
+ id_type , pii,
3
3
types:: { ChargeRefunds , ConnectorTransactionId , ConnectorTransactionIdTrait , MinorUnit } ,
4
4
} ;
5
5
use diesel:: { AsChangeset , Identifiable , Insertable , Queryable , Selectable } ;
@@ -11,6 +11,14 @@ use crate::enums as storage_enums;
11
11
use crate :: schema:: refund;
12
12
#[ cfg( feature = "v2" ) ]
13
13
use crate :: schema_v2:: refund;
14
+ #[ cfg( feature = "v2" ) ]
15
+ use crate :: RequiredFromNullable ;
16
+ #[ cfg( feature = "v2" ) ]
17
+ impl From < RequiredFromNullable < id_type:: RefundReferenceId > > for id_type:: RefundReferenceId {
18
+ fn from ( wrapper : RequiredFromNullable < id_type:: RefundReferenceId > ) -> Self {
19
+ wrapper. into_inner ( )
20
+ }
21
+ }
14
22
#[ cfg( feature = "v1" ) ]
15
23
#[ derive(
16
24
Clone ,
@@ -27,8 +35,8 @@ use crate::schema_v2::refund;
27
35
pub struct Refund {
28
36
pub internal_reference_id : String ,
29
37
pub refund_id : String , //merchant_reference id
30
- pub payment_id : common_utils :: id_type:: PaymentId ,
31
- pub merchant_id : common_utils :: id_type:: MerchantId ,
38
+ pub payment_id : id_type:: PaymentId ,
39
+ pub merchant_id : id_type:: MerchantId ,
32
40
pub connector_transaction_id : ConnectorTransactionId ,
33
41
pub connector : String ,
34
42
pub connector_refund_id : Option < ConnectorTransactionId > ,
@@ -50,11 +58,11 @@ pub struct Refund {
50
58
pub attempt_id : String ,
51
59
pub refund_reason : Option < String > ,
52
60
pub refund_error_code : Option < String > ,
53
- pub profile_id : Option < common_utils :: id_type:: ProfileId > ,
61
+ pub profile_id : Option < id_type:: ProfileId > ,
54
62
pub updated_by : String ,
55
- pub merchant_connector_id : Option < common_utils :: id_type:: MerchantConnectorAccountId > ,
63
+ pub merchant_connector_id : Option < id_type:: MerchantConnectorAccountId > ,
56
64
pub charges : Option < ChargeRefunds > ,
57
- pub organization_id : common_utils :: id_type:: OrganizationId ,
65
+ pub organization_id : id_type:: OrganizationId ,
58
66
/// INFO: This field is deprecated and replaced by processor_refund_data
59
67
pub connector_refund_data : Option < String > ,
60
68
/// INFO: This field is deprecated and replaced by processor_transaction_data
@@ -82,8 +90,8 @@ pub struct Refund {
82
90
) ]
83
91
#[ diesel( table_name = refund, primary_key( id) , check_for_backend( diesel:: pg:: Pg ) ) ]
84
92
pub struct Refund {
85
- pub payment_id : common_utils :: id_type:: GlobalPaymentId ,
86
- pub merchant_id : common_utils :: id_type:: MerchantId ,
93
+ pub payment_id : id_type:: GlobalPaymentId ,
94
+ pub merchant_id : id_type:: MerchantId ,
87
95
pub connector_transaction_id : ConnectorTransactionId ,
88
96
pub connector : String ,
89
97
pub connector_refund_id : Option < ConnectorTransactionId > ,
@@ -102,21 +110,22 @@ pub struct Refund {
102
110
#[ serde( with = "common_utils::custom_serde::iso8601" ) ]
103
111
pub modified_at : PrimitiveDateTime ,
104
112
pub description : Option < String > ,
105
- pub attempt_id : common_utils :: id_type:: GlobalAttemptId ,
113
+ pub attempt_id : id_type:: GlobalAttemptId ,
106
114
pub refund_reason : Option < String > ,
107
115
pub refund_error_code : Option < String > ,
108
- pub profile_id : Option < common_utils :: id_type:: ProfileId > ,
116
+ pub profile_id : Option < id_type:: ProfileId > ,
109
117
pub updated_by : String ,
110
118
pub charges : Option < ChargeRefunds > ,
111
- pub organization_id : common_utils :: id_type:: OrganizationId ,
119
+ pub organization_id : id_type:: OrganizationId ,
112
120
pub split_refunds : Option < common_types:: refunds:: SplitRefund > ,
113
121
pub unified_code : Option < String > ,
114
122
pub unified_message : Option < String > ,
115
123
pub processor_refund_data : Option < String > ,
116
124
pub processor_transaction_data : Option < String > ,
117
- pub id : common_utils:: id_type:: GlobalRefundId ,
118
- pub merchant_reference_id : Option < common_utils:: id_type:: RefundReferenceId > ,
119
- pub connector_id : Option < common_utils:: id_type:: MerchantConnectorAccountId > ,
125
+ pub id : id_type:: GlobalRefundId ,
126
+ #[ diesel( deserialize_as = RequiredFromNullable <id_type:: RefundReferenceId >) ]
127
+ pub merchant_reference_id : id_type:: RefundReferenceId ,
128
+ pub connector_id : Option < id_type:: MerchantConnectorAccountId > ,
120
129
}
121
130
122
131
#[ cfg( feature = "v1" ) ]
@@ -134,8 +143,8 @@ pub struct Refund {
134
143
#[ diesel( table_name = refund) ]
135
144
pub struct RefundNew {
136
145
pub refund_id : String ,
137
- pub payment_id : common_utils :: id_type:: PaymentId ,
138
- pub merchant_id : common_utils :: id_type:: MerchantId ,
146
+ pub payment_id : id_type:: PaymentId ,
147
+ pub merchant_id : id_type:: MerchantId ,
139
148
pub internal_reference_id : String ,
140
149
pub external_reference_id : Option < String > ,
141
150
pub connector_transaction_id : ConnectorTransactionId ,
@@ -156,11 +165,11 @@ pub struct RefundNew {
156
165
pub description : Option < String > ,
157
166
pub attempt_id : String ,
158
167
pub refund_reason : Option < String > ,
159
- pub profile_id : Option < common_utils :: id_type:: ProfileId > ,
168
+ pub profile_id : Option < id_type:: ProfileId > ,
160
169
pub updated_by : String ,
161
- pub merchant_connector_id : Option < common_utils :: id_type:: MerchantConnectorAccountId > ,
170
+ pub merchant_connector_id : Option < id_type:: MerchantConnectorAccountId > ,
162
171
pub charges : Option < ChargeRefunds > ,
163
- pub organization_id : common_utils :: id_type:: OrganizationId ,
172
+ pub organization_id : id_type:: OrganizationId ,
164
173
pub split_refunds : Option < common_types:: refunds:: SplitRefund > ,
165
174
pub processor_refund_data : Option < String > ,
166
175
pub processor_transaction_data : Option < String > ,
@@ -180,10 +189,10 @@ pub struct RefundNew {
180
189
) ]
181
190
#[ diesel( table_name = refund) ]
182
191
pub struct RefundNew {
183
- pub merchant_reference_id : common_utils :: id_type:: RefundReferenceId ,
184
- pub payment_id : common_utils :: id_type:: GlobalPaymentId ,
185
- pub merchant_id : common_utils :: id_type:: MerchantId ,
186
- pub id : common_utils :: id_type:: GlobalRefundId ,
192
+ pub merchant_reference_id : id_type:: RefundReferenceId ,
193
+ pub payment_id : id_type:: GlobalPaymentId ,
194
+ pub merchant_id : id_type:: MerchantId ,
195
+ pub id : id_type:: GlobalRefundId ,
187
196
pub external_reference_id : Option < String > ,
188
197
pub connector_transaction_id : ConnectorTransactionId ,
189
198
pub connector : String ,
@@ -201,13 +210,13 @@ pub struct RefundNew {
201
210
#[ serde( with = "common_utils::custom_serde::iso8601" ) ]
202
211
pub modified_at : PrimitiveDateTime ,
203
212
pub description : Option < String > ,
204
- pub attempt_id : common_utils :: id_type:: GlobalAttemptId ,
213
+ pub attempt_id : id_type:: GlobalAttemptId ,
205
214
pub refund_reason : Option < String > ,
206
- pub profile_id : Option < common_utils :: id_type:: ProfileId > ,
215
+ pub profile_id : Option < id_type:: ProfileId > ,
207
216
pub updated_by : String ,
208
- pub connector_id : Option < common_utils :: id_type:: MerchantConnectorAccountId > ,
217
+ pub connector_id : Option < id_type:: MerchantConnectorAccountId > ,
209
218
pub charges : Option < ChargeRefunds > ,
210
- pub organization_id : common_utils :: id_type:: OrganizationId ,
219
+ pub organization_id : id_type:: OrganizationId ,
211
220
pub split_refunds : Option < common_types:: refunds:: SplitRefund > ,
212
221
pub processor_refund_data : Option < String > ,
213
222
pub processor_transaction_data : Option < String > ,
@@ -781,18 +790,18 @@ impl RefundUpdate {
781
790
pub struct RefundCoreWorkflow {
782
791
pub refund_internal_reference_id : String ,
783
792
pub connector_transaction_id : ConnectorTransactionId ,
784
- pub merchant_id : common_utils :: id_type:: MerchantId ,
785
- pub payment_id : common_utils :: id_type:: PaymentId ,
793
+ pub merchant_id : id_type:: MerchantId ,
794
+ pub payment_id : id_type:: PaymentId ,
786
795
pub processor_transaction_data : Option < String > ,
787
796
}
788
797
789
798
#[ cfg( feature = "v2" ) ]
790
799
#[ derive( Debug , Eq , PartialEq , Deserialize , Serialize ) ]
791
800
pub struct RefundCoreWorkflow {
792
- pub refund_id : common_utils :: id_type:: GlobalRefundId ,
801
+ pub refund_id : id_type:: GlobalRefundId ,
793
802
pub connector_transaction_id : ConnectorTransactionId ,
794
- pub merchant_id : common_utils :: id_type:: MerchantId ,
795
- pub payment_id : common_utils :: id_type:: GlobalPaymentId ,
803
+ pub merchant_id : id_type:: MerchantId ,
804
+ pub payment_id : id_type:: GlobalPaymentId ,
796
805
pub processor_transaction_data : Option < String > ,
797
806
}
798
807
0 commit comments