mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 11:06:50 +08:00
feat(payment_method): [upi] add new payment method and use in iatapay (#1528)
Co-authored-by: arvindpatel24 <arvind.patel@juspay.in>
This commit is contained in:
@ -370,7 +370,8 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for AciPaymentsRequest {
|
||||
api::PaymentMethodData::Crypto(_)
|
||||
| api::PaymentMethodData::BankDebit(_)
|
||||
| api::PaymentMethodData::BankTransfer(_)
|
||||
| api::PaymentMethodData::Reward(_) => Err(errors::ConnectorError::NotSupported {
|
||||
| api::PaymentMethodData::Reward(_)
|
||||
| api::PaymentMethodData::Upi(_) => Err(errors::ConnectorError::NotSupported {
|
||||
message: format!("{:?}", item.payment_method),
|
||||
connector: "Aci",
|
||||
payment_experience: api_models::enums::PaymentExperience::RedirectToUrl.to_string(),
|
||||
|
||||
@ -140,7 +140,8 @@ fn get_pm_and_subsequent_auth_detail(
|
||||
| api::PaymentMethodData::BankDebit(_)
|
||||
| api::PaymentMethodData::MandatePayment
|
||||
| api::PaymentMethodData::BankTransfer(_)
|
||||
| api::PaymentMethodData::Reward(_) => Err(errors::ConnectorError::NotSupported {
|
||||
| api::PaymentMethodData::Reward(_)
|
||||
| api::PaymentMethodData::Upi(_) => Err(errors::ConnectorError::NotSupported {
|
||||
message: format!("{:?}", item.request.payment_method_data),
|
||||
connector: "AuthorizeDotNet",
|
||||
payment_experience: api_models::enums::PaymentExperience::RedirectToUrl.to_string(),
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use masking::Secret;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
@ -58,6 +59,12 @@ pub struct RedirectUrls {
|
||||
failure_url: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PayerInfo {
|
||||
token_id: Secret<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct IatapayPaymentsRequest {
|
||||
@ -68,6 +75,7 @@ pub struct IatapayPaymentsRequest {
|
||||
locale: String,
|
||||
redirect_urls: RedirectUrls,
|
||||
notification_url: String,
|
||||
payer_info: Option<PayerInfo>,
|
||||
}
|
||||
|
||||
impl TryFrom<&types::PaymentsAuthorizeRouterData> for IatapayPaymentsRequest {
|
||||
@ -75,6 +83,12 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for IatapayPaymentsRequest {
|
||||
fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result<Self, Self::Error> {
|
||||
let country = item.get_billing_country()?.to_string();
|
||||
let return_url = item.get_return_url()?;
|
||||
let payer_info = match item.request.payment_method_data.clone() {
|
||||
api::PaymentMethodData::Upi(upi_data) => {
|
||||
upi_data.vpa_id.map(|id| PayerInfo { token_id: id })
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
let payload = Self {
|
||||
merchant_id: IatapayAuthType::try_from(&item.connector_auth_type)?.merchant_id,
|
||||
amount: item.request.amount,
|
||||
@ -82,6 +96,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for IatapayPaymentsRequest {
|
||||
country: country.clone(),
|
||||
locale: format!("en-{}", country),
|
||||
redirect_urls: get_redirect_url(return_url),
|
||||
payer_info,
|
||||
notification_url: item.request.get_webhook_url()?,
|
||||
};
|
||||
Ok(payload)
|
||||
|
||||
@ -2574,7 +2574,8 @@ impl
|
||||
}
|
||||
api::PaymentMethodData::MandatePayment
|
||||
| api::PaymentMethodData::Crypto(_)
|
||||
| api::PaymentMethodData::Reward(_) => Err(errors::ConnectorError::NotSupported {
|
||||
| api::PaymentMethodData::Reward(_)
|
||||
| api::PaymentMethodData::Upi(_) => Err(errors::ConnectorError::NotSupported {
|
||||
message: format!("{pm_type:?}"),
|
||||
connector: "Stripe",
|
||||
payment_experience: api_models::enums::PaymentExperience::RedirectToUrl.to_string(),
|
||||
|
||||
@ -1271,6 +1271,7 @@ pub async fn make_pm_data<'a, F: Clone, R>(
|
||||
(pm @ Some(api::PaymentMethodData::BankRedirect(_)), _) => Ok(pm.to_owned()),
|
||||
(pm @ Some(api::PaymentMethodData::Crypto(_)), _) => Ok(pm.to_owned()),
|
||||
(pm @ Some(api::PaymentMethodData::BankDebit(_)), _) => Ok(pm.to_owned()),
|
||||
(pm @ Some(api::PaymentMethodData::Upi(_)), _) => Ok(pm.to_owned()),
|
||||
(pm @ Some(api::PaymentMethodData::Reward(_)), _) => Ok(pm.to_owned()),
|
||||
(pm_opt @ Some(pm @ api::PaymentMethodData::BankTransfer(_)), _) => {
|
||||
let token = vault::Vault::store_payment_method_data_in_locker(
|
||||
|
||||
@ -170,6 +170,7 @@ Never share your secret api keys. Keep them guarded and secure.
|
||||
api_models::payments::BankDebitBilling,
|
||||
api_models::payments::CryptoData,
|
||||
api_models::payments::RewardData,
|
||||
api_models::payments::UpiData,
|
||||
api_models::payments::Address,
|
||||
api_models::payments::BankRedirectData,
|
||||
api_models::payments::BankRedirectBilling,
|
||||
|
||||
Reference in New Issue
Block a user