@@ -2,10 +2,20 @@ use std::fmt::Debug;
2
2
3
3
use common_utils:: { encryption:: Encryption , id_type, pii} ;
4
4
use diesel:: { AsChangeset , Identifiable , Insertable , Queryable , Selectable } ;
5
- use masking:: Secret ;
6
5
7
- use crate :: { enums as storage_enums, schema:: merchant_connector_account} ;
6
+ use crate :: enums as storage_enums;
7
+ #[ cfg( all(
8
+ any( feature = "v1" , feature = "v2" ) ,
9
+ not( feature = "merchant_connector_account_v2" )
10
+ ) ) ]
11
+ use crate :: schema:: merchant_connector_account;
12
+ #[ cfg( all( feature = "v2" , feature = "merchant_connector_account_v2" ) ) ]
13
+ use crate :: schema_v2:: merchant_connector_account;
8
14
15
+ #[ cfg( all(
16
+ any( feature = "v1" , feature = "v2" ) ,
17
+ not( feature = "merchant_connector_account_v2" )
18
+ ) ) ]
9
19
#[ derive(
10
20
Clone ,
11
21
Debug ,
@@ -24,20 +34,20 @@ pub struct MerchantConnectorAccount {
24
34
pub test_mode : Option < bool > ,
25
35
pub disabled : Option < bool > ,
26
36
pub merchant_connector_id : String ,
27
- #[ diesel( deserialize_as = super :: OptionalDieselArray <serde_json :: Value >) ]
28
- pub payment_methods_enabled : Option < Vec < serde_json :: Value > > ,
37
+ #[ diesel( deserialize_as = super :: OptionalDieselArray <pii :: SecretSerdeValue >) ]
38
+ pub payment_methods_enabled : Option < Vec < pii :: SecretSerdeValue > > ,
29
39
pub connector_type : storage_enums:: ConnectorType ,
30
40
pub metadata : Option < pii:: SecretSerdeValue > ,
31
41
pub connector_label : Option < String > ,
32
42
pub business_country : Option < storage_enums:: CountryAlpha2 > ,
33
43
pub business_label : Option < String > ,
34
44
pub business_sub_label : Option < String > ,
35
- pub frm_configs : Option < Secret < serde_json :: Value > > ,
45
+ pub frm_configs : Option < pii :: SecretSerdeValue > ,
36
46
pub created_at : time:: PrimitiveDateTime ,
37
47
pub modified_at : time:: PrimitiveDateTime ,
38
48
pub connector_webhook_details : Option < pii:: SecretSerdeValue > ,
39
49
#[ diesel( deserialize_as = super :: OptionalDieselArray <pii:: SecretSerdeValue >) ]
40
- pub frm_config : Option < Vec < Secret < serde_json :: Value > > > ,
50
+ pub frm_config : Option < Vec < pii :: SecretSerdeValue > > ,
41
51
pub profile_id : Option < String > ,
42
52
#[ diesel( deserialize_as = super :: OptionalDieselArray <String >) ]
43
53
pub applepay_verified_domains : Option < Vec < String > > ,
@@ -47,6 +57,64 @@ pub struct MerchantConnectorAccount {
47
57
pub connector_wallets_details : Option < Encryption > ,
48
58
}
49
59
60
+ #[ cfg( all(
61
+ any( feature = "v1" , feature = "v2" ) ,
62
+ not( feature = "merchant_connector_account_v2" )
63
+ ) ) ]
64
+ impl MerchantConnectorAccount {
65
+ pub fn get_id ( & self ) -> String {
66
+ self . merchant_connector_id . clone ( )
67
+ }
68
+ }
69
+
70
+ #[ cfg( all( feature = "v2" , feature = "merchant_connector_account_v2" ) ) ]
71
+ #[ derive(
72
+ Clone ,
73
+ Debug ,
74
+ serde:: Serialize ,
75
+ serde:: Deserialize ,
76
+ Identifiable ,
77
+ Queryable ,
78
+ Selectable ,
79
+ router_derive:: DebugAsDisplay ,
80
+ ) ]
81
+ #[ diesel( table_name = merchant_connector_account, check_for_backend( diesel:: pg:: Pg ) ) ]
82
+ pub struct MerchantConnectorAccount {
83
+ pub merchant_id : id_type:: MerchantId ,
84
+ pub connector_name : String ,
85
+ pub connector_account_details : Encryption ,
86
+ pub disabled : Option < bool > ,
87
+ #[ diesel( deserialize_as = super :: OptionalDieselArray <pii:: SecretSerdeValue >) ]
88
+ pub payment_methods_enabled : Option < Vec < pii:: SecretSerdeValue > > ,
89
+ pub connector_type : storage_enums:: ConnectorType ,
90
+ pub metadata : Option < pii:: SecretSerdeValue > ,
91
+ pub connector_label : Option < String > ,
92
+ pub created_at : time:: PrimitiveDateTime ,
93
+ pub modified_at : time:: PrimitiveDateTime ,
94
+ pub connector_webhook_details : Option < pii:: SecretSerdeValue > ,
95
+ #[ diesel( deserialize_as = super :: OptionalDieselArray <pii:: SecretSerdeValue >) ]
96
+ pub frm_config : Option < Vec < pii:: SecretSerdeValue > > ,
97
+ pub profile_id : Option < String > ,
98
+ #[ diesel( deserialize_as = super :: OptionalDieselArray <String >) ]
99
+ pub applepay_verified_domains : Option < Vec < String > > ,
100
+ pub pm_auth_config : Option < pii:: SecretSerdeValue > ,
101
+ pub status : storage_enums:: ConnectorStatus ,
102
+ pub additional_merchant_data : Option < Encryption > ,
103
+ pub connector_wallets_details : Option < Encryption > ,
104
+ pub id : String ,
105
+ }
106
+
107
+ #[ cfg( all( feature = "v2" , feature = "merchant_connector_account_v2" ) ) ]
108
+ impl MerchantConnectorAccount {
109
+ pub fn get_id ( & self ) -> String {
110
+ self . id . clone ( )
111
+ }
112
+ }
113
+
114
+ #[ cfg( all(
115
+ any( feature = "v1" , feature = "v2" ) ,
116
+ not( feature = "merchant_connector_account_v2" )
117
+ ) ) ]
50
118
#[ derive( Clone , Debug , Insertable , router_derive:: DebugAsDisplay ) ]
51
119
#[ diesel( table_name = merchant_connector_account) ]
52
120
pub struct MerchantConnectorAccountNew {
@@ -57,27 +125,58 @@ pub struct MerchantConnectorAccountNew {
57
125
pub test_mode : Option < bool > ,
58
126
pub disabled : Option < bool > ,
59
127
pub merchant_connector_id : String ,
60
- pub payment_methods_enabled : Option < Vec < serde_json :: Value > > ,
128
+ pub payment_methods_enabled : Option < Vec < pii :: SecretSerdeValue > > ,
61
129
pub metadata : Option < pii:: SecretSerdeValue > ,
62
130
pub connector_label : Option < String > ,
63
131
pub business_country : Option < storage_enums:: CountryAlpha2 > ,
64
132
pub business_label : Option < String > ,
65
133
pub business_sub_label : Option < String > ,
66
- pub frm_configs : Option < Secret < serde_json:: Value > > ,
134
+ pub frm_configs : Option < pii:: SecretSerdeValue > ,
135
+ pub created_at : time:: PrimitiveDateTime ,
136
+ pub modified_at : time:: PrimitiveDateTime ,
137
+ pub connector_webhook_details : Option < pii:: SecretSerdeValue > ,
138
+ #[ diesel( deserialize_as = super :: OptionalDieselArray <pii:: SecretSerdeValue >) ]
139
+ pub frm_config : Option < Vec < pii:: SecretSerdeValue > > ,
140
+ pub profile_id : Option < String > ,
141
+ #[ diesel( deserialize_as = super :: OptionalDieselArray <String >) ]
142
+ pub applepay_verified_domains : Option < Vec < String > > ,
143
+ pub pm_auth_config : Option < pii:: SecretSerdeValue > ,
144
+ pub status : storage_enums:: ConnectorStatus ,
145
+ pub additional_merchant_data : Option < Encryption > ,
146
+ pub connector_wallets_details : Option < Encryption > ,
147
+ }
148
+
149
+ #[ cfg( all( feature = "v2" , feature = "merchant_connector_account_v2" ) ) ]
150
+ #[ derive( Clone , Debug , Insertable , router_derive:: DebugAsDisplay ) ]
151
+ #[ diesel( table_name = merchant_connector_account) ]
152
+ pub struct MerchantConnectorAccountNew {
153
+ pub merchant_id : Option < id_type:: MerchantId > ,
154
+ pub connector_type : Option < storage_enums:: ConnectorType > ,
155
+ pub connector_name : Option < String > ,
156
+ pub connector_account_details : Option < Encryption > ,
157
+ pub disabled : Option < bool > ,
158
+ pub payment_methods_enabled : Option < Vec < pii:: SecretSerdeValue > > ,
159
+ pub metadata : Option < pii:: SecretSerdeValue > ,
160
+ pub connector_label : Option < String > ,
67
161
pub created_at : time:: PrimitiveDateTime ,
68
162
pub modified_at : time:: PrimitiveDateTime ,
69
163
pub connector_webhook_details : Option < pii:: SecretSerdeValue > ,
70
164
#[ diesel( deserialize_as = super :: OptionalDieselArray <pii:: SecretSerdeValue >) ]
71
- pub frm_config : Option < Vec < Secret < serde_json :: Value > > > ,
165
+ pub frm_config : Option < Vec < pii :: SecretSerdeValue > > ,
72
166
pub profile_id : Option < String > ,
73
167
#[ diesel( deserialize_as = super :: OptionalDieselArray <String >) ]
74
168
pub applepay_verified_domains : Option < Vec < String > > ,
75
169
pub pm_auth_config : Option < pii:: SecretSerdeValue > ,
76
170
pub status : storage_enums:: ConnectorStatus ,
77
171
pub additional_merchant_data : Option < Encryption > ,
78
172
pub connector_wallets_details : Option < Encryption > ,
173
+ pub id : String ,
79
174
}
80
175
176
+ #[ cfg( all(
177
+ any( feature = "v1" , feature = "v2" ) ,
178
+ not( feature = "merchant_connector_account_v2" )
179
+ ) ) ]
81
180
#[ derive( Clone , Debug , AsChangeset , router_derive:: DebugAsDisplay ) ]
82
181
#[ diesel( table_name = merchant_connector_account) ]
83
182
pub struct MerchantConnectorAccountUpdateInternal {
@@ -88,20 +187,45 @@ pub struct MerchantConnectorAccountUpdateInternal {
88
187
pub test_mode : Option < bool > ,
89
188
pub disabled : Option < bool > ,
90
189
pub merchant_connector_id : Option < String > ,
91
- pub payment_methods_enabled : Option < Vec < serde_json :: Value > > ,
92
- pub frm_configs : Option < Secret < serde_json :: Value > > ,
190
+ pub payment_methods_enabled : Option < Vec < pii :: SecretSerdeValue > > ,
191
+ pub frm_configs : Option < pii :: SecretSerdeValue > ,
93
192
pub metadata : Option < pii:: SecretSerdeValue > ,
94
193
pub modified_at : Option < time:: PrimitiveDateTime > ,
95
194
pub connector_webhook_details : Option < pii:: SecretSerdeValue > ,
96
195
#[ diesel( deserialize_as = super :: OptionalDieselArray <pii:: SecretSerdeValue >) ]
97
- pub frm_config : Option < Vec < Secret < serde_json :: Value > > > ,
196
+ pub frm_config : Option < Vec < pii :: SecretSerdeValue > > ,
98
197
#[ diesel( deserialize_as = super :: OptionalDieselArray <String >) ]
99
198
pub applepay_verified_domains : Option < Vec < String > > ,
100
199
pub pm_auth_config : Option < pii:: SecretSerdeValue > ,
101
200
pub status : Option < storage_enums:: ConnectorStatus > ,
102
201
pub connector_wallets_details : Option < Encryption > ,
103
202
}
104
203
204
+ #[ cfg( all( feature = "v2" , feature = "merchant_connector_account_v2" ) ) ]
205
+ #[ derive( Clone , Debug , AsChangeset , router_derive:: DebugAsDisplay ) ]
206
+ #[ diesel( table_name = merchant_connector_account) ]
207
+ pub struct MerchantConnectorAccountUpdateInternal {
208
+ pub connector_type : Option < storage_enums:: ConnectorType > ,
209
+ pub connector_account_details : Option < Encryption > ,
210
+ pub connector_label : Option < String > ,
211
+ pub disabled : Option < bool > ,
212
+ pub payment_methods_enabled : Option < Vec < pii:: SecretSerdeValue > > ,
213
+ pub metadata : Option < pii:: SecretSerdeValue > ,
214
+ pub modified_at : Option < time:: PrimitiveDateTime > ,
215
+ pub connector_webhook_details : Option < pii:: SecretSerdeValue > ,
216
+ #[ diesel( deserialize_as = super :: OptionalDieselArray <pii:: SecretSerdeValue >) ]
217
+ pub frm_config : Option < Vec < pii:: SecretSerdeValue > > ,
218
+ #[ diesel( deserialize_as = super :: OptionalDieselArray <String >) ]
219
+ pub applepay_verified_domains : Option < Vec < String > > ,
220
+ pub pm_auth_config : Option < pii:: SecretSerdeValue > ,
221
+ pub status : Option < storage_enums:: ConnectorStatus > ,
222
+ pub connector_wallets_details : Option < Encryption > ,
223
+ }
224
+
225
+ #[ cfg( all(
226
+ any( feature = "v1" , feature = "v2" ) ,
227
+ not( feature = "merchant_connector_account_v2" )
228
+ ) ) ]
105
229
impl MerchantConnectorAccountUpdateInternal {
106
230
pub fn create_merchant_connector_account (
107
231
self ,
@@ -128,3 +252,26 @@ impl MerchantConnectorAccountUpdateInternal {
128
252
}
129
253
}
130
254
}
255
+
256
+ #[ cfg( all( feature = "v2" , feature = "merchant_connector_account_v2" ) ) ]
257
+ impl MerchantConnectorAccountUpdateInternal {
258
+ pub fn create_merchant_connector_account (
259
+ self ,
260
+ source : MerchantConnectorAccount ,
261
+ ) -> MerchantConnectorAccount {
262
+ MerchantConnectorAccount {
263
+ connector_type : self . connector_type . unwrap_or ( source. connector_type ) ,
264
+ connector_account_details : self
265
+ . connector_account_details
266
+ . unwrap_or ( source. connector_account_details ) ,
267
+ disabled : self . disabled ,
268
+ payment_methods_enabled : self . payment_methods_enabled ,
269
+ frm_config : self . frm_config ,
270
+ modified_at : self . modified_at . unwrap_or ( source. modified_at ) ,
271
+ pm_auth_config : self . pm_auth_config ,
272
+ status : self . status . unwrap_or ( source. status ) ,
273
+
274
+ ..source
275
+ }
276
+ }
277
+ }
0 commit comments