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),
|
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")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum StripePaymentMethodType {
|
pub enum StripePaymentMethodType {
|
||||||
#[default]
|
#[default]
|
||||||
Card,
|
Card,
|
||||||
Wallet,
|
Wallet,
|
||||||
|
Upi,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<StripePaymentMethodType> for api_enums::PaymentMethod {
|
impl From<StripePaymentMethodType> for api_enums::PaymentMethod {
|
||||||
@ -73,6 +79,7 @@ impl From<StripePaymentMethodType> for api_enums::PaymentMethod {
|
|||||||
match item {
|
match item {
|
||||||
StripePaymentMethodType::Card => Self::Card,
|
StripePaymentMethodType::Card => Self::Card,
|
||||||
StripePaymentMethodType::Wallet => Self::Wallet,
|
StripePaymentMethodType::Wallet => Self::Wallet,
|
||||||
|
StripePaymentMethodType::Upi => Self::Upi,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,6 +99,7 @@ pub struct StripePaymentMethodData {
|
|||||||
pub enum StripePaymentMethodDetails {
|
pub enum StripePaymentMethodDetails {
|
||||||
Card(StripeCard),
|
Card(StripeCard),
|
||||||
Wallet(StripeWallet),
|
Wallet(StripeWallet),
|
||||||
|
Upi(StripeUpi),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<StripeCard> for payments::Card {
|
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 {
|
impl From<StripePaymentMethodDetails> for payments::PaymentMethodData {
|
||||||
fn from(item: StripePaymentMethodDetails) -> Self {
|
fn from(item: StripePaymentMethodDetails) -> Self {
|
||||||
match item {
|
match item {
|
||||||
@ -127,6 +143,7 @@ impl From<StripePaymentMethodDetails> for payments::PaymentMethodData {
|
|||||||
StripePaymentMethodDetails::Wallet(wallet) => {
|
StripePaymentMethodDetails::Wallet(wallet) => {
|
||||||
Self::Wallet(payments::WalletData::from(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 serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
connector::utils::{PaymentsAuthorizeRequestData, RefundsRequestData, RouterData},
|
connector::utils::{self, PaymentsAuthorizeRequestData, RefundsRequestData, RouterData},
|
||||||
core::errors,
|
core::errors,
|
||||||
services,
|
services,
|
||||||
types::{self, api, storage::enums},
|
types::{self, api, storage::enums},
|
||||||
@ -69,7 +69,7 @@ pub struct PayerInfo {
|
|||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct IatapayPaymentsRequest {
|
pub struct IatapayPaymentsRequest {
|
||||||
merchant_id: String,
|
merchant_id: String,
|
||||||
amount: i64,
|
amount: f64,
|
||||||
currency: String,
|
currency: String,
|
||||||
country: String,
|
country: String,
|
||||||
locale: String,
|
locale: String,
|
||||||
@ -89,9 +89,11 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for IatapayPaymentsRequest {
|
|||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
let amount =
|
||||||
|
utils::to_currency_base_unit_asf64(item.request.amount, item.request.currency)?;
|
||||||
let payload = Self {
|
let payload = Self {
|
||||||
merchant_id: IatapayAuthType::try_from(&item.connector_auth_type)?.merchant_id,
|
merchant_id: IatapayAuthType::try_from(&item.connector_auth_type)?.merchant_id,
|
||||||
amount: item.request.amount,
|
amount,
|
||||||
currency: item.request.currency.to_string(),
|
currency: item.request.currency.to_string(),
|
||||||
country: country.clone(),
|
country: country.clone(),
|
||||||
locale: format!("en-{}", country),
|
locale: format!("en-{}", country),
|
||||||
|
|||||||
Reference in New Issue
Block a user