@@ -557,7 +557,6 @@ pub struct JpmorganRefundResponse {
557
557
pub remaining_refundable_amount : Option < i64 > ,
558
558
}
559
559
560
- #[ allow( dead_code) ]
561
560
#[ derive( Debug , Serialize , Default , Deserialize , Clone ) ]
562
561
pub enum RefundStatus {
563
562
Succeeded ,
@@ -576,24 +575,23 @@ impl From<RefundStatus> for common_enums::RefundStatus {
576
575
}
577
576
}
578
577
579
- pub fn refund_status_from_transaction_state (
580
- response_status : JpmorganResponseStatus ,
581
- transaction_state : JpmorganTransactionState ,
582
- ) -> common_enums:: RefundStatus {
583
- match response_status {
584
- JpmorganResponseStatus :: Success => match transaction_state {
585
- JpmorganTransactionState :: Voided | JpmorganTransactionState :: Closed => {
586
- common_enums:: RefundStatus :: Success
587
- }
588
- JpmorganTransactionState :: Declined | JpmorganTransactionState :: Error => {
589
- common_enums:: RefundStatus :: Failure
590
- }
591
- JpmorganTransactionState :: Pending | JpmorganTransactionState :: Authorized => {
592
- common_enums:: RefundStatus :: Pending
593
- }
594
- } ,
595
- JpmorganResponseStatus :: Denied | JpmorganResponseStatus :: Error => {
596
- common_enums:: RefundStatus :: Failure
578
+ impl From < ( JpmorganResponseStatus , JpmorganTransactionState ) > for RefundStatus {
579
+ fn from (
580
+ ( response_status, transaction_state) : ( JpmorganResponseStatus , JpmorganTransactionState ) ,
581
+ ) -> Self {
582
+ match response_status {
583
+ JpmorganResponseStatus :: Success => match transaction_state {
584
+ JpmorganTransactionState :: Voided | JpmorganTransactionState :: Closed => {
585
+ Self :: Succeeded
586
+ }
587
+ JpmorganTransactionState :: Declined | JpmorganTransactionState :: Error => {
588
+ Self :: Failed
589
+ }
590
+ JpmorganTransactionState :: Pending | JpmorganTransactionState :: Authorized => {
591
+ Self :: Processing
592
+ }
593
+ } ,
594
+ JpmorganResponseStatus :: Denied | JpmorganResponseStatus :: Error => Self :: Failed ,
597
595
}
598
596
}
599
597
}
@@ -612,10 +610,11 @@ impl TryFrom<RefundsResponseRouterData<Execute, JpmorganRefundResponse>>
612
610
. transaction_id
613
611
. clone ( )
614
612
. ok_or ( errors:: ConnectorError :: ResponseHandlingFailed ) ?,
615
- refund_status : refund_status_from_transaction_state (
613
+ refund_status : RefundStatus :: from ( (
616
614
item. response . response_status ,
617
615
item. response . transaction_state ,
618
- ) ,
616
+ ) )
617
+ . into ( ) ,
619
618
} ) ,
620
619
..item. data
621
620
} )
@@ -644,10 +643,11 @@ impl TryFrom<RefundsResponseRouterData<RSync, JpmorganRefundSyncResponse>>
644
643
Ok ( Self {
645
644
response : Ok ( RefundsResponseData {
646
645
connector_refund_id : item. response . transaction_id . clone ( ) ,
647
- refund_status : refund_status_from_transaction_state (
646
+ refund_status : RefundStatus :: from ( (
648
647
item. response . response_status ,
649
648
item. response . transaction_state ,
650
- ) ,
649
+ ) )
650
+ . into ( ) ,
651
651
} ) ,
652
652
..item. data
653
653
} )
0 commit comments