@@ -19,7 +19,7 @@ use utoipa::{schema, ToSchema};
19
19
#[ cfg( feature = "payouts" ) ]
20
20
use crate :: payouts;
21
21
use crate :: {
22
- admin, customers , enums as api_enums,
22
+ admin, enums as api_enums,
23
23
payments:: { self , BankCodeResponse } ,
24
24
} ;
25
25
@@ -2500,6 +2500,7 @@ pub struct PaymentMethodRecord {
2500
2500
pub billing_address_line3 : Option < masking:: Secret < String > > ,
2501
2501
pub raw_card_number : Option < masking:: Secret < String > > ,
2502
2502
pub merchant_connector_id : Option < id_type:: MerchantConnectorAccountId > ,
2503
+ pub merchant_connector_ids : Option < String > ,
2503
2504
pub original_transaction_amount : Option < i64 > ,
2504
2505
pub original_transaction_currency : Option < common_enums:: Currency > ,
2505
2506
pub line_number : Option < i64 > ,
@@ -2509,18 +2510,6 @@ pub struct PaymentMethodRecord {
2509
2510
pub network_token_requestor_ref_id : Option < String > ,
2510
2511
}
2511
2512
2512
- #[ derive( Debug , Clone , serde:: Deserialize , serde:: Serialize ) ]
2513
- pub struct ConnectorCustomerDetails {
2514
- pub connector_customer_id : String ,
2515
- pub merchant_connector_id : id_type:: MerchantConnectorAccountId ,
2516
- }
2517
-
2518
- #[ derive( Debug , Clone , serde:: Deserialize , serde:: Serialize ) ]
2519
- pub struct PaymentMethodCustomerMigrate {
2520
- pub customer : customers:: CustomerRequest ,
2521
- pub connector_customer_details : Option < ConnectorCustomerDetails > ,
2522
- }
2523
-
2524
2513
#[ derive( Debug , Default , serde:: Serialize ) ]
2525
2514
pub struct PaymentMethodMigrationResponse {
2526
2515
pub line_number : Option < i64 > ,
@@ -2637,47 +2626,56 @@ impl From<PaymentMethodMigrationResponseType> for PaymentMethodMigrationResponse
2637
2626
2638
2627
impl
2639
2628
TryFrom < (
2640
- PaymentMethodRecord ,
2629
+ & PaymentMethodRecord ,
2641
2630
id_type:: MerchantId ,
2642
- Option < id_type:: MerchantConnectorAccountId > ,
2631
+ Option < & Vec < id_type:: MerchantConnectorAccountId > > ,
2643
2632
) > for PaymentMethodMigrate
2644
2633
{
2645
2634
type Error = error_stack:: Report < errors:: ValidationError > ;
2635
+
2646
2636
fn try_from (
2647
2637
item : (
2648
- PaymentMethodRecord ,
2638
+ & PaymentMethodRecord ,
2649
2639
id_type:: MerchantId ,
2650
- Option < id_type:: MerchantConnectorAccountId > ,
2640
+ Option < & Vec < id_type:: MerchantConnectorAccountId > > ,
2651
2641
) ,
2652
2642
) -> Result < Self , Self :: Error > {
2653
- let ( record, merchant_id, mca_id ) = item;
2643
+ let ( record, merchant_id, mca_ids ) = item;
2654
2644
let billing = record. create_billing ( ) ;
2655
-
2656
- // if payment instrument id is present then only construct this
2657
- let connector_mandate_details = if record. payment_instrument_id . is_some ( ) {
2658
- Some ( PaymentsMandateReference ( HashMap :: from ( [ (
2659
- mca_id. get_required_value ( "merchant_connector_id" ) ?,
2660
- PaymentsMandateReferenceRecord {
2661
- connector_mandate_id : record
2662
- . payment_instrument_id
2663
- . get_required_value ( "payment_instrument_id" ) ?
2664
- . peek ( )
2665
- . to_string ( ) ,
2666
- payment_method_type : record. payment_method_type ,
2667
- original_payment_authorized_amount : record. original_transaction_amount ,
2668
- original_payment_authorized_currency : record. original_transaction_currency ,
2669
- } ,
2670
- ) ] ) ) )
2645
+ let connector_mandate_details = if let Some ( payment_instrument_id) =
2646
+ & record. payment_instrument_id
2647
+ {
2648
+ let ids = mca_ids. get_required_value ( "mca_ids" ) ?;
2649
+ let mandate_map: HashMap < _ , _ > = ids
2650
+ . iter ( )
2651
+ . map ( |mca_id| {
2652
+ (
2653
+ mca_id. clone ( ) ,
2654
+ PaymentsMandateReferenceRecord {
2655
+ connector_mandate_id : payment_instrument_id. peek ( ) . to_string ( ) ,
2656
+ payment_method_type : record. payment_method_type ,
2657
+ original_payment_authorized_amount : record. original_transaction_amount ,
2658
+ original_payment_authorized_currency : record
2659
+ . original_transaction_currency ,
2660
+ } ,
2661
+ )
2662
+ } )
2663
+ . collect ( ) ;
2664
+ Some ( PaymentsMandateReference ( mandate_map) )
2671
2665
} else {
2672
2666
None
2673
2667
} ;
2668
+
2674
2669
Ok ( Self {
2675
2670
merchant_id,
2676
- customer_id : Some ( record. customer_id ) ,
2671
+ customer_id : Some ( record. customer_id . clone ( ) ) ,
2677
2672
card : Some ( MigrateCardDetail {
2678
- card_number : record. raw_card_number . unwrap_or ( record. card_number_masked ) ,
2679
- card_exp_month : record. card_expiry_month ,
2680
- card_exp_year : record. card_expiry_year ,
2673
+ card_number : record
2674
+ . raw_card_number
2675
+ . clone ( )
2676
+ . unwrap_or_else ( || record. card_number_masked . clone ( ) ) ,
2677
+ card_exp_month : record. card_expiry_month . clone ( ) ,
2678
+ card_exp_year : record. card_expiry_year . clone ( ) ,
2681
2679
card_holder_name : record. name . clone ( ) ,
2682
2680
card_network : None ,
2683
2681
card_type : None ,
@@ -2687,10 +2685,16 @@ impl
2687
2685
} ) ,
2688
2686
network_token : Some ( MigrateNetworkTokenDetail {
2689
2687
network_token_data : MigrateNetworkTokenData {
2690
- network_token_number : record. network_token_number . unwrap_or_default ( ) ,
2691
- network_token_exp_month : record. network_token_expiry_month . unwrap_or_default ( ) ,
2692
- network_token_exp_year : record. network_token_expiry_year . unwrap_or_default ( ) ,
2693
- card_holder_name : record. name ,
2688
+ network_token_number : record. network_token_number . clone ( ) . unwrap_or_default ( ) ,
2689
+ network_token_exp_month : record
2690
+ . network_token_expiry_month
2691
+ . clone ( )
2692
+ . unwrap_or_default ( ) ,
2693
+ network_token_exp_year : record
2694
+ . network_token_expiry_year
2695
+ . clone ( )
2696
+ . unwrap_or_default ( ) ,
2697
+ card_holder_name : record. name . clone ( ) ,
2694
2698
nick_name : record. nick_name . clone ( ) ,
2695
2699
card_issuing_country : None ,
2696
2700
card_network : None ,
@@ -2699,6 +2703,7 @@ impl
2699
2703
} ,
2700
2704
network_token_requestor_ref_id : record
2701
2705
. network_token_requestor_ref_id
2706
+ . clone ( )
2702
2707
. unwrap_or_default ( ) ,
2703
2708
} ) ,
2704
2709
payment_method : record. payment_method ,
@@ -2723,45 +2728,6 @@ impl
2723
2728
}
2724
2729
}
2725
2730
2726
- #[ cfg( feature = "v1" ) ]
2727
- impl From < ( PaymentMethodRecord , id_type:: MerchantId ) > for PaymentMethodCustomerMigrate {
2728
- fn from ( value : ( PaymentMethodRecord , id_type:: MerchantId ) ) -> Self {
2729
- let ( record, merchant_id) = value;
2730
- Self {
2731
- customer : customers:: CustomerRequest {
2732
- customer_id : Some ( record. customer_id ) ,
2733
- merchant_id,
2734
- name : record. name ,
2735
- email : record. email ,
2736
- phone : record. phone ,
2737
- description : None ,
2738
- phone_country_code : record. phone_country_code ,
2739
- address : Some ( payments:: AddressDetails {
2740
- city : record. billing_address_city ,
2741
- country : record. billing_address_country ,
2742
- line1 : record. billing_address_line1 ,
2743
- line2 : record. billing_address_line2 ,
2744
- state : record. billing_address_state ,
2745
- line3 : record. billing_address_line3 ,
2746
- zip : record. billing_address_zip ,
2747
- first_name : record. billing_address_first_name ,
2748
- last_name : record. billing_address_last_name ,
2749
- } ) ,
2750
- metadata : None ,
2751
- } ,
2752
- connector_customer_details : record
2753
- . connector_customer_id
2754
- . zip ( record. merchant_connector_id )
2755
- . map (
2756
- |( connector_customer_id, merchant_connector_id) | ConnectorCustomerDetails {
2757
- connector_customer_id,
2758
- merchant_connector_id,
2759
- } ,
2760
- ) ,
2761
- }
2762
- }
2763
- }
2764
-
2765
2731
#[ derive( Debug , serde:: Deserialize , serde:: Serialize , ToSchema ) ]
2766
2732
pub struct CardNetworkTokenizeRequest {
2767
2733
/// Merchant ID associated with the tokenization request
0 commit comments