@@ -7,7 +7,7 @@ use common_utils::{
7
7
ext_traits:: AsyncExt ,
8
8
types:: { ConnectorTransactionId , MinorUnit } ,
9
9
} ;
10
- use diesel_models:: process_tracker:: business_status;
10
+ use diesel_models:: { process_tracker:: business_status, refund as diesel_refund } ;
11
11
use error_stack:: { report, ResultExt } ;
12
12
use hyperswitch_domain_models:: {
13
13
router_data:: ErrorResponse , router_request_types:: SplitRefundsRequest ,
@@ -136,13 +136,13 @@ pub async fn refund_create_core(
136
136
#[ instrument( skip_all) ]
137
137
pub async fn trigger_refund_to_gateway (
138
138
state : & SessionState ,
139
- refund : & storage :: Refund ,
139
+ refund : & diesel_refund :: Refund ,
140
140
merchant_context : & domain:: MerchantContext ,
141
141
payment_attempt : & storage:: PaymentAttempt ,
142
142
payment_intent : & storage:: PaymentIntent ,
143
143
creds_identifier : Option < String > ,
144
144
split_refunds : Option < SplitRefundsRequest > ,
145
- ) -> RouterResult < storage :: Refund > {
145
+ ) -> RouterResult < diesel_refund :: Refund > {
146
146
let routed_through = payment_attempt
147
147
. connector
148
148
. clone ( )
@@ -223,7 +223,7 @@ pub async fn trigger_refund_to_gateway(
223
223
. err ( )
224
224
. and_then ( |error| match error. current_context ( ) {
225
225
errors:: ConnectorError :: NotImplemented ( message) => {
226
- Some ( storage :: RefundUpdate :: ErrorUpdate {
226
+ Some ( diesel_refund :: RefundUpdate :: ErrorUpdate {
227
227
refund_status : Some ( enums:: RefundStatus :: Failure ) ,
228
228
refund_error_message : Some (
229
229
errors:: ConnectorError :: NotImplemented ( message. to_owned ( ) )
@@ -240,7 +240,7 @@ pub async fn trigger_refund_to_gateway(
240
240
} )
241
241
}
242
242
errors:: ConnectorError :: NotSupported { message, connector } => {
243
- Some ( storage :: RefundUpdate :: ErrorUpdate {
243
+ Some ( diesel_refund :: RefundUpdate :: ErrorUpdate {
244
244
refund_status : Some ( enums:: RefundStatus :: Failure ) ,
245
245
refund_error_message : Some ( format ! (
246
246
"{message} is not supported by {connector}"
@@ -327,7 +327,7 @@ pub async fn trigger_refund_to_gateway(
327
327
)
328
328
} ;
329
329
330
- storage :: RefundUpdate :: ErrorUpdate {
330
+ diesel_refund :: RefundUpdate :: ErrorUpdate {
331
331
refund_status : Some ( enums:: RefundStatus :: Failure ) ,
332
332
refund_error_message : err. reason . or ( Some ( err. message ) ) ,
333
333
refund_error_code : Some ( err. code ) ,
@@ -360,7 +360,7 @@ pub async fn trigger_refund_to_gateway(
360
360
) ,
361
361
) ,
362
362
) ;
363
- storage :: RefundUpdate :: ErrorUpdate {
363
+ diesel_refund :: RefundUpdate :: ErrorUpdate {
364
364
refund_status : Some ( enums:: RefundStatus :: ManualReview ) ,
365
365
refund_error_message : Some ( format ! (
366
366
"Integrity Check Failed! as data mismatched for fields {}" ,
@@ -388,7 +388,7 @@ pub async fn trigger_refund_to_gateway(
388
388
}
389
389
let ( connector_refund_id, processor_refund_data) =
390
390
ConnectorTransactionId :: form_id_and_data ( response. connector_refund_id ) ;
391
- storage :: RefundUpdate :: Update {
391
+ diesel_refund :: RefundUpdate :: Update {
392
392
connector_refund_id,
393
393
refund_status : response. refund_status ,
394
394
sent_to_gateway : true ,
@@ -477,8 +477,8 @@ pub async fn refund_retrieve_core(
477
477
merchant_context : domain:: MerchantContext ,
478
478
profile_id : Option < common_utils:: id_type:: ProfileId > ,
479
479
request : refunds:: RefundsRetrieveRequest ,
480
- refund : storage :: Refund ,
481
- ) -> RouterResult < storage :: Refund > {
480
+ refund : diesel_refund :: Refund ,
481
+ ) -> RouterResult < diesel_refund :: Refund > {
482
482
let db = & * state. store ;
483
483
let merchant_id = merchant_context. get_merchant_account ( ) . get_id ( ) ;
484
484
core_utils:: validate_profile_id_from_auth_layer ( profile_id, & refund) ?;
@@ -539,7 +539,7 @@ pub async fn refund_retrieve_core(
539
539
refund. unified_message
540
540
} ;
541
541
542
- let refund = storage :: Refund {
542
+ let refund = diesel_refund :: Refund {
543
543
unified_message : unified_translated_message,
544
544
..refund
545
545
} ;
@@ -586,10 +586,10 @@ pub async fn sync_refund_with_gateway(
586
586
merchant_context : & domain:: MerchantContext ,
587
587
payment_attempt : & storage:: PaymentAttempt ,
588
588
payment_intent : & storage:: PaymentIntent ,
589
- refund : & storage :: Refund ,
589
+ refund : & diesel_refund :: Refund ,
590
590
creds_identifier : Option < String > ,
591
591
split_refunds : Option < SplitRefundsRequest > ,
592
- ) -> RouterResult < storage :: Refund > {
592
+ ) -> RouterResult < diesel_refund :: Refund > {
593
593
let connector_id = refund. connector . to_string ( ) ;
594
594
let connector: api:: ConnectorData = api:: ConnectorData :: get_connector_by_name (
595
595
& state. conf . connectors ,
@@ -673,7 +673,7 @@ pub async fn sync_refund_with_gateway(
673
673
200 ..=299 => Some ( enums:: RefundStatus :: Failure ) ,
674
674
_ => None ,
675
675
} ;
676
- storage :: RefundUpdate :: ErrorUpdate {
676
+ diesel_refund :: RefundUpdate :: ErrorUpdate {
677
677
refund_status,
678
678
refund_error_message : error_message. reason . or ( Some ( error_message. message ) ) ,
679
679
refund_error_code : Some ( error_message. code ) ,
@@ -705,7 +705,7 @@ pub async fn sync_refund_with_gateway(
705
705
ConnectorTransactionId :: form_id_and_data ( refund_id) ;
706
706
( Some ( refund_id) , refund_data)
707
707
} ) ;
708
- storage :: RefundUpdate :: ErrorUpdate {
708
+ diesel_refund :: RefundUpdate :: ErrorUpdate {
709
709
refund_status : Some ( enums:: RefundStatus :: ManualReview ) ,
710
710
refund_error_message : Some ( format ! (
711
711
"Integrity Check Failed! as data mismatched for fields {}" ,
@@ -724,7 +724,7 @@ pub async fn sync_refund_with_gateway(
724
724
Ok ( ( ) ) => {
725
725
let ( connector_refund_id, processor_refund_data) =
726
726
ConnectorTransactionId :: form_id_and_data ( response. connector_refund_id ) ;
727
- storage :: RefundUpdate :: Update {
727
+ diesel_refund :: RefundUpdate :: Update {
728
728
connector_refund_id,
729
729
refund_status : response. refund_status ,
730
730
sent_to_gateway : true ,
@@ -784,7 +784,7 @@ pub async fn refund_update_core(
784
784
let response = db
785
785
. update_refund (
786
786
refund,
787
- storage :: RefundUpdate :: MetadataAndReasonUpdate {
787
+ diesel_refund :: RefundUpdate :: MetadataAndReasonUpdate {
788
788
metadata : req. metadata ,
789
789
reason : req. reason ,
790
790
updated_by : merchant_context
@@ -894,7 +894,7 @@ pub async fn validate_and_create_refund(
894
894
. attach_printable ( "No connector populated in payment attempt" ) ?;
895
895
let ( connector_transaction_id, processor_transaction_data) =
896
896
ConnectorTransactionId :: form_id_and_data ( connector_transaction_id) ;
897
- let refund_create_req = storage :: RefundNew {
897
+ let refund_create_req = diesel_refund :: RefundNew {
898
898
refund_id : refund_id. to_string ( ) ,
899
899
internal_reference_id : utils:: generate_id ( consts:: ID_LENGTH , "refid" ) ,
900
900
external_reference_id : Some ( refund_id. clone ( ) ) ,
@@ -974,7 +974,7 @@ pub async fn validate_and_create_refund(
974
974
refund. unified_message
975
975
} ;
976
976
977
- let refund = storage :: Refund {
977
+ let refund = diesel_refund :: Refund {
978
978
unified_message : unified_translated_message,
979
979
..refund
980
980
} ;
@@ -1059,7 +1059,7 @@ pub async fn refund_retrieve_core_with_internal_reference_id(
1059
1059
profile_id : Option < common_utils:: id_type:: ProfileId > ,
1060
1060
refund_internal_request_id : String ,
1061
1061
force_sync : Option < bool > ,
1062
- ) -> RouterResult < storage :: Refund > {
1062
+ ) -> RouterResult < diesel_refund :: Refund > {
1063
1063
let db = & * state. store ;
1064
1064
let merchant_id = merchant_context. get_merchant_account ( ) . get_id ( ) ;
1065
1065
@@ -1094,7 +1094,7 @@ pub async fn refund_retrieve_core_with_refund_id(
1094
1094
merchant_context : domain:: MerchantContext ,
1095
1095
profile_id : Option < common_utils:: id_type:: ProfileId > ,
1096
1096
request : refunds:: RefundsRetrieveRequest ,
1097
- ) -> RouterResult < storage :: Refund > {
1097
+ ) -> RouterResult < diesel_refund :: Refund > {
1098
1098
let refund_id = request. refund_id . clone ( ) ;
1099
1099
let db = & * state. store ;
1100
1100
let merchant_id = merchant_context. get_merchant_account ( ) . get_id ( ) ;
@@ -1150,7 +1150,7 @@ pub async fn refund_manual_update(
1150
1150
)
1151
1151
. await
1152
1152
. to_not_found_response ( errors:: ApiErrorResponse :: RefundNotFound ) ?;
1153
- let refund_update = storage :: RefundUpdate :: ManualUpdate {
1153
+ let refund_update = diesel_refund :: RefundUpdate :: ManualUpdate {
1154
1154
refund_status : req. status . map ( common_enums:: RefundStatus :: from) ,
1155
1155
refund_error_message : req. error_message ,
1156
1156
refund_error_code : req. error_code ,
@@ -1254,8 +1254,8 @@ pub async fn get_aggregates_for_refunds(
1254
1254
) )
1255
1255
}
1256
1256
1257
- impl ForeignFrom < storage :: Refund > for api:: RefundResponse {
1258
- fn foreign_from ( refund : storage :: Refund ) -> Self {
1257
+ impl ForeignFrom < diesel_refund :: Refund > for api:: RefundResponse {
1258
+ fn foreign_from ( refund : diesel_refund :: Refund ) -> Self {
1259
1259
let refund = refund;
1260
1260
1261
1261
Self {
@@ -1288,14 +1288,14 @@ impl ForeignFrom<storage::Refund> for api::RefundResponse {
1288
1288
#[ allow( clippy:: too_many_arguments) ]
1289
1289
pub async fn schedule_refund_execution (
1290
1290
state : & SessionState ,
1291
- refund : storage :: Refund ,
1291
+ refund : diesel_refund :: Refund ,
1292
1292
refund_type : api_models:: refunds:: RefundType ,
1293
1293
merchant_context : & domain:: MerchantContext ,
1294
1294
payment_attempt : & storage:: PaymentAttempt ,
1295
1295
payment_intent : & storage:: PaymentIntent ,
1296
1296
creds_identifier : Option < String > ,
1297
1297
split_refunds : Option < SplitRefundsRequest > ,
1298
- ) -> RouterResult < storage :: Refund > {
1298
+ ) -> RouterResult < diesel_refund :: Refund > {
1299
1299
// refunds::RefundResponse> {
1300
1300
let db = & * state. store ;
1301
1301
let runner = storage:: ProcessTrackerRunner :: RefundWorkflowRouter ;
@@ -1383,7 +1383,7 @@ pub async fn sync_refund_with_gateway_workflow(
1383
1383
) -> Result < ( ) , errors:: ProcessTrackerError > {
1384
1384
let key_manager_state = & state. into ( ) ;
1385
1385
let refund_core =
1386
- serde_json:: from_value :: < storage :: RefundCoreWorkflow > ( refund_tracker. tracking_data . clone ( ) )
1386
+ serde_json:: from_value :: < diesel_refund :: RefundCoreWorkflow > ( refund_tracker. tracking_data . clone ( ) )
1387
1387
. change_context ( errors:: ApiErrorResponse :: InternalServerError )
1388
1388
. attach_printable_lazy ( || {
1389
1389
format ! (
@@ -1474,7 +1474,7 @@ pub async fn trigger_refund_execute_workflow(
1474
1474
) -> Result < ( ) , errors:: ProcessTrackerError > {
1475
1475
let db = & * state. store ;
1476
1476
let refund_core =
1477
- serde_json:: from_value :: < storage :: RefundCoreWorkflow > ( refund_tracker. tracking_data . clone ( ) )
1477
+ serde_json:: from_value :: < diesel_refund :: RefundCoreWorkflow > ( refund_tracker. tracking_data . clone ( ) )
1478
1478
. change_context ( errors:: ApiErrorResponse :: InternalServerError )
1479
1479
. attach_printable_lazy ( || {
1480
1480
format ! (
@@ -1593,9 +1593,9 @@ pub async fn trigger_refund_execute_workflow(
1593
1593
1594
1594
#[ instrument]
1595
1595
pub fn refund_to_refund_core_workflow_model (
1596
- refund : & storage :: Refund ,
1597
- ) -> storage :: RefundCoreWorkflow {
1598
- storage :: RefundCoreWorkflow {
1596
+ refund : & diesel_refund :: Refund ,
1597
+ ) -> diesel_refund :: RefundCoreWorkflow {
1598
+ diesel_refund :: RefundCoreWorkflow {
1599
1599
refund_internal_reference_id : refund. internal_reference_id . clone ( ) ,
1600
1600
connector_transaction_id : refund. connector_transaction_id . clone ( ) ,
1601
1601
merchant_id : refund. merchant_id . clone ( ) ,
@@ -1607,7 +1607,7 @@ pub fn refund_to_refund_core_workflow_model(
1607
1607
#[ instrument( skip_all) ]
1608
1608
pub async fn add_refund_sync_task (
1609
1609
db : & dyn db:: StorageInterface ,
1610
- refund : & storage :: Refund ,
1610
+ refund : & diesel_refund :: Refund ,
1611
1611
runner : storage:: ProcessTrackerRunner ,
1612
1612
) -> RouterResult < storage:: ProcessTracker > {
1613
1613
let task = "SYNC_REFUND" ;
@@ -1646,7 +1646,7 @@ pub async fn add_refund_sync_task(
1646
1646
#[ instrument( skip_all) ]
1647
1647
pub async fn add_refund_execute_task (
1648
1648
db : & dyn db:: StorageInterface ,
1649
- refund : & storage :: Refund ,
1649
+ refund : & diesel_refund :: Refund ,
1650
1650
runner : storage:: ProcessTrackerRunner ,
1651
1651
) -> RouterResult < storage:: ProcessTracker > {
1652
1652
let task = "EXECUTE_REFUND" ;
0 commit comments