@@ -35,6 +35,7 @@ pub struct PayoutData {
35
35
pub payout_attempt : storage:: PayoutAttempt ,
36
36
pub payout_method_data : Option < payouts:: PayoutMethodData > ,
37
37
pub merchant_connector_account : Option < payment_helpers:: MerchantConnectorAccountType > ,
38
+ pub profile_id : String ,
38
39
}
39
40
40
41
// ********************************************** CORE FLOWS **********************************************
@@ -96,9 +97,7 @@ pub async fn payouts_create_core(
96
97
merchant_account : domain:: MerchantAccount ,
97
98
key_store : domain:: MerchantKeyStore ,
98
99
req : payouts:: PayoutCreateRequest ,
99
- ) -> RouterResponse < payouts:: PayoutCreateResponse >
100
- where
101
- {
100
+ ) -> RouterResponse < payouts:: PayoutCreateResponse > {
102
101
// Form connector data
103
102
let connector_data = get_connector_data (
104
103
& state,
@@ -111,7 +110,7 @@ where
111
110
. await ?;
112
111
113
112
// Validate create request
114
- let ( payout_id, payout_method_data) =
113
+ let ( payout_id, payout_method_data, profile_id ) =
115
114
validator:: validate_create_request ( & state, & merchant_account, & req, & key_store) . await ?;
116
115
117
116
// Create DB entries
@@ -121,6 +120,7 @@ where
121
120
& key_store,
122
121
& req,
123
122
& payout_id,
123
+ & profile_id,
124
124
& connector_data. connector_name ,
125
125
payout_method_data. as_ref ( ) ,
126
126
)
@@ -561,18 +561,8 @@ pub async fn create_recipient(
561
561
let customer_details = payout_data. customer_details . to_owned ( ) ;
562
562
let connector_name = connector_data. connector_name . to_string ( ) ;
563
563
564
- let profile_id = core_utils:: get_profile_id_from_business_details (
565
- payout_data. payout_attempt . business_country ,
566
- payout_data. payout_attempt . business_label . as_ref ( ) ,
567
- merchant_account,
568
- payout_data. payout_attempt . profile_id . as_ref ( ) ,
569
- & * state. store ,
570
- false ,
571
- )
572
- . await ?;
573
-
574
564
// Create the connector label using {profile_id}_{connector_name}
575
- let connector_label = format ! ( "{profile_id }_{}" , connector_name) ;
565
+ let connector_label = format ! ( "{}_{}" , payout_data . profile_id , connector_name) ;
576
566
577
567
let ( should_call_connector, _connector_customer_id) =
578
568
helpers:: should_call_payout_connector_create_customer (
@@ -1124,13 +1114,15 @@ pub async fn response_handler(
1124
1114
}
1125
1115
1126
1116
// DB entries
1117
+ #[ allow( clippy:: too_many_arguments) ]
1127
1118
#[ cfg( feature = "payouts" ) ]
1128
1119
pub async fn payout_create_db_entries (
1129
1120
state : & AppState ,
1130
1121
merchant_account : & domain:: MerchantAccount ,
1131
1122
key_store : & domain:: MerchantKeyStore ,
1132
1123
req : & payouts:: PayoutCreateRequest ,
1133
1124
payout_id : & String ,
1125
+ profile_id : & String ,
1134
1126
connector_name : & api_enums:: PayoutConnectors ,
1135
1127
stored_payout_method_data : Option < & payouts:: PayoutMethodData > ,
1136
1128
) -> RouterResult < PayoutData > {
@@ -1231,8 +1223,7 @@ pub async fn payout_create_db_entries(
1231
1223
} else {
1232
1224
storage_enums:: PayoutStatus :: RequiresPayoutMethodData
1233
1225
} ;
1234
- let _id = core_utils:: get_or_generate_uuid ( "payout_attempt_id" , None ) ?;
1235
- let payout_attempt_id = format ! ( "{}_{}" , merchant_id. to_owned( ) , payout_id. to_owned( ) ) ;
1226
+ let payout_attempt_id = utils:: get_payment_attempt_id ( payout_id, 1 ) ;
1236
1227
1237
1228
let payout_attempt_req = storage:: PayoutAttemptNew :: default ( )
1238
1229
. set_payout_attempt_id ( payout_attempt_id. to_string ( ) )
@@ -1247,7 +1238,7 @@ pub async fn payout_create_db_entries(
1247
1238
. set_payout_token ( req. payout_token . to_owned ( ) )
1248
1239
. set_created_at ( Some ( common_utils:: date_time:: now ( ) ) )
1249
1240
. set_last_modified_at ( Some ( common_utils:: date_time:: now ( ) ) )
1250
- . set_profile_id ( req . profile_id . to_owned ( ) )
1241
+ . set_profile_id ( Some ( profile_id. to_string ( ) ) )
1251
1242
. to_owned ( ) ;
1252
1243
let payout_attempt = db
1253
1244
. insert_payout_attempt ( payout_attempt_req)
@@ -1269,6 +1260,7 @@ pub async fn payout_create_db_entries(
1269
1260
. cloned ( )
1270
1261
. or ( stored_payout_method_data. cloned ( ) ) ,
1271
1262
merchant_connector_account : None ,
1263
+ profile_id : profile_id. to_owned ( ) ,
1272
1264
} )
1273
1265
}
1274
1266
@@ -1318,12 +1310,15 @@ pub async fn make_payout_data(
1318
1310
. await
1319
1311
. map_or ( None , |c| c) ;
1320
1312
1313
+ let profile_id = payout_attempt. profile_id . clone ( ) ;
1314
+
1321
1315
Ok ( PayoutData {
1322
1316
billing_address,
1323
1317
customer_details,
1324
1318
payouts,
1325
1319
payout_attempt,
1326
1320
payout_method_data : None ,
1327
1321
merchant_connector_account : None ,
1322
+ profile_id,
1328
1323
} )
1329
1324
}
0 commit comments