mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-03 21:37:41 +08:00
feat(compatibility): [upi] add upi pm in compatibility layer, convert amount to base unit in iatapay (#1711)
Co-authored-by: arvindpatel24 <arvind.patel@juspay.in>
This commit is contained in:
@ -60,12 +60,18 @@ pub enum StripeWallet {
|
||||
ApplePay(payments::ApplePayWalletData),
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, PartialEq, Eq, Deserialize, Clone)]
|
||||
#[derive(Default, Serialize, PartialEq, Eq, Deserialize, Clone, Debug)]
|
||||
pub struct StripeUpi {
|
||||
pub vpa_id: masking::Secret<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Serialize, PartialEq, Eq, Deserialize, Clone)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum StripePaymentMethodType {
|
||||
#[default]
|
||||
Card,
|
||||
Wallet,
|
||||
Upi,
|
||||
}
|
||||
|
||||
impl From<StripePaymentMethodType> for api_enums::PaymentMethod {
|
||||
@ -73,6 +79,7 @@ impl From<StripePaymentMethodType> for api_enums::PaymentMethod {
|
||||
match item {
|
||||
StripePaymentMethodType::Card => Self::Card,
|
||||
StripePaymentMethodType::Wallet => Self::Wallet,
|
||||
StripePaymentMethodType::Upi => Self::Upi,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -92,6 +99,7 @@ pub struct StripePaymentMethodData {
|
||||
pub enum StripePaymentMethodDetails {
|
||||
Card(StripeCard),
|
||||
Wallet(StripeWallet),
|
||||
Upi(StripeUpi),
|
||||
}
|
||||
|
||||
impl From<StripeCard> for payments::Card {
|
||||
@ -120,6 +128,14 @@ impl From<StripeWallet> for payments::WalletData {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StripeUpi> for payments::UpiData {
|
||||
fn from(upi: StripeUpi) -> Self {
|
||||
Self {
|
||||
vpa_id: Some(upi.vpa_id),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StripePaymentMethodDetails> for payments::PaymentMethodData {
|
||||
fn from(item: StripePaymentMethodDetails) -> Self {
|
||||
match item {
|
||||
@ -127,6 +143,7 @@ impl From<StripePaymentMethodDetails> for payments::PaymentMethodData {
|
||||
StripePaymentMethodDetails::Wallet(wallet) => {
|
||||
Self::Wallet(payments::WalletData::from(wallet))
|
||||
}
|
||||
StripePaymentMethodDetails::Upi(upi) => Self::Upi(payments::UpiData::from(upi)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ use masking::Secret;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
connector::utils::{PaymentsAuthorizeRequestData, RefundsRequestData, RouterData},
|
||||
connector::utils::{self, PaymentsAuthorizeRequestData, RefundsRequestData, RouterData},
|
||||
core::errors,
|
||||
services,
|
||||
types::{self, api, storage::enums},
|
||||
@ -69,7 +69,7 @@ pub struct PayerInfo {
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct IatapayPaymentsRequest {
|
||||
merchant_id: String,
|
||||
amount: i64,
|
||||
amount: f64,
|
||||
currency: String,
|
||||
country: String,
|
||||
locale: String,
|
||||
@ -89,9 +89,11 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for IatapayPaymentsRequest {
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
let amount =
|
||||
utils::to_currency_base_unit_asf64(item.request.amount, item.request.currency)?;
|
||||
let payload = Self {
|
||||
merchant_id: IatapayAuthType::try_from(&item.connector_auth_type)?.merchant_id,
|
||||
amount: item.request.amount,
|
||||
amount,
|
||||
currency: item.request.currency.to_string(),
|
||||
country: country.clone(),
|
||||
locale: format!("en-{}", country),
|
||||
|
||||
Reference in New Issue
Block a user