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:
Arvind Patel
2023-06-30 19:54:35 +05:30
committed by GitHub
parent 88860b9c0b
commit 2d11bf5b3a
10 changed files with 309 additions and 210 deletions

View File

@ -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(),

View File

@ -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(),

View File

@ -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)

View File

@ -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(),

View File

@ -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(

View File

@ -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,