@@ -211,37 +211,40 @@ impl
211
211
Some ( date) => date. chars ( ) . take ( 10 ) . collect ( ) ,
212
212
None => time:: OffsetDateTime :: now_utc ( ) . date ( ) . to_string ( ) ,
213
213
} ;
214
- Ok ( Self {
215
- status : if item. response . rc == "0" {
216
- match item. response . state {
217
- Some ( state) => common_enums:: AttemptStatus :: from ( state) ,
218
- None => common_enums:: AttemptStatus :: Failure ,
219
- }
220
- } else {
221
- common_enums:: AttemptStatus :: Failure
222
- } ,
223
- response : Ok ( PaymentsResponseData :: TransactionResponse {
224
- resource_id : ResponseId :: NoResponseId ,
225
- redirection_data : Some ( RedirectForm :: Form {
226
- endpoint : item. data . request . get_complete_authorize_url ( ) ?,
227
- method : common_utils:: request:: Method :: Get ,
228
- form_fields : HashMap :: from ( [
229
- (
230
- "reference" . to_string ( ) ,
231
- item. response . reference . unwrap_or ( "" . to_string ( ) ) ,
232
- ) ,
233
- ( "signed_on" . to_string ( ) , signed_on) ,
234
- ] ) ,
214
+ match item. response . reference {
215
+ Some ( reference) => Ok ( Self {
216
+ status : if item. response . rc == "0" {
217
+ match item. response . state {
218
+ Some ( state) => common_enums:: AttemptStatus :: from ( state) ,
219
+ None => common_enums:: AttemptStatus :: Failure ,
220
+ }
221
+ } else {
222
+ common_enums:: AttemptStatus :: Failure
223
+ } ,
224
+ response : Ok ( PaymentsResponseData :: TransactionResponse {
225
+ resource_id : ResponseId :: NoResponseId ,
226
+ redirection_data : Some ( RedirectForm :: Form {
227
+ endpoint : item. data . request . get_complete_authorize_url ( ) ?,
228
+ method : common_utils:: request:: Method :: Get ,
229
+ form_fields : HashMap :: from ( [
230
+ ( "reference" . to_string ( ) , reference) ,
231
+ ( "signed_on" . to_string ( ) , signed_on) ,
232
+ ] ) ,
233
+ } ) ,
234
+ mandate_reference : None ,
235
+ connector_metadata : None ,
236
+ network_txn_id : None ,
237
+ connector_response_reference_id : None ,
238
+ incremental_authorization_allowed : None ,
239
+ charge_id : None ,
235
240
} ) ,
236
- mandate_reference : None ,
237
- connector_metadata : None ,
238
- network_txn_id : None ,
239
- connector_response_reference_id : None ,
240
- incremental_authorization_allowed : None ,
241
- charge_id : None ,
241
+ ..item. data
242
242
} ) ,
243
- ..item. data
244
- } )
243
+ None => Ok ( Self {
244
+ status : common_enums:: AttemptStatus :: Failure ,
245
+ ..item. data
246
+ } ) ,
247
+ }
245
248
}
246
249
}
247
250
@@ -399,7 +402,7 @@ pub struct DeutschebankPaymentsResponse {
399
402
event_id : Option < String > ,
400
403
kind : Option < String > ,
401
404
tx_action : Option < DeutschebankTXAction > ,
402
- tx_id : Option < String > ,
405
+ tx_id : String ,
403
406
amount_total : Option < DeutschebankAmount > ,
404
407
transaction_info : Option < DeutschebankTransactionInfo > ,
405
408
}
@@ -423,11 +426,6 @@ impl
423
426
PaymentsResponseData ,
424
427
> ,
425
428
) -> Result < Self , Self :: Error > {
426
- let resource_id = ResponseId :: ConnectorTransactionId (
427
- item. response
428
- . tx_id
429
- . ok_or ( errors:: ConnectorError :: MissingConnectorTransactionID ) ?,
430
- ) ;
431
429
Ok ( Self {
432
430
status : if item. response . rc == "0" {
433
431
match item. data . request . is_auto_capture ( ) ? {
438
436
common_enums:: AttemptStatus :: Failure
439
437
} ,
440
438
response : Ok ( PaymentsResponseData :: TransactionResponse {
441
- resource_id,
439
+ resource_id : ResponseId :: ConnectorTransactionId ( item . response . tx_id ) ,
442
440
redirection_data : None ,
443
441
mandate_reference : None ,
444
442
connector_metadata : None ,
@@ -452,10 +450,16 @@ impl
452
450
}
453
451
}
454
452
453
+ #[ derive( Debug , Serialize , PartialEq ) ]
454
+ #[ serde( rename_all = "UPPERCASE" ) ]
455
+ pub enum DeutschebankTransactionKind {
456
+ Directdebit ,
457
+ }
458
+
455
459
#[ derive( Debug , Serialize , PartialEq ) ]
456
460
pub struct DeutschebankCaptureRequest {
457
461
changed_amount : MinorUnit ,
458
- kind : String ,
462
+ kind : DeutschebankTransactionKind ,
459
463
}
460
464
461
465
impl TryFrom < & DeutschebankRouterData < & PaymentsCaptureRouterData > > for DeutschebankCaptureRequest {
@@ -465,7 +469,7 @@ impl TryFrom<&DeutschebankRouterData<&PaymentsCaptureRouterData>> for Deutscheba
465
469
) -> Result < Self , Self :: Error > {
466
470
Ok ( Self {
467
471
changed_amount : item. amount ,
468
- kind : "DIRECTDEBIT" . to_string ( ) ,
472
+ kind : DeutschebankTransactionKind :: Directdebit ,
469
473
} )
470
474
}
471
475
}
@@ -489,14 +493,9 @@ impl
489
493
PaymentsResponseData ,
490
494
> ,
491
495
) -> Result < Self , Self :: Error > {
492
- let resource_id = ResponseId :: ConnectorTransactionId (
493
- item. response
494
- . tx_id
495
- . ok_or ( errors:: ConnectorError :: MissingConnectorTransactionID ) ?,
496
- ) ;
497
496
Ok ( Self {
498
497
response : Ok ( PaymentsResponseData :: TransactionResponse {
499
- resource_id,
498
+ resource_id : ResponseId :: ConnectorTransactionId ( item . response . tx_id ) ,
500
499
redirection_data : None ,
501
500
mandate_reference : None ,
502
501
connector_metadata : None ,
@@ -565,16 +564,16 @@ impl
565
564
}
566
565
}
567
566
568
- #[ derive( Default , Debug , Serialize ) ]
567
+ #[ derive( Debug , Serialize ) ]
569
568
pub struct DeutschebankReversalRequest {
570
- kind : String ,
569
+ kind : DeutschebankTransactionKind ,
571
570
}
572
571
573
572
impl TryFrom < & PaymentsCancelRouterData > for DeutschebankReversalRequest {
574
573
type Error = error_stack:: Report < errors:: ConnectorError > ;
575
574
fn try_from ( _item : & PaymentsCancelRouterData ) -> Result < Self , Self :: Error > {
576
575
Ok ( Self {
577
- kind : "DIRECTDEBIT" . to_string ( ) ,
576
+ kind : DeutschebankTransactionKind :: Directdebit ,
578
577
} )
579
578
}
580
579
}
@@ -597,18 +596,18 @@ impl TryFrom<PaymentsCancelResponseRouterData<DeutschebankPaymentsResponse>>
597
596
}
598
597
}
599
598
600
- #[ derive( Default , Debug , Serialize ) ]
599
+ #[ derive( Debug , Serialize ) ]
601
600
pub struct DeutschebankRefundRequest {
602
601
changed_amount : MinorUnit ,
603
- kind : String ,
602
+ kind : DeutschebankTransactionKind ,
604
603
}
605
604
606
605
impl < F > TryFrom < & DeutschebankRouterData < & RefundsRouterData < F > > > for DeutschebankRefundRequest {
607
606
type Error = error_stack:: Report < errors:: ConnectorError > ;
608
607
fn try_from ( item : & DeutschebankRouterData < & RefundsRouterData < F > > ) -> Result < Self , Self :: Error > {
609
608
Ok ( Self {
610
609
changed_amount : item. amount . to_owned ( ) ,
611
- kind : "DIRECTDEBIT" . to_string ( ) ,
610
+ kind : DeutschebankTransactionKind :: Directdebit ,
612
611
} )
613
612
}
614
613
}
@@ -620,13 +619,9 @@ impl TryFrom<RefundsResponseRouterData<Execute, DeutschebankPaymentsResponse>>
620
619
fn try_from (
621
620
item : RefundsResponseRouterData < Execute , DeutschebankPaymentsResponse > ,
622
621
) -> Result < Self , Self :: Error > {
623
- let connector_refund_id = item
624
- . response
625
- . tx_id
626
- . ok_or ( errors:: ConnectorError :: MissingConnectorRefundID ) ?;
627
622
Ok ( Self {
628
623
response : Ok ( RefundsResponseData {
629
- connector_refund_id,
624
+ connector_refund_id : item . response . tx_id ,
630
625
refund_status : if item. response . rc == "0" {
631
626
enums:: RefundStatus :: Success
632
627
} else {
0 commit comments