@@ -9,8 +9,8 @@ use url::Url;
9
9
10
10
use crate :: {
11
11
connector:: utils:: {
12
- self , AddressDetailsData , BrowserInformationData , CardData , PaymentsAuthorizeRequestData ,
13
- RouterData ,
12
+ self , AddressDetailsData , BrowserInformationData , CardData ,
13
+ PaymentMethodTokenizationRequestData , PaymentsAuthorizeRequestData , RouterData ,
14
14
} ,
15
15
core:: errors,
16
16
services, types,
@@ -62,7 +62,7 @@ pub struct MolliePaymentsRequest {
62
62
locale : Option < String > ,
63
63
#[ serde( flatten) ]
64
64
payment_method_data : PaymentMethodData ,
65
- metadata : Option < serde_json :: Value > ,
65
+ metadata : Option < MollieMetadata > ,
66
66
sequence_type : SequenceType ,
67
67
mandate_id : Option < String > ,
68
68
}
@@ -148,8 +148,10 @@ pub struct Address {
148
148
pub country : api_models:: enums:: CountryAlpha2 ,
149
149
}
150
150
151
- pub struct MollieBrowserInfo {
152
- language : String ,
151
+ #[ derive( Debug , Serialize , Deserialize ) ]
152
+ #[ serde( rename_all = "camelCase" ) ]
153
+ pub struct MollieMetadata {
154
+ pub order_id : String ,
153
155
}
154
156
155
157
impl TryFrom < & MollieRouterData < & types:: PaymentsAuthorizeRouterData > > for MolliePaymentsRequest {
@@ -216,7 +218,9 @@ impl TryFrom<&MollieRouterData<&types::PaymentsAuthorizeRouterData>> for MollieP
216
218
webhook_url : "" . to_string ( ) ,
217
219
locale : None ,
218
220
payment_method_data,
219
- metadata : None ,
221
+ metadata : Some ( MollieMetadata {
222
+ order_id : item. router_data . connector_request_reference_id . clone ( ) ,
223
+ } ) ,
220
224
sequence_type : SequenceType :: Oneoff ,
221
225
mandate_id : None ,
222
226
} )
@@ -287,12 +291,7 @@ impl TryFrom<&types::TokenizationRouterData> for MollieCardTokenRequest {
287
291
let card_expiry_date =
288
292
ccard. get_card_expiry_month_year_2_digit_with_delimiter ( "/" . to_owned ( ) ) ;
289
293
let card_cvv = ccard. card_cvc ;
290
- let browser_info = get_browser_info ( item) ?;
291
- let locale = browser_info
292
- . ok_or ( errors:: ConnectorError :: MissingRequiredField {
293
- field_name : "browser_info.language" ,
294
- } ) ?
295
- . language ;
294
+ let locale = item. request . get_browser_info ( ) ?. get_language ( ) ?;
296
295
let testmode =
297
296
item. test_mode
298
297
. ok_or ( errors:: ConnectorError :: MissingRequiredField {
@@ -386,32 +385,14 @@ fn get_address_details(
386
385
Ok ( address_details)
387
386
}
388
387
389
- fn get_browser_info (
390
- item : & types:: TokenizationRouterData ,
391
- ) -> Result < Option < MollieBrowserInfo > , error_stack:: Report < errors:: ConnectorError > > {
392
- if matches ! ( item. auth_type, enums:: AuthenticationType :: ThreeDs ) {
393
- item. request
394
- . browser_info
395
- . as_ref ( )
396
- . map ( |info| {
397
- Ok ( MollieBrowserInfo {
398
- language : info. get_language ( ) ?,
399
- } )
400
- } )
401
- . transpose ( )
402
- } else {
403
- Ok ( None )
404
- }
405
- }
406
-
407
388
#[ derive( Debug , Deserialize ) ]
408
389
#[ serde( rename_all = "camelCase" ) ]
409
390
pub struct MolliePaymentsResponse {
410
391
pub resource : String ,
411
392
pub id : String ,
412
393
pub amount : Amount ,
413
394
pub description : Option < String > ,
414
- pub metadata : Option < serde_json :: Value > ,
395
+ pub metadata : Option < MollieMetadata > ,
415
396
pub status : MolliePaymentStatus ,
416
397
pub is_cancelable : Option < bool > ,
417
398
pub sequence_type : SequenceType ,
@@ -544,12 +525,12 @@ impl<F, T>
544
525
Ok ( Self {
545
526
status : enums:: AttemptStatus :: from ( item. response . status ) ,
546
527
response : Ok ( types:: PaymentsResponseData :: TransactionResponse {
547
- resource_id : types:: ResponseId :: ConnectorTransactionId ( item. response . id ) ,
528
+ resource_id : types:: ResponseId :: ConnectorTransactionId ( item. response . id . clone ( ) ) ,
548
529
redirection_data : url,
549
530
mandate_reference : None ,
550
531
connector_metadata : None ,
551
532
network_txn_id : None ,
552
- connector_response_reference_id : None ,
533
+ connector_response_reference_id : Some ( item . response . id ) ,
553
534
} ) ,
554
535
..item. data
555
536
} )
@@ -561,6 +542,7 @@ impl<F, T>
561
542
pub struct MollieRefundRequest {
562
543
amount : Amount ,
563
544
description : Option < String > ,
545
+ metadata : Option < MollieMetadata > ,
564
546
}
565
547
566
548
impl < F > TryFrom < & MollieRouterData < & types:: RefundsRouterData < F > > > for MollieRefundRequest {
@@ -575,6 +557,9 @@ impl<F> TryFrom<&MollieRouterData<&types::RefundsRouterData<F>>> for MollieRefun
575
557
Ok ( Self {
576
558
amount,
577
559
description : item. router_data . request . reason . to_owned ( ) ,
560
+ metadata : Some ( MollieMetadata {
561
+ order_id : item. router_data . request . refund_id . clone ( ) ,
562
+ } ) ,
578
563
} )
579
564
}
580
565
}
@@ -589,7 +574,7 @@ pub struct RefundResponse {
589
574
settlement_amount : Option < Amount > ,
590
575
status : MollieRefundStatus ,
591
576
description : Option < String > ,
592
- metadata : serde_json :: Value ,
577
+ metadata : Option < MollieMetadata > ,
593
578
payment_id : String ,
594
579
#[ serde( rename = "_links" ) ]
595
580
links : Links ,
@@ -642,6 +627,4 @@ pub struct ErrorResponse {
642
627
pub title : Option < String > ,
643
628
pub detail : String ,
644
629
pub field : Option < String > ,
645
- #[ serde( rename = "_links" ) ]
646
- pub links : Option < Links > ,
647
630
}
0 commit comments