feat(connector): [Iatapay] add upi qr support (#4728)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: SamraatBansal <55536657+SamraatBansal@users.noreply.github.com>
This commit is contained in:
AkshayaFoiger
2024-05-28 13:06:53 +05:30
committed by GitHub
parent d15cb31814
commit c9fa94febe
22 changed files with 257 additions and 65 deletions

View File

@ -141,10 +141,10 @@ impl From<StripeWallet> for payments::WalletData {
}
impl From<StripeUpi> for payments::UpiData {
fn from(upi: StripeUpi) -> Self {
Self {
vpa_id: Some(upi.vpa_id),
}
fn from(upi_data: StripeUpi) -> Self {
Self::UpiCollect(payments::UpiCollectData {
vpa_id: Some(upi_data.vpa_id),
})
}
}
@ -315,6 +315,18 @@ impl TryFrom<StripePaymentIntentRequest> for payments::PaymentsRequest {
let amount = item.amount.map(|amount| MinorUnit::new(amount).into());
let payment_method_data = item.payment_method_data.as_ref().map(|pmd| {
let payment_method_data = match pmd.payment_method_details.as_ref() {
Some(spmd) => Some(payments::PaymentMethodData::from(spmd.to_owned())),
None => get_pmd_based_on_payment_method_type(item.payment_method_types),
};
payments::PaymentMethodDataRequest {
payment_method_data,
billing: pmd.billing_details.clone().map(payments::Address::from),
}
});
let request = Ok(Self {
payment_id: item.id.map(payments::PaymentIdType::PaymentIntentId),
amount,
@ -334,16 +346,7 @@ impl TryFrom<StripePaymentIntentRequest> for payments::PaymentsRequest {
phone: item.shipping.as_ref().and_then(|s| s.phone.clone()),
description: item.description,
return_url: item.return_url,
payment_method_data: item.payment_method_data.as_ref().and_then(|pmd| {
pmd.payment_method_details
.as_ref()
.map(|spmd| payments::PaymentMethodDataRequest {
payment_method_data: Some(payments::PaymentMethodData::from(
spmd.to_owned(),
)),
billing: pmd.billing_details.clone().map(payments::Address::from),
})
}),
payment_method_data,
payment_method: item
.payment_method_data
.as_ref()
@ -816,6 +819,9 @@ pub enum StripeNextAction {
display_to_timestamp: Option<i64>,
qr_code_url: Option<url::Url>,
},
FetchQrCodeInformation {
qr_code_fetch_url: url::Url,
},
DisplayVoucherInformation {
voucher_details: payments::VoucherNextStepData,
},
@ -858,6 +864,9 @@ pub(crate) fn into_stripe_next_action(
display_to_timestamp,
qr_code_url,
},
payments::NextActionData::FetchQrCodeInformation { qr_code_fetch_url } => {
StripeNextAction::FetchQrCodeInformation { qr_code_fetch_url }
}
payments::NextActionData::DisplayVoucherInformation { voucher_details } => {
StripeNextAction::DisplayVoucherInformation { voucher_details }
}
@ -884,3 +893,15 @@ pub(crate) fn into_stripe_next_action(
pub struct StripePaymentRetrieveBody {
pub client_secret: Option<String>,
}
//To handle payment types that have empty payment method data
fn get_pmd_based_on_payment_method_type(
payment_method_type: Option<api_enums::PaymentMethodType>,
) -> Option<payments::PaymentMethodData> {
match payment_method_type {
Some(api_enums::PaymentMethodType::UpiIntent) => Some(payments::PaymentMethodData::Upi(
payments::UpiData::UpiIntent(payments::UpiIntentData {}),
)),
_ => None,
}
}

View File

@ -382,6 +382,9 @@ pub enum StripeNextAction {
display_to_timestamp: Option<i64>,
qr_code_url: Option<url::Url>,
},
FetchQrCodeInformation {
qr_code_fetch_url: url::Url,
},
DisplayVoucherInformation {
voucher_details: payments::VoucherNextStepData,
},
@ -424,6 +427,9 @@ pub(crate) fn into_stripe_next_action(
display_to_timestamp,
qr_code_url,
},
payments::NextActionData::FetchQrCodeInformation { qr_code_fetch_url } => {
StripeNextAction::FetchQrCodeInformation { qr_code_fetch_url }
}
payments::NextActionData::DisplayVoucherInformation { voucher_details } => {
StripeNextAction::DisplayVoucherInformation { voucher_details }
}