mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 18:17:13 +08:00 
			
		
		
		
	feat(revert): populate payment method details in payments response (#5785)
This commit is contained in:
		| @ -4,10 +4,7 @@ use std::{borrow::Cow, str::FromStr}; | ||||
| use api_models::customers::CustomerRequestWithEmail; | ||||
| use api_models::{ | ||||
|     mandates::RecurringDetails, | ||||
|     payments::{ | ||||
|         additional_info as payment_additional_types, AddressDetailsWithPhone, | ||||
|         RequestSurchargeDetails, | ||||
|     }, | ||||
|     payments::{AddressDetailsWithPhone, RequestSurchargeDetails}, | ||||
| }; | ||||
| use base64::Engine; | ||||
| use common_enums::ConnectorType; | ||||
| @ -34,10 +31,7 @@ use hyperswitch_domain_models::{ | ||||
| }; | ||||
| use hyperswitch_interfaces::integrity::{CheckIntegrity, FlowIntegrity, GetIntegrityObject}; | ||||
| use josekit::jwe; | ||||
| use masking::{ | ||||
|     masked_string::{MaskedIban, MaskedSortCode}, | ||||
|     ExposeInterface, PeekInterface, | ||||
| }; | ||||
| use masking::{ExposeInterface, PeekInterface}; | ||||
| use openssl::{ | ||||
|     derive::Deriver, | ||||
|     pkey::PKey, | ||||
| @ -4000,67 +3994,16 @@ pub async fn get_additional_payment_data( | ||||
|             domain::BankRedirectData::Eps { bank_name, .. } => { | ||||
|                 Some(api_models::payments::AdditionalPaymentData::BankRedirect { | ||||
|                     bank_name: bank_name.to_owned(), | ||||
|                     additional_details: None, | ||||
|                 }) | ||||
|             } | ||||
|             domain::BankRedirectData::Ideal { bank_name, .. } => { | ||||
|                 Some(api_models::payments::AdditionalPaymentData::BankRedirect { | ||||
|                     bank_name: bank_name.to_owned(), | ||||
|                     additional_details: None, | ||||
|                 }) | ||||
|             } | ||||
|             domain::BankRedirectData::BancontactCard { | ||||
|                 card_number, | ||||
|                 card_exp_month, | ||||
|                 card_exp_year, | ||||
|             } => Some(api_models::payments::AdditionalPaymentData::BankRedirect { | ||||
|                 bank_name: None, | ||||
|                 additional_details: Some( | ||||
|                     payment_additional_types::BankRedirectDetails::BancontactCard(Box::new( | ||||
|                         payment_additional_types::BancontactBankRedirectAdditionalData { | ||||
|                             last4: card_number.as_ref().map(|c| c.get_last4()), | ||||
|                             card_exp_month: card_exp_month.clone(), | ||||
|                             card_exp_year: card_exp_year.clone(), | ||||
|                             card_holder_name: None, | ||||
|                         }, | ||||
|                     )), | ||||
|                 ), | ||||
|             }), | ||||
|             domain::BankRedirectData::Blik { blik_code } => { | ||||
|                 Some(api_models::payments::AdditionalPaymentData::BankRedirect { | ||||
|                     bank_name: None, | ||||
|                     additional_details: blik_code.as_ref().map(|blik_code| { | ||||
|                         payment_additional_types::BankRedirectDetails::Blik(Box::new( | ||||
|                             payment_additional_types::BlikBankRedirectAdditionalData { | ||||
|                                 blik_code: Some(blik_code.to_owned()), | ||||
|                             }, | ||||
|                         )) | ||||
|                     }), | ||||
|                 }) | ||||
|             _ => { | ||||
|                 Some(api_models::payments::AdditionalPaymentData::BankRedirect { bank_name: None }) | ||||
|             } | ||||
|             domain::BankRedirectData::Giropay { | ||||
|                 bank_account_bic, | ||||
|                 bank_account_iban, | ||||
|             } => Some(api_models::payments::AdditionalPaymentData::BankRedirect { | ||||
|                 bank_name: None, | ||||
|                 additional_details: Some(payment_additional_types::BankRedirectDetails::Giropay( | ||||
|                     Box::new( | ||||
|                         payment_additional_types::GiropayBankRedirectAdditionalData { | ||||
|                             bic: bank_account_bic.as_ref().map(|bic| { | ||||
|                                 masking::Secret::from(MaskedSortCode::from(bic.peek().to_owned())) | ||||
|                             }), | ||||
|                             iban: bank_account_iban.as_ref().map(|iban| { | ||||
|                                 masking::Secret::from(MaskedIban::from(iban.peek().to_owned())) | ||||
|                             }), | ||||
|                             country: None, | ||||
|                         }, | ||||
|                     ), | ||||
|                 )), | ||||
|             }), | ||||
|             _ => Some(api_models::payments::AdditionalPaymentData::BankRedirect { | ||||
|                 bank_name: None, | ||||
|                 additional_details: None, | ||||
|             }), | ||||
|         }, | ||||
|         domain::PaymentMethodData::Wallet(wallet) => match wallet { | ||||
|             domain::WalletData::ApplePay(apple_pay_wallet_data) => { | ||||
| @ -4077,49 +4020,41 @@ pub async fn get_additional_payment_data( | ||||
|         domain::PaymentMethodData::PayLater(_) => { | ||||
|             Some(api_models::payments::AdditionalPaymentData::PayLater { klarna_sdk: None }) | ||||
|         } | ||||
|         domain::PaymentMethodData::BankTransfer(bank_transfer) => { | ||||
|             Some(api_models::payments::AdditionalPaymentData::BankTransfer( | ||||
|                 (*(bank_transfer.to_owned())).into(), | ||||
|             )) | ||||
|         domain::PaymentMethodData::BankTransfer(_) => { | ||||
|             Some(api_models::payments::AdditionalPaymentData::BankTransfer {}) | ||||
|         } | ||||
|         domain::PaymentMethodData::Crypto(_) => { | ||||
|             Some(api_models::payments::AdditionalPaymentData::Crypto {}) | ||||
|         } | ||||
|         domain::PaymentMethodData::BankDebit(_) => { | ||||
|             Some(api_models::payments::AdditionalPaymentData::BankDebit {}) | ||||
|         } | ||||
|         domain::PaymentMethodData::Crypto(crypto) => Some( | ||||
|             api_models::payments::AdditionalPaymentData::Crypto(crypto.to_owned().into()), | ||||
|         ), | ||||
|         domain::PaymentMethodData::BankDebit(bank_debit) => Some( | ||||
|             api_models::payments::AdditionalPaymentData::BankDebit(bank_debit.to_owned().into()), | ||||
|         ), | ||||
|         domain::PaymentMethodData::MandatePayment => { | ||||
|             Some(api_models::payments::AdditionalPaymentData::MandatePayment {}) | ||||
|         } | ||||
|         domain::PaymentMethodData::Reward => { | ||||
|             Some(api_models::payments::AdditionalPaymentData::Reward {}) | ||||
|         } | ||||
|         domain::PaymentMethodData::RealTimePayment(realtime_payment) => Some( | ||||
|             api_models::payments::AdditionalPaymentData::RealTimePayment( | ||||
|                 (*(realtime_payment.to_owned())).into(), | ||||
|             ), | ||||
|         ), | ||||
|         domain::PaymentMethodData::Upi(upi) => Some( | ||||
|             api_models::payments::AdditionalPaymentData::Upi(upi.to_owned().into()), | ||||
|         ), | ||||
|         domain::PaymentMethodData::CardRedirect(card_redirect) => { | ||||
|             Some(api_models::payments::AdditionalPaymentData::CardRedirect( | ||||
|                 card_redirect.to_owned().into(), | ||||
|             )) | ||||
|         domain::PaymentMethodData::RealTimePayment(_) => { | ||||
|             Some(api_models::payments::AdditionalPaymentData::RealTimePayment {}) | ||||
|         } | ||||
|         domain::PaymentMethodData::Voucher(voucher) => Some( | ||||
|             api_models::payments::AdditionalPaymentData::Voucher(voucher.to_owned().into()), | ||||
|         ), | ||||
|         domain::PaymentMethodData::GiftCard(gift_card) => Some( | ||||
|             api_models::payments::AdditionalPaymentData::GiftCard((*(gift_card.to_owned())).into()), | ||||
|         ), | ||||
|         domain::PaymentMethodData::CardToken(card_token) => Some( | ||||
|             api_models::payments::AdditionalPaymentData::CardToken(card_token.to_owned().into()), | ||||
|         ), | ||||
|         domain::PaymentMethodData::OpenBanking(open_banking) => { | ||||
|             Some(api_models::payments::AdditionalPaymentData::OpenBanking( | ||||
|                 open_banking.to_owned().into(), | ||||
|             )) | ||||
|         domain::PaymentMethodData::Upi(_) => { | ||||
|             Some(api_models::payments::AdditionalPaymentData::Upi {}) | ||||
|         } | ||||
|         domain::PaymentMethodData::CardRedirect(_) => { | ||||
|             Some(api_models::payments::AdditionalPaymentData::CardRedirect {}) | ||||
|         } | ||||
|         domain::PaymentMethodData::Voucher(_) => { | ||||
|             Some(api_models::payments::AdditionalPaymentData::Voucher {}) | ||||
|         } | ||||
|         domain::PaymentMethodData::GiftCard(_) => { | ||||
|             Some(api_models::payments::AdditionalPaymentData::GiftCard {}) | ||||
|         } | ||||
|         domain::PaymentMethodData::CardToken(_) => { | ||||
|             Some(api_models::payments::AdditionalPaymentData::CardToken {}) | ||||
|         } | ||||
|         domain::PaymentMethodData::OpenBanking(_) => { | ||||
|             Some(api_models::payments::AdditionalPaymentData::OpenBanking {}) | ||||
|         } | ||||
|         domain::PaymentMethodData::NetworkToken(_) => None, | ||||
|     } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Sampras Lopes
					Sampras Lopes