From ee1c674336b2aae2215c77ff0f7a6e15c552733d Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Wed, 22 May 2024 14:48:29 +0530 Subject: [PATCH 01/17] add qr data --- crates/api_models/src/payments.rs | 26 +- crates/common_enums/src/enums.rs | 1 + crates/common_enums/src/transformers.rs | 1 + crates/euclid/src/frontend/dir/enums.rs | 1 + crates/euclid/src/frontend/dir/lowering.rs | 1 + .../euclid/src/frontend/dir/transformers.rs | 1 + crates/kgraph_utils/src/transformers.rs | 1 + .../stripe/payment_intents/types.rs | 12 +- .../stripe/setup_intents/types.rs | 3 + crates/router/src/connector/adyen.rs | 3 +- crates/router/src/connector/iatapay.rs | 94 +++++- .../src/connector/iatapay/transformers.rs | 280 ++++++++++++++---- crates/router/src/connector/klarna.rs | 1 + .../src/connector/stripe/transformers.rs | 1 + crates/router/src/core/payments/flows.rs | 1 - .../src/core/payments/flows/authorize_flow.rs | 1 + crates/router/src/core/payments/helpers.rs | 6 +- .../router/src/core/payments/transformers.rs | 13 + crates/router/src/types/domain/payments.rs | 18 +- crates/router/src/types/transformers.rs | 4 +- 20 files changed, 402 insertions(+), 67 deletions(-) diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index f00be78a039..56e2487432d 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -1640,7 +1640,10 @@ impl GetPaymentMethodType for CryptoData { impl GetPaymentMethodType for UpiData { fn get_payment_method_type(&self) -> api_enums::PaymentMethodType { - api_enums::PaymentMethodType::UpiCollect + match self { + UpiData::Upi(_) => api_enums::PaymentMethodType::UpiCollect, + UpiData::UpiQr(_) => api_enums::PaymentMethodType::UpiIntent, + } } } impl GetPaymentMethodType for VoucherData { @@ -2093,13 +2096,22 @@ pub struct CryptoData { pub pay_currency: Option, } -#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)] +#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)] #[serde(rename_all = "snake_case")] -pub struct UpiData { - #[schema(value_type = Option, example = "successtest@iata")] +pub enum UpiData { + Upi(Upi), + UpiQr(UpiQr), +} + +#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(rename_all = "snake_case")] +pub struct Upi { pub vpa_id: Option>, } +#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)] +pub struct UpiQr {} + #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)] pub struct SofortBilling { /// The country associated with the billing @@ -2930,6 +2942,7 @@ pub enum NextActionData { #[schema(value_type = String)] /// The url for Qr code given by the connector qr_code_url: Option, + qr_code_data: Option, }, /// Contains the download url and the reference number for transaction DisplayVoucherInformation { @@ -2999,6 +3012,11 @@ pub enum QrCodeInformation { qr_code_url: Url, display_to_timestamp: Option, }, + QrCodeData { + qr_code_url: Url, + qr_code_data: String, + display_to_timestamp: Option, + }, } #[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)] diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index dc4ca6b2cb3..3df291d5681 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -1430,6 +1430,7 @@ pub enum PaymentMethodType { Trustly, Twint, UpiCollect, + UpiIntent, Vipps, Venmo, Walley, diff --git a/crates/common_enums/src/transformers.rs b/crates/common_enums/src/transformers.rs index faca2579c0a..cb37180c987 100644 --- a/crates/common_enums/src/transformers.rs +++ b/crates/common_enums/src/transformers.rs @@ -1854,6 +1854,7 @@ impl From for PaymentMethod { PaymentMethodType::Trustly => Self::BankRedirect, PaymentMethodType::Twint => Self::Wallet, PaymentMethodType::UpiCollect => Self::Upi, + PaymentMethodType::UpiIntent => Self::Upi, PaymentMethodType::Vipps => Self::Wallet, PaymentMethodType::Venmo => Self::Wallet, PaymentMethodType::Walley => Self::PayLater, diff --git a/crates/euclid/src/frontend/dir/enums.rs b/crates/euclid/src/frontend/dir/enums.rs index 941fc9d7465..87e10253006 100644 --- a/crates/euclid/src/frontend/dir/enums.rs +++ b/crates/euclid/src/frontend/dir/enums.rs @@ -268,6 +268,7 @@ pub enum CryptoType { #[strum(serialize_all = "snake_case")] pub enum UpiType { UpiCollect, + UpiIntent, } #[derive( diff --git a/crates/euclid/src/frontend/dir/lowering.rs b/crates/euclid/src/frontend/dir/lowering.rs index f6b156bf909..cc4c9be2a2d 100644 --- a/crates/euclid/src/frontend/dir/lowering.rs +++ b/crates/euclid/src/frontend/dir/lowering.rs @@ -75,6 +75,7 @@ impl From for global_enums::PaymentMethodType { fn from(value: enums::UpiType) -> Self { match value { enums::UpiType::UpiCollect => Self::UpiCollect, + enums::UpiType::UpiIntent => Self::UpiIntent, } } } diff --git a/crates/euclid/src/frontend/dir/transformers.rs b/crates/euclid/src/frontend/dir/transformers.rs index bcc951b0057..052561b5aab 100644 --- a/crates/euclid/src/frontend/dir/transformers.rs +++ b/crates/euclid/src/frontend/dir/transformers.rs @@ -109,6 +109,7 @@ impl IntoDirValue for (global_enums::PaymentMethodType, global_enums::PaymentMet } global_enums::PaymentMethodType::Evoucher => Ok(dirval!(RewardType = Evoucher)), global_enums::PaymentMethodType::UpiCollect => Ok(dirval!(UpiType = UpiCollect)), + global_enums::PaymentMethodType::UpiIntent => Ok(dirval!(UpiType = UpiIntent)), global_enums::PaymentMethodType::SamsungPay => Ok(dirval!(WalletType = SamsungPay)), global_enums::PaymentMethodType::GoPay => Ok(dirval!(WalletType = GoPay)), global_enums::PaymentMethodType::KakaoPay => Ok(dirval!(WalletType = KakaoPay)), diff --git a/crates/kgraph_utils/src/transformers.rs b/crates/kgraph_utils/src/transformers.rs index 3e43a4324f9..1bff0eac0d7 100644 --- a/crates/kgraph_utils/src/transformers.rs +++ b/crates/kgraph_utils/src/transformers.rs @@ -230,6 +230,7 @@ impl IntoDirValue for (api_enums::PaymentMethodType, api_enums::PaymentMethod) { api_enums::PaymentMethodType::ClassicReward => Ok(dirval!(RewardType = ClassicReward)), api_enums::PaymentMethodType::Evoucher => Ok(dirval!(RewardType = Evoucher)), api_enums::PaymentMethodType::UpiCollect => Ok(dirval!(UpiType = UpiCollect)), + api_enums::PaymentMethodType::UpiIntent => Ok(dirval!(UpiType = UpiIntent)), api_enums::PaymentMethodType::SamsungPay => Ok(dirval!(WalletType = SamsungPay)), api_enums::PaymentMethodType::GoPay => Ok(dirval!(WalletType = GoPay)), api_enums::PaymentMethodType::KakaoPay => Ok(dirval!(WalletType = KakaoPay)), diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rs index 04bb99ef75c..a34e67c6a01 100644 --- a/crates/router/src/compatibility/stripe/payment_intents/types.rs +++ b/crates/router/src/compatibility/stripe/payment_intents/types.rs @@ -73,7 +73,7 @@ pub enum StripeWallet { #[derive(Default, Serialize, PartialEq, Eq, Deserialize, Clone, Debug)] pub struct StripeUpi { - pub vpa_id: masking::Secret, + pub vpa_id: Option>, } #[derive(Debug, Default, Serialize, PartialEq, Eq, Deserialize, Clone)] @@ -141,8 +141,11 @@ impl From for payments::WalletData { impl From for payments::UpiData { fn from(upi: StripeUpi) -> Self { - Self { - vpa_id: Some(upi.vpa_id), + match upi.vpa_id { + Some(vpa_id) => Self::Upi(payments::Upi { + vpa_id: Some(vpa_id), + }), + None => Self::UpiQr(payments::UpiQr {}), } } } @@ -812,6 +815,7 @@ pub enum StripeNextAction { image_data_url: Option, display_to_timestamp: Option, qr_code_url: Option, + qr_code_data: Option, }, DisplayVoucherInformation { voucher_details: payments::VoucherNextStepData, @@ -847,10 +851,12 @@ pub(crate) fn into_stripe_next_action( image_data_url, display_to_timestamp, qr_code_url, + qr_code_data, } => StripeNextAction::QrCodeInformation { image_data_url, display_to_timestamp, qr_code_url, + qr_code_data, }, payments::NextActionData::DisplayVoucherInformation { voucher_details } => { StripeNextAction::DisplayVoucherInformation { voucher_details } diff --git a/crates/router/src/compatibility/stripe/setup_intents/types.rs b/crates/router/src/compatibility/stripe/setup_intents/types.rs index 03335d42722..5115a81238f 100644 --- a/crates/router/src/compatibility/stripe/setup_intents/types.rs +++ b/crates/router/src/compatibility/stripe/setup_intents/types.rs @@ -381,6 +381,7 @@ pub enum StripeNextAction { image_data_url: Option, display_to_timestamp: Option, qr_code_url: Option, + qr_code_data: Option, }, DisplayVoucherInformation { voucher_details: payments::VoucherNextStepData, @@ -416,10 +417,12 @@ pub(crate) fn into_stripe_next_action( image_data_url, display_to_timestamp, qr_code_url, + qr_code_data, } => StripeNextAction::QrCodeInformation { image_data_url, display_to_timestamp, qr_code_url, + qr_code_data, }, payments::NextActionData::DisplayVoucherInformation { voucher_details } => { StripeNextAction::DisplayVoucherInformation { voucher_details } diff --git a/crates/router/src/connector/adyen.rs b/crates/router/src/connector/adyen.rs index e2effb2e325..1a63dc50c9e 100644 --- a/crates/router/src/connector/adyen.rs +++ b/crates/router/src/connector/adyen.rs @@ -214,7 +214,8 @@ impl ConnectorValidation for Adyen { | PaymentMethodType::SamsungPay | PaymentMethodType::Evoucher | PaymentMethodType::Cashapp - | PaymentMethodType::UpiCollect => { + | PaymentMethodType::UpiCollect + | PaymentMethodType::UpiIntent => { capture_method_not_supported!(connector, capture_method, payment_method_type) } }, diff --git a/crates/router/src/connector/iatapay.rs b/crates/router/src/connector/iatapay.rs index 62c257fa43b..940f90262f6 100644 --- a/crates/router/src/connector/iatapay.rs +++ b/crates/router/src/connector/iatapay.rs @@ -24,6 +24,7 @@ use crate::{ types::{ self, api::{self, ConnectorCommon, ConnectorCommonExt}, + transformers::ForeignFrom, ErrorResponse, Response, }, utils::BytesExt, @@ -288,6 +289,11 @@ impl } } + +impl api::PaymentsCompleteAuthorize for Iatapay {} + + +#[async_trait::async_trait] impl ConnectorIntegration for Iatapay { @@ -347,13 +353,14 @@ impl ConnectorIntegration, res: Response, ) -> CustomResult { + let con_resp = std::str::from_utf8(&res.response).unwrap(); let response: IatapayPaymentsResponse = res .response .parse_struct("Iatapay PaymentsAuthorizeResponse") @@ -637,6 +644,91 @@ impl ConnectorIntegration for Iatapay +{ + fn get_headers( + &self, + _req: &types::PaymentsCompleteAuthorizeRouterData, + _connectors: &settings::Connectors, + ) -> CustomResult)>, errors::ConnectorError> { + Ok(vec![ + ( + headers::CONTENT_TYPE.to_string(), + types::RefreshTokenType::get_content_type(self) + .to_string() + .into(), + ) + ]) + } + fn get_content_type(&self) -> &'static str { + self.common_get_content_type() + } + + fn get_url( + &self, + req: &types::PaymentsCompleteAuthorizeRouterData, + _connectors: &settings::Connectors, + ) -> CustomResult { + let connector_payment_id = req + .request + .complete_authorize_url + .clone() + .ok_or(errors::ConnectorError::MissingConnectorTransactionID)?; + Ok(connector_payment_id) + } + fn build_request( + &self, + req: &types::PaymentsCompleteAuthorizeRouterData, + connectors: &settings::Connectors, + ) -> CustomResult, errors::ConnectorError> { + Ok(Some( + services::RequestBuilder::new() + .method(services::Method::Get) + .url(&types::PaymentsCompleteAuthorizeType::get_url( + self, req, connectors, + )?) + .headers(types::PaymentsCompleteAuthorizeType::get_headers( + self, req, connectors, + )?) + .build(), + )) + } + fn handle_response( + &self, + data: &types::PaymentsCompleteAuthorizeRouterData, + event_builder: Option<&mut ConnectorEvent>, + res: Response, + ) -> CustomResult { + let response: iatapay::IatapayCompleteAuthorizeResponse = res + .response + .parse_struct("IatapayCompleteAuthorizeResponse") + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; + + event_builder.map(|i| i.set_response_body(&response)); + router_env::logger::info!(connector_response=?response); + + types::RouterData::try_from(types::ResponseRouterData { + response, + data: data.clone(), + http_code: res.status_code, + }) + .change_context(errors::ConnectorError::ResponseHandlingFailed) + } + + fn get_error_response( + &self, + res: Response, + event_builder: Option<&mut ConnectorEvent>, + ) -> CustomResult { + self.build_error_response(res, event_builder) + } +} + #[async_trait::async_trait] impl api::IncomingWebhook for Iatapay { fn get_webhook_source_verification_algorithm( diff --git a/crates/router/src/connector/iatapay/transformers.rs b/crates/router/src/connector/iatapay/transformers.rs index 3e337d3a74e..87ff19bafe1 100644 --- a/crates/router/src/connector/iatapay/transformers.rs +++ b/crates/router/src/connector/iatapay/transformers.rs @@ -1,7 +1,9 @@ use std::collections::HashMap; use api_models::enums::PaymentMethod; -use common_utils::errors::CustomResult; +use common_enums::PaymentMethodType; +use common_utils::{errors::CustomResult, ext_traits::Encode}; +use error_stack::ResultExt; use masking::{Secret, SwitchStrategy}; use serde::{Deserialize, Serialize}; @@ -78,12 +80,38 @@ pub struct RedirectUrls { failure_url: String, } +#[derive(Debug, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct IatapayCompleteAuthorizeResponse { + iata_payment_id: String, + status: IatapayPaymentStatus, + authorization_timeout_date_time: Option, + qr_info_data: Option, + failure_details: Option, + failure_code: Option, +} + +#[derive(Debug, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct QrInfoData { + qr: String, + qr_link: url::Url, +} + #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct PayerInfo { token_id: Secret, } + +#[derive(Debug, Serialize)] +#[serde(rename_all = "UPPERCASE")] +pub enum PreferredCheckoutMethod { + Vpa, + Qr, +} + #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct IatapayPaymentsRequest { @@ -95,7 +123,14 @@ pub struct IatapayPaymentsRequest { locale: String, redirect_urls: RedirectUrls, notification_url: String, + #[serde(skip_serializing_if = "Option::is_none")] payer_info: Option, + preferred_checkout_method: Option, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct IatapayQrMetadata { + pub complete_authorize_url: String, } impl @@ -136,24 +171,31 @@ impl | PaymentMethod::GiftCard => item.router_data.get_billing_country()?.to_string(), }; let return_url = item.router_data.get_return_url()?; - let payer_info = match item.router_data.request.payment_method_data.clone() { - domain::PaymentMethodData::Upi(upi_data) => upi_data.vpa_id.map(|id| PayerInfo { - token_id: id.switch_strategy(), - }), - domain::PaymentMethodData::Card(_) - | domain::PaymentMethodData::CardRedirect(_) - | domain::PaymentMethodData::Wallet(_) - | domain::PaymentMethodData::PayLater(_) - | domain::PaymentMethodData::BankRedirect(_) - | domain::PaymentMethodData::BankDebit(_) - | domain::PaymentMethodData::BankTransfer(_) - | domain::PaymentMethodData::Crypto(_) - | domain::PaymentMethodData::MandatePayment - | domain::PaymentMethodData::Reward - | domain::PaymentMethodData::Voucher(_) - | domain::PaymentMethodData::GiftCard(_) - | domain::PaymentMethodData::CardToken(_) => None, - }; + let (payer_info, preferred_checkout_method) = + match item.router_data.request.payment_method_data.clone() { + domain::PaymentMethodData::Upi(upi_type) => match upi_type { + domain::UpiData::Upi(upi_data) => ( + upi_data.vpa_id.map(|id| PayerInfo { + token_id: id.switch_strategy(), + }), + Some(PreferredCheckoutMethod::Vpa), + ), + domain::UpiData::UpiQr(_) => (None, Some(PreferredCheckoutMethod::Qr)), + }, + domain::PaymentMethodData::Card(_) + | domain::PaymentMethodData::CardRedirect(_) + | domain::PaymentMethodData::Wallet(_) + | domain::PaymentMethodData::PayLater(_) + | domain::PaymentMethodData::BankRedirect(_) + | domain::PaymentMethodData::BankDebit(_) + | domain::PaymentMethodData::BankTransfer(_) + | domain::PaymentMethodData::Crypto(_) + | domain::PaymentMethodData::MandatePayment + | domain::PaymentMethodData::Reward + | domain::PaymentMethodData::Voucher(_) + | domain::PaymentMethodData::GiftCard(_) + | domain::PaymentMethodData::CardToken(_) => (None, None), + }; let payload = Self { merchant_id: IatapayAuthType::try_from(&item.router_data.connector_auth_type)? .merchant_id, @@ -164,7 +206,8 @@ impl locale: format!("en-{}", country), redirect_urls: get_redirect_url(return_url), payer_info, - notification_url: item.router_data.request.get_webhook_url()?, + notification_url: "https://77f1-65-1-52-128.ngrok-free.app".to_owned(), + preferred_checkout_method, }; Ok(payload) } @@ -258,6 +301,7 @@ pub struct IatapayPaymentsResponse { fn get_iatpay_response( response: IatapayPaymentsResponse, status_code: u16, + payment_method_type: Option, ) -> CustomResult< ( enums::AttemptStatus, @@ -291,43 +335,109 @@ fn get_iatpay_response( }; let connector_response_reference_id = response.merchant_payment_id.or(response.iata_payment_id); - let payment_response_data = response.checkout_methods.map_or( - types::PaymentsResponseData::TransactionResponse { - resource_id: id.clone(), - redirection_data: None, - mandate_reference: None, - connector_metadata: None, - network_txn_id: None, - connector_response_reference_id: connector_response_reference_id.clone(), - incremental_authorization_allowed: None, - }, - |checkout_methods| types::PaymentsResponseData::TransactionResponse { - resource_id: id, - redirection_data: Some(services::RedirectForm::Form { - endpoint: checkout_methods.redirect.redirect_url, - method: services::Method::Get, - form_fields, - }), - mandate_reference: None, - connector_metadata: None, - network_txn_id: None, - connector_response_reference_id: connector_response_reference_id.clone(), - incremental_authorization_allowed: None, - }, - ); + let payment_response_data = match response.checkout_methods { + Some(checkout_methods) => { + let (connector_metadata, redirection_data) = match payment_method_type { + Some(PaymentMethodType::UpiIntent) => { + let qr_code_info = IatapayQrMetadata { + complete_authorize_url: checkout_methods.redirect.redirect_url, + }; + ( + Some(qr_code_info.encode_to_value()) + .transpose() + .change_context(errors::ConnectorError::ResponseHandlingFailed)?, + None, + ) + } + Some(PaymentMethodType::UpiCollect) => ( + None, + Some(services::RedirectForm::Form { + endpoint: checkout_methods.redirect.redirect_url, + method: services::Method::Get, + form_fields, + }), + ), + _ => (None, None), + }; + + types::PaymentsResponseData::TransactionResponse { + resource_id: id, + redirection_data, + mandate_reference: None, + connector_metadata, + network_txn_id: None, + connector_response_reference_id: connector_response_reference_id.clone(), + incremental_authorization_allowed: None, + } + }, + None => types::PaymentsResponseData::TransactionResponse { + resource_id: id.clone(), + redirection_data: None, + mandate_reference: None, + connector_metadata: None, + network_txn_id: None, + connector_response_reference_id: connector_response_reference_id.clone(), + incremental_authorization_allowed: None, + } + + }; + Ok((status, error, payment_response_data)) } -impl - TryFrom> - for types::RouterData +impl + TryFrom< + types::ResponseRouterData< + F, + IatapayPaymentsResponse, + PaymentsAuthorizeData, + types::PaymentsResponseData, + >, + > for types::RouterData +{ + type Error = Error; + fn try_from( + item: types::ResponseRouterData< + F, + IatapayPaymentsResponse, + PaymentsAuthorizeData, + types::PaymentsResponseData, + >, + ) -> Result { + let payment_method_type = item.data.request.payment_method_type; + let (status, error, payment_response_data) = + get_iatpay_response(item.response, item.http_code, payment_method_type)?; + Ok(Self { + status, + response: error.map_or_else(|| Ok(payment_response_data), Err), + ..item.data + }) + } +} + +impl + TryFrom< + types::ResponseRouterData< + F, + IatapayPaymentsResponse, + types::PaymentsSyncData, + types::PaymentsResponseData, + >, + > for types::RouterData { type Error = Error; fn try_from( - item: types::ResponseRouterData, + item: types::ResponseRouterData< + F, + IatapayPaymentsResponse, + types::PaymentsSyncData, + types::PaymentsResponseData, + >, ) -> Result { + let payment_method_type = item.data.request.payment_method_type; + let (status, error, payment_response_data) = - get_iatpay_response(item.response, item.http_code)?; + get_iatpay_response(item.response, item.http_code, payment_method_type)?; Ok(Self { status, response: error.map_or_else(|| Ok(payment_response_data), Err), @@ -336,6 +446,76 @@ impl } } +impl + TryFrom< + types::ResponseRouterData< + F, + IatapayCompleteAuthorizeResponse, + types::CompleteAuthorizeData, + types::PaymentsResponseData, + >, + > for types::RouterData +{ + type Error = Error; + fn try_from( + item: types::ResponseRouterData< + F, + IatapayCompleteAuthorizeResponse, + types::CompleteAuthorizeData, + types::PaymentsResponseData, + >, + ) -> Result { + + let status = enums::AttemptStatus::from(item.response.status); + let response = if connector_util::is_payment_failure(status) { + Err(types::ErrorResponse { + code: item + .response + .failure_code + .unwrap_or_else(|| consts::NO_ERROR_CODE.to_string()), + message: item + .response + .failure_details + .clone() + .unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()), + reason: item.response.failure_details, + status_code: item.http_code, + attempt_status: Some(status), + connector_transaction_id: Some(item.response.iata_payment_id.clone()), + }) + } else { + let qr_code_info = item.response.qr_info_data.map(|qr_data| { + api_models::payments::QrCodeInformation::QrCodeData { + qr_code_url: qr_data.qr_link, + qr_code_data: qr_data.qr, + display_to_timestamp: None, + } + }); + let connector_metadata = Some(qr_code_info.encode_to_value()) + .transpose() + .change_context(errors::ConnectorError::ResponseHandlingFailed)?; + + Ok(types::PaymentsResponseData::TransactionResponse { + resource_id: types::ResponseId::ConnectorTransactionId( + item.response.iata_payment_id, + ), + redirection_data: None, + mandate_reference: None, + connector_metadata, + network_txn_id: None, + connector_response_reference_id: None, + incremental_authorization_allowed: None, + }) + }; + + Ok(Self { + status, + response, + ..item.data + }) + } +} + // REFUND : // Type definition for RefundRequest #[derive(Debug, Serialize)] @@ -361,7 +541,7 @@ impl TryFrom<&IatapayRouterData<&types::RefundsRouterData>> for IatapayRef merchant_refund_id: Some(item.router_data.request.refund_id.clone()), currency: item.router_data.request.currency.to_string(), bank_transfer_description: item.router_data.request.reason.clone(), - notification_url: item.router_data.request.get_webhook_url()?, + notification_url: "https://77f1-65-1-52-128.ngrok-free.app".to_owned(), }) } } diff --git a/crates/router/src/connector/klarna.rs b/crates/router/src/connector/klarna.rs index 5c174c69e3b..48b6616a64e 100644 --- a/crates/router/src/connector/klarna.rs +++ b/crates/router/src/connector/klarna.rs @@ -398,6 +398,7 @@ impl | common_enums::PaymentMethodType::Trustly | common_enums::PaymentMethodType::Twint | common_enums::PaymentMethodType::UpiCollect + | common_enums::PaymentMethodType::UpiIntent | common_enums::PaymentMethodType::Venmo | common_enums::PaymentMethodType::Vipps | common_enums::PaymentMethodType::Walley diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs index da524bea4c7..3600fcbc502 100644 --- a/crates/router/src/connector/stripe/transformers.rs +++ b/crates/router/src/connector/stripe/transformers.rs @@ -663,6 +663,7 @@ impl TryFrom for StripePaymentMethodType { | enums::PaymentMethodType::Paypal | enums::PaymentMethodType::Pix | enums::PaymentMethodType::UpiCollect + | enums::PaymentMethodType::UpiIntent | enums::PaymentMethodType::Cashapp | enums::PaymentMethodType::Oxxo => Err(errors::ConnectorError::NotImplemented( connector_util::get_unimplemented_payment_method_error_message("stripe"), diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs index a8425896dd7..6d4b256a365 100644 --- a/crates/router/src/core/payments/flows.rs +++ b/crates/router/src/core/payments/flows.rs @@ -160,7 +160,6 @@ default_imp_for_complete_authorize!( connector::Gocardless, connector::Gpayments, connector::Helcim, - connector::Iatapay, connector::Klarna, connector::Mifinity, connector::Multisafepay, diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs index 75bbb5bda8c..159509657f9 100644 --- a/crates/router/src/core/payments/flows/authorize_flow.rs +++ b/crates/router/src/core/payments/flows/authorize_flow.rs @@ -197,6 +197,7 @@ impl Feature for types::PaymentsAu self.decide_authentication_type(); logger::debug!(auth_type=?self.auth_type); + Ok(( connector_integration .build_request(self, &state.conf.connectors) diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs index 2c442c5ce43..f219bfaf6cd 100644 --- a/crates/router/src/core/payments/helpers.rs +++ b/crates/router/src/core/payments/helpers.rs @@ -2332,7 +2332,7 @@ pub fn validate_payment_method_type_against_payment_method( ), api_enums::PaymentMethod::Upi => matches!( payment_method_type, - api_enums::PaymentMethodType::UpiCollect + api_enums::PaymentMethodType::UpiCollect | api_enums::PaymentMethodType::UpiIntent ), api_enums::PaymentMethod::Voucher => matches!( payment_method_type, @@ -4108,9 +4108,9 @@ pub fn get_key_params_for_surcharge_details( )), api_models::payments::PaymentMethodData::MandatePayment => None, api_models::payments::PaymentMethodData::Reward => None, - api_models::payments::PaymentMethodData::Upi(_) => Some(( + api_models::payments::PaymentMethodData::Upi(upi_data) => Some(( common_enums::PaymentMethod::Upi, - common_enums::PaymentMethodType::UpiCollect, + upi_data.get_payment_method_type(), None, )), api_models::payments::PaymentMethodData::Voucher(voucher) => Some(( diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index 1fd76130597..3570515322e 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -1037,6 +1037,7 @@ impl ForeignFrom for api_models::paymen } => Self::QrCodeInformation { image_data_url: Some(image_data_url), qr_code_url: Some(qr_code_url), + qr_code_data: None, display_to_timestamp, }, api_models::payments::QrCodeInformation::QrDataUrl { @@ -1045,6 +1046,7 @@ impl ForeignFrom for api_models::paymen } => Self::QrCodeInformation { image_data_url: Some(image_data_url), display_to_timestamp, + qr_code_data: None, qr_code_url: None, }, api_models::payments::QrCodeInformation::QrCodeImageUrl { @@ -1052,8 +1054,19 @@ impl ForeignFrom for api_models::paymen display_to_timestamp, } => Self::QrCodeInformation { qr_code_url: Some(qr_code_url), + qr_code_data: None, + image_data_url: None, + display_to_timestamp, + }, + api_models::payments::QrCodeInformation::QrCodeData { + qr_code_url, + qr_code_data, display_to_timestamp, + } => Self::QrCodeInformation { + qr_code_url: Some(qr_code_url), + qr_code_data: Some(qr_code_data), image_data_url: None, + display_to_timestamp, }, } } diff --git a/crates/router/src/types/domain/payments.rs b/crates/router/src/types/domain/payments.rs index 9dc85c103e9..8853b33533c 100644 --- a/crates/router/src/types/domain/payments.rs +++ b/crates/router/src/types/domain/payments.rs @@ -289,10 +289,20 @@ pub struct CryptoData { #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)] #[serde(rename_all = "snake_case")] -pub struct UpiData { +pub enum UpiData { + Upi(Upi), + UpiQr(UpiQr), +} + +#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(rename_all = "snake_case")] +pub struct Upi { pub vpa_id: Option>, } +#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)] +pub struct UpiQr {} + #[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(rename_all = "snake_case")] pub enum VoucherData { @@ -690,8 +700,10 @@ impl From for CryptoData { impl From for UpiData { fn from(value: api_models::payments::UpiData) -> Self { - let api_models::payments::UpiData { vpa_id } = value; - Self { vpa_id } + match value { + api_models::payments::UpiData::Upi(upi) => Self::Upi(Upi { vpa_id: upi.vpa_id }), + api_models::payments::UpiData::UpiQr(_) => Self::UpiQr(UpiQr {}), + } } } diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs index 6fb98d944bf..7022d8dc12b 100644 --- a/crates/router/src/types/transformers.rs +++ b/crates/router/src/types/transformers.rs @@ -460,7 +460,9 @@ impl ForeignFrom for api_enums::PaymentMethod { | api_enums::PaymentMethodType::Trustly | api_enums::PaymentMethodType::Bizum | api_enums::PaymentMethodType::Interac => Self::BankRedirect, - api_enums::PaymentMethodType::UpiCollect => Self::Upi, + api_enums::PaymentMethodType::UpiCollect | api_enums::PaymentMethodType::UpiIntent => { + Self::Upi + } api_enums::PaymentMethodType::CryptoCurrency => Self::Crypto, api_enums::PaymentMethodType::Ach | api_enums::PaymentMethodType::Sepa From cccc969daf424d7cce30776cf171d49302b352da Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Wed, 22 May 2024 15:23:57 +0530 Subject: [PATCH 02/17] refactor to send the qr code data link --- crates/api_models/src/payments.rs | 8 +- .../stripe/payment_intents/types.rs | 6 +- .../stripe/setup_intents/types.rs | 6 +- crates/router/src/connector/iatapay.rs | 93 +-------- .../src/connector/iatapay/transformers.rs | 195 +++--------------- crates/router/src/core/payments/flows.rs | 1 + .../src/core/payments/flows/authorize_flow.rs | 1 - .../router/src/core/payments/transformers.rs | 24 +-- 8 files changed, 52 insertions(+), 282 deletions(-) diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index 56e2487432d..03f47aece66 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -2942,7 +2942,7 @@ pub enum NextActionData { #[schema(value_type = String)] /// The url for Qr code given by the connector qr_code_url: Option, - qr_code_data: Option, + qr_code_data_url: Option, }, /// Contains the download url and the reference number for transaction DisplayVoucherInformation { @@ -3012,10 +3012,8 @@ pub enum QrCodeInformation { qr_code_url: Url, display_to_timestamp: Option, }, - QrCodeData { - qr_code_url: Url, - qr_code_data: String, - display_to_timestamp: Option, + QrCodeDataUrl { + qr_code_data_url: Url, }, } diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rs index a34e67c6a01..3ebc036d75a 100644 --- a/crates/router/src/compatibility/stripe/payment_intents/types.rs +++ b/crates/router/src/compatibility/stripe/payment_intents/types.rs @@ -815,7 +815,7 @@ pub enum StripeNextAction { image_data_url: Option, display_to_timestamp: Option, qr_code_url: Option, - qr_code_data: Option, + qr_code_data_url: Option, }, DisplayVoucherInformation { voucher_details: payments::VoucherNextStepData, @@ -851,12 +851,12 @@ pub(crate) fn into_stripe_next_action( image_data_url, display_to_timestamp, qr_code_url, - qr_code_data, + qr_code_data_url, } => StripeNextAction::QrCodeInformation { image_data_url, display_to_timestamp, qr_code_url, - qr_code_data, + qr_code_data_url, }, payments::NextActionData::DisplayVoucherInformation { voucher_details } => { StripeNextAction::DisplayVoucherInformation { voucher_details } diff --git a/crates/router/src/compatibility/stripe/setup_intents/types.rs b/crates/router/src/compatibility/stripe/setup_intents/types.rs index 5115a81238f..a959dcebce4 100644 --- a/crates/router/src/compatibility/stripe/setup_intents/types.rs +++ b/crates/router/src/compatibility/stripe/setup_intents/types.rs @@ -381,7 +381,7 @@ pub enum StripeNextAction { image_data_url: Option, display_to_timestamp: Option, qr_code_url: Option, - qr_code_data: Option, + qr_code_data_url: Option, }, DisplayVoucherInformation { voucher_details: payments::VoucherNextStepData, @@ -417,12 +417,12 @@ pub(crate) fn into_stripe_next_action( image_data_url, display_to_timestamp, qr_code_url, - qr_code_data, + qr_code_data_url, } => StripeNextAction::QrCodeInformation { image_data_url, display_to_timestamp, qr_code_url, - qr_code_data, + qr_code_data_url, }, payments::NextActionData::DisplayVoucherInformation { voucher_details } => { StripeNextAction::DisplayVoucherInformation { voucher_details } diff --git a/crates/router/src/connector/iatapay.rs b/crates/router/src/connector/iatapay.rs index 940f90262f6..873c06b5982 100644 --- a/crates/router/src/connector/iatapay.rs +++ b/crates/router/src/connector/iatapay.rs @@ -24,7 +24,6 @@ use crate::{ types::{ self, api::{self, ConnectorCommon, ConnectorCommonExt}, - transformers::ForeignFrom, ErrorResponse, Response, }, utils::BytesExt, @@ -289,11 +288,6 @@ impl } } - -impl api::PaymentsCompleteAuthorize for Iatapay {} - - -#[async_trait::async_trait] impl ConnectorIntegration for Iatapay { @@ -353,7 +347,7 @@ impl ConnectorIntegration for Iatapay -{ - fn get_headers( - &self, - _req: &types::PaymentsCompleteAuthorizeRouterData, - _connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { - Ok(vec![ - ( - headers::CONTENT_TYPE.to_string(), - types::RefreshTokenType::get_content_type(self) - .to_string() - .into(), - ) - ]) - } - fn get_content_type(&self) -> &'static str { - self.common_get_content_type() - } - - fn get_url( - &self, - req: &types::PaymentsCompleteAuthorizeRouterData, - _connectors: &settings::Connectors, - ) -> CustomResult { - let connector_payment_id = req - .request - .complete_authorize_url - .clone() - .ok_or(errors::ConnectorError::MissingConnectorTransactionID)?; - Ok(connector_payment_id) - } - fn build_request( - &self, - req: &types::PaymentsCompleteAuthorizeRouterData, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { - Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Get) - .url(&types::PaymentsCompleteAuthorizeType::get_url( - self, req, connectors, - )?) - .headers(types::PaymentsCompleteAuthorizeType::get_headers( - self, req, connectors, - )?) - .build(), - )) - } - fn handle_response( - &self, - data: &types::PaymentsCompleteAuthorizeRouterData, - event_builder: Option<&mut ConnectorEvent>, - res: Response, - ) -> CustomResult { - let response: iatapay::IatapayCompleteAuthorizeResponse = res - .response - .parse_struct("IatapayCompleteAuthorizeResponse") - .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; - - event_builder.map(|i| i.set_response_body(&response)); - router_env::logger::info!(connector_response=?response); - - types::RouterData::try_from(types::ResponseRouterData { - response, - data: data.clone(), - http_code: res.status_code, - }) - .change_context(errors::ConnectorError::ResponseHandlingFailed) - } - - fn get_error_response( - &self, - res: Response, - event_builder: Option<&mut ConnectorEvent>, - ) -> CustomResult { - self.build_error_response(res, event_builder) - } -} - #[async_trait::async_trait] impl api::IncomingWebhook for Iatapay { fn get_webhook_source_verification_algorithm( diff --git a/crates/router/src/connector/iatapay/transformers.rs b/crates/router/src/connector/iatapay/transformers.rs index 87ff19bafe1..adbf77552a2 100644 --- a/crates/router/src/connector/iatapay/transformers.rs +++ b/crates/router/src/connector/iatapay/transformers.rs @@ -1,7 +1,6 @@ use std::collections::HashMap; use api_models::enums::PaymentMethod; -use common_enums::PaymentMethodType; use common_utils::{errors::CustomResult, ext_traits::Encode}; use error_stack::ResultExt; use masking::{Secret, SwitchStrategy}; @@ -80,23 +79,6 @@ pub struct RedirectUrls { failure_url: String, } -#[derive(Debug, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct IatapayCompleteAuthorizeResponse { - iata_payment_id: String, - status: IatapayPaymentStatus, - authorization_timeout_date_time: Option, - qr_info_data: Option, - failure_details: Option, - failure_code: Option, -} - -#[derive(Debug, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct QrInfoData { - qr: String, - qr_link: url::Url, -} #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] @@ -104,7 +86,6 @@ pub struct PayerInfo { token_id: Secret, } - #[derive(Debug, Serialize)] #[serde(rename_all = "UPPERCASE")] pub enum PreferredCheckoutMethod { @@ -128,11 +109,6 @@ pub struct IatapayPaymentsRequest { preferred_checkout_method: Option, } -#[derive(Debug, Serialize, Deserialize)] -pub struct IatapayQrMetadata { - pub complete_authorize_url: String, -} - impl TryFrom< &IatapayRouterData< @@ -301,7 +277,6 @@ pub struct IatapayPaymentsResponse { fn get_iatpay_response( response: IatapayPaymentsResponse, status_code: u16, - payment_method_type: Option, ) -> CustomResult< ( enums::AttemptStatus, @@ -337,10 +312,14 @@ fn get_iatpay_response( let payment_response_data = match response.checkout_methods { Some(checkout_methods) => { - let (connector_metadata, redirection_data) = match payment_method_type { - Some(PaymentMethodType::UpiIntent) => { - let qr_code_info = IatapayQrMetadata { - complete_authorize_url: checkout_methods.redirect.redirect_url, + let (connector_metadata, redirection_data) = + match checkout_methods.redirect.redirect_url.ends_with("qr") { + true => { + let qr_code_info = api_models::payments::QrCodeInformation::QrCodeDataUrl { + qr_code_data_url: url::Url::parse( + &checkout_methods.redirect.redirect_url, + ) + .change_context(errors::ConnectorError::ResponseHandlingFailed)?, }; ( Some(qr_code_info.encode_to_value()) @@ -349,7 +328,7 @@ fn get_iatpay_response( None, ) } - Some(PaymentMethodType::UpiCollect) => ( + false => ( None, Some(services::RedirectForm::Form { endpoint: checkout_methods.redirect.redirect_url, @@ -359,54 +338,41 @@ fn get_iatpay_response( ), _ => (None, None), }; - - types::PaymentsResponseData::TransactionResponse { - resource_id: id, - redirection_data, - mandate_reference: None, - connector_metadata, - network_txn_id: None, - connector_response_reference_id: connector_response_reference_id.clone(), - incremental_authorization_allowed: None, - } - }, - None => types::PaymentsResponseData::TransactionResponse { - resource_id: id.clone(), - redirection_data: None, + + types::PaymentsResponseData::TransactionResponse { + resource_id: id, + redirection_data, mandate_reference: None, - connector_metadata: None, + connector_metadata, network_txn_id: None, connector_response_reference_id: connector_response_reference_id.clone(), incremental_authorization_allowed: None, } - - }; + } + None => types::PaymentsResponseData::TransactionResponse { + resource_id: id.clone(), + redirection_data: None, + mandate_reference: None, + connector_metadata: None, + network_txn_id: None, + connector_response_reference_id: connector_response_reference_id.clone(), + incremental_authorization_allowed: None, + }, + }; Ok((status, error, payment_response_data)) } -impl - TryFrom< - types::ResponseRouterData< - F, - IatapayPaymentsResponse, - PaymentsAuthorizeData, - types::PaymentsResponseData, - >, - > for types::RouterData +impl + TryFrom> + for types::RouterData { type Error = Error; fn try_from( - item: types::ResponseRouterData< - F, - IatapayPaymentsResponse, - PaymentsAuthorizeData, - types::PaymentsResponseData, - >, + item: types::ResponseRouterData, ) -> Result { - let payment_method_type = item.data.request.payment_method_type; let (status, error, payment_response_data) = - get_iatpay_response(item.response, item.http_code, payment_method_type)?; + get_iatpay_response(item.response, item.http_code)?; Ok(Self { status, response: error.map_or_else(|| Ok(payment_response_data), Err), @@ -415,107 +381,6 @@ impl } } -impl - TryFrom< - types::ResponseRouterData< - F, - IatapayPaymentsResponse, - types::PaymentsSyncData, - types::PaymentsResponseData, - >, - > for types::RouterData -{ - type Error = Error; - fn try_from( - item: types::ResponseRouterData< - F, - IatapayPaymentsResponse, - types::PaymentsSyncData, - types::PaymentsResponseData, - >, - ) -> Result { - let payment_method_type = item.data.request.payment_method_type; - - let (status, error, payment_response_data) = - get_iatpay_response(item.response, item.http_code, payment_method_type)?; - Ok(Self { - status, - response: error.map_or_else(|| Ok(payment_response_data), Err), - ..item.data - }) - } -} - -impl - TryFrom< - types::ResponseRouterData< - F, - IatapayCompleteAuthorizeResponse, - types::CompleteAuthorizeData, - types::PaymentsResponseData, - >, - > for types::RouterData -{ - type Error = Error; - fn try_from( - item: types::ResponseRouterData< - F, - IatapayCompleteAuthorizeResponse, - types::CompleteAuthorizeData, - types::PaymentsResponseData, - >, - ) -> Result { - - let status = enums::AttemptStatus::from(item.response.status); - let response = if connector_util::is_payment_failure(status) { - Err(types::ErrorResponse { - code: item - .response - .failure_code - .unwrap_or_else(|| consts::NO_ERROR_CODE.to_string()), - message: item - .response - .failure_details - .clone() - .unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()), - reason: item.response.failure_details, - status_code: item.http_code, - attempt_status: Some(status), - connector_transaction_id: Some(item.response.iata_payment_id.clone()), - }) - } else { - let qr_code_info = item.response.qr_info_data.map(|qr_data| { - api_models::payments::QrCodeInformation::QrCodeData { - qr_code_url: qr_data.qr_link, - qr_code_data: qr_data.qr, - display_to_timestamp: None, - } - }); - let connector_metadata = Some(qr_code_info.encode_to_value()) - .transpose() - .change_context(errors::ConnectorError::ResponseHandlingFailed)?; - - Ok(types::PaymentsResponseData::TransactionResponse { - resource_id: types::ResponseId::ConnectorTransactionId( - item.response.iata_payment_id, - ), - redirection_data: None, - mandate_reference: None, - connector_metadata, - network_txn_id: None, - connector_response_reference_id: None, - incremental_authorization_allowed: None, - }) - }; - - Ok(Self { - status, - response, - ..item.data - }) - } -} - // REFUND : // Type definition for RefundRequest #[derive(Debug, Serialize)] diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs index 6d4b256a365..a8425896dd7 100644 --- a/crates/router/src/core/payments/flows.rs +++ b/crates/router/src/core/payments/flows.rs @@ -160,6 +160,7 @@ default_imp_for_complete_authorize!( connector::Gocardless, connector::Gpayments, connector::Helcim, + connector::Iatapay, connector::Klarna, connector::Mifinity, connector::Multisafepay, diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs index 159509657f9..75bbb5bda8c 100644 --- a/crates/router/src/core/payments/flows/authorize_flow.rs +++ b/crates/router/src/core/payments/flows/authorize_flow.rs @@ -197,7 +197,6 @@ impl Feature for types::PaymentsAu self.decide_authentication_type(); logger::debug!(auth_type=?self.auth_type); - Ok(( connector_integration .build_request(self, &state.conf.connectors) diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index 3570515322e..85d39c7fe87 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -1037,8 +1037,8 @@ impl ForeignFrom for api_models::paymen } => Self::QrCodeInformation { image_data_url: Some(image_data_url), qr_code_url: Some(qr_code_url), - qr_code_data: None, display_to_timestamp, + qr_code_data_url: None, }, api_models::payments::QrCodeInformation::QrDataUrl { image_data_url, @@ -1046,28 +1046,26 @@ impl ForeignFrom for api_models::paymen } => Self::QrCodeInformation { image_data_url: Some(image_data_url), display_to_timestamp, - qr_code_data: None, qr_code_url: None, + qr_code_data_url: None, }, api_models::payments::QrCodeInformation::QrCodeImageUrl { qr_code_url, display_to_timestamp, } => Self::QrCodeInformation { qr_code_url: Some(qr_code_url), - qr_code_data: None, - image_data_url: None, - display_to_timestamp, - }, - api_models::payments::QrCodeInformation::QrCodeData { - qr_code_url, - qr_code_data, - display_to_timestamp, - } => Self::QrCodeInformation { - qr_code_url: Some(qr_code_url), - qr_code_data: Some(qr_code_data), image_data_url: None, display_to_timestamp, + qr_code_data_url: None, }, + api_models::payments::QrCodeInformation::QrCodeDataUrl { qr_code_data_url } => { + Self::QrCodeInformation { + qr_code_data_url: Some(qr_code_data_url), + image_data_url: None, + display_to_timestamp: None, + qr_code_url: None, + } + } } } } From 6651778dda57a2665df1e7eb8cae007a33baad03 Mon Sep 17 00:00:00 2001 From: "hyperswitch-bot[bot]" <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Date: Wed, 22 May 2024 10:10:04 +0000 Subject: [PATCH 03/17] chore: run formatter --- crates/router/src/connector/iatapay/transformers.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/router/src/connector/iatapay/transformers.rs b/crates/router/src/connector/iatapay/transformers.rs index adbf77552a2..a6738156c70 100644 --- a/crates/router/src/connector/iatapay/transformers.rs +++ b/crates/router/src/connector/iatapay/transformers.rs @@ -79,7 +79,6 @@ pub struct RedirectUrls { failure_url: String, } - #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct PayerInfo { From bc159db4d2cc75654fd5be1ee0cb8782926a94f8 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Wed, 22 May 2024 18:12:18 +0530 Subject: [PATCH 04/17] minor refactor to stripe compatibility layer --- .../stripe/payment_intents/types.rs | 46 ++++++++++++------- crates/router/src/connector/iatapay.rs | 1 - .../src/connector/iatapay/transformers.rs | 5 +- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rs index 3ebc036d75a..cc061305fb6 100644 --- a/crates/router/src/compatibility/stripe/payment_intents/types.rs +++ b/crates/router/src/compatibility/stripe/payment_intents/types.rs @@ -140,13 +140,10 @@ impl From for payments::WalletData { } impl From for payments::UpiData { - fn from(upi: StripeUpi) -> Self { - match upi.vpa_id { - Some(vpa_id) => Self::Upi(payments::Upi { - vpa_id: Some(vpa_id), - }), - None => Self::UpiQr(payments::UpiQr {}), - } + fn from(upi_data: StripeUpi) -> Self { + Self::Upi(payments::Upi { + vpa_id: upi_data.vpa_id, + }) } } @@ -315,6 +312,18 @@ impl TryFrom for payments::PaymentsRequest { expected_format: "127.0.0.1".to_string(), })?; + 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: item.amount.map(|amount| amount.into()), @@ -334,16 +343,7 @@ impl TryFrom 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() @@ -881,3 +881,15 @@ pub(crate) fn into_stripe_next_action( pub struct StripePaymentRetrieveBody { pub client_secret: Option, } + +//To handle payment types that have empty payment method data +fn get_pmd_based_on_payment_method_type( + payment_method_type: Option, +) -> Option { + match payment_method_type { + Some(api_enums::PaymentMethodType::UpiIntent) => { + Some(payments::PaymentMethodData::Upi(payments::UpiData::UpiQr(payments::UpiQr {}))) + }, + _ => None, + } +} diff --git a/crates/router/src/connector/iatapay.rs b/crates/router/src/connector/iatapay.rs index 873c06b5982..62c257fa43b 100644 --- a/crates/router/src/connector/iatapay.rs +++ b/crates/router/src/connector/iatapay.rs @@ -354,7 +354,6 @@ impl ConnectorIntegration, res: Response, ) -> CustomResult { - let con_resp = std::str::from_utf8(&res.response).unwrap(); let response: IatapayPaymentsResponse = res .response .parse_struct("Iatapay PaymentsAuthorizeResponse") diff --git a/crates/router/src/connector/iatapay/transformers.rs b/crates/router/src/connector/iatapay/transformers.rs index a6738156c70..33d0a7595c8 100644 --- a/crates/router/src/connector/iatapay/transformers.rs +++ b/crates/router/src/connector/iatapay/transformers.rs @@ -181,7 +181,7 @@ impl locale: format!("en-{}", country), redirect_urls: get_redirect_url(return_url), payer_info, - notification_url: "https://77f1-65-1-52-128.ngrok-free.app".to_owned(), + notification_url: item.router_data.request.get_webhook_url()?, preferred_checkout_method, }; Ok(payload) @@ -335,7 +335,6 @@ fn get_iatpay_response( form_fields, }), ), - _ => (None, None), }; types::PaymentsResponseData::TransactionResponse { @@ -405,7 +404,7 @@ impl TryFrom<&IatapayRouterData<&types::RefundsRouterData>> for IatapayRef merchant_refund_id: Some(item.router_data.request.refund_id.clone()), currency: item.router_data.request.currency.to_string(), bank_transfer_description: item.router_data.request.reason.clone(), - notification_url: "https://77f1-65-1-52-128.ngrok-free.app".to_owned(), + notification_url: item.router_data.request.get_webhook_url()?, }) } } From dda26abff2f28bc530655482aa473fe5b8249000 Mon Sep 17 00:00:00 2001 From: "hyperswitch-bot[bot]" <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Date: Wed, 22 May 2024 12:45:23 +0000 Subject: [PATCH 05/17] chore: run formatter --- .../src/compatibility/stripe/payment_intents/types.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rs index f83edfb3235..1f92fd17e5c 100644 --- a/crates/router/src/compatibility/stripe/payment_intents/types.rs +++ b/crates/router/src/compatibility/stripe/payment_intents/types.rs @@ -890,9 +890,9 @@ fn get_pmd_based_on_payment_method_type( payment_method_type: Option, ) -> Option { match payment_method_type { - Some(api_enums::PaymentMethodType::UpiIntent) => { - Some(payments::PaymentMethodData::Upi(payments::UpiData::UpiQr(payments::UpiQr {}))) - }, + Some(api_enums::PaymentMethodType::UpiIntent) => Some(payments::PaymentMethodData::Upi( + payments::UpiData::UpiQr(payments::UpiQr {}), + )), _ => None, } } From e317b34ec589baad44b5aa7b7ff13c40e968af66 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Wed, 22 May 2024 18:32:54 +0530 Subject: [PATCH 06/17] add upitype --- crates/api_models/src/payments.rs | 1 + crates/kgraph_utils/src/mca.rs | 3 ++- .../router/src/compatibility/stripe/payment_intents/types.rs | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index 3993cfce894..83218a543a9 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -2950,6 +2950,7 @@ pub enum NextActionData { #[schema(value_type = String)] /// The url for Qr code given by the connector qr_code_url: Option, + /// The url to fetch qr code data qr_code_data_url: Option, }, /// Contains the download url and the reference number for transaction diff --git a/crates/kgraph_utils/src/mca.rs b/crates/kgraph_utils/src/mca.rs index ed96cd9b545..5ddee1fa514 100644 --- a/crates/kgraph_utils/src/mca.rs +++ b/crates/kgraph_utils/src/mca.rs @@ -77,7 +77,6 @@ fn get_dir_value_payment_method( api_enums::PaymentMethodType::ClassicReward => Ok(dirval!(RewardType = ClassicReward)), api_enums::PaymentMethodType::Evoucher => Ok(dirval!(RewardType = Evoucher)), - api_enums::PaymentMethodType::UpiCollect => Ok(dirval!(UpiType = UpiCollect)), api_enums::PaymentMethodType::SamsungPay => Ok(dirval!(WalletType = SamsungPay)), api_enums::PaymentMethodType::GoPay => Ok(dirval!(WalletType = GoPay)), api_enums::PaymentMethodType::KakaoPay => Ok(dirval!(WalletType = KakaoPay)), @@ -133,6 +132,8 @@ fn get_dir_value_payment_method( api_enums::PaymentMethodType::Oxxo => Ok(dirval!(VoucherType = Oxxo)), api_enums::PaymentMethodType::CardRedirect => Ok(dirval!(CardRedirectType = CardRedirect)), api_enums::PaymentMethodType::Venmo => Ok(dirval!(WalletType = Venmo)), + api_enums::PaymentMethodType::UpiIntent => Ok(dirval!(UpiType = UpiIntent)), + api_enums::PaymentMethodType::UpiCollect => Ok(dirval!(UpiType = UpiCollect)), } } diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rs index 1f92fd17e5c..2d8fb9bb382 100644 --- a/crates/router/src/compatibility/stripe/payment_intents/types.rs +++ b/crates/router/src/compatibility/stripe/payment_intents/types.rs @@ -74,7 +74,7 @@ pub enum StripeWallet { #[derive(Default, Serialize, PartialEq, Eq, Deserialize, Clone, Debug)] pub struct StripeUpi { - pub vpa_id: Option>, + pub vpa_id: masking::Secret, } #[derive(Debug, Default, Serialize, PartialEq, Eq, Deserialize, Clone)] @@ -143,7 +143,7 @@ impl From for payments::WalletData { impl From for payments::UpiData { fn from(upi_data: StripeUpi) -> Self { Self::Upi(payments::Upi { - vpa_id: upi_data.vpa_id, + vpa_id: Some(upi_data.vpa_id), }) } } From ae70012d05c106f5683cfed55c2d7a9d2b4ee7fc Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Fri, 24 May 2024 12:15:42 +0530 Subject: [PATCH 07/17] fix merge conflicts --- .../src/payment_method_data.rs | 18 +++++++++++++++--- crates/router/src/types/domain/payments.rs | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/crates/hyperswitch_domain_models/src/payment_method_data.rs b/crates/hyperswitch_domain_models/src/payment_method_data.rs index 9dc85c103e9..1bd5574b7e6 100644 --- a/crates/hyperswitch_domain_models/src/payment_method_data.rs +++ b/crates/hyperswitch_domain_models/src/payment_method_data.rs @@ -289,10 +289,20 @@ pub struct CryptoData { #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)] #[serde(rename_all = "snake_case")] -pub struct UpiData { +pub enum UpiData { + Upi(Upi), + UpiQr(UpiQr), +} + +#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)] +#[serde(rename_all = "snake_case")] +pub struct Upi { pub vpa_id: Option>, } +#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)] +pub struct UpiQr {} + #[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(rename_all = "snake_case")] pub enum VoucherData { @@ -690,8 +700,10 @@ impl From for CryptoData { impl From for UpiData { fn from(value: api_models::payments::UpiData) -> Self { - let api_models::payments::UpiData { vpa_id } = value; - Self { vpa_id } + match value { + api_models::payments::UpiData::Upi(upi) => Self::Upi(Upi { vpa_id: upi.vpa_id }), + api_models::payments::UpiData::UpiQr(_) => Self::UpiQr(UpiQr {}), + } } } diff --git a/crates/router/src/types/domain/payments.rs b/crates/router/src/types/domain/payments.rs index 7b1f3365490..35e8d9b54fe 100644 --- a/crates/router/src/types/domain/payments.rs +++ b/crates/router/src/types/domain/payments.rs @@ -5,6 +5,6 @@ pub use hyperswitch_domain_models::payment_method_data::{ GooglePayPaymentMethodInfo, GooglePayRedirectData, GooglePayThirdPartySdkData, GooglePayWalletData, GpayTokenizationData, IndomaretVoucherData, KakaoPayRedirection, MbWayRedirection, PayLaterData, PaymentMethodData, SamsungPayWalletData, - SepaAndBacsBillingDetails, SwishQrData, TouchNGoRedirection, VoucherData, WalletData, + SepaAndBacsBillingDetails, SwishQrData, TouchNGoRedirection, VoucherData, UpiData, Upi, UpiQr, WalletData, WeChatPayQr, }; From 90675b4dd56514f121860f2f6d4ec3e46b0d8e8c Mon Sep 17 00:00:00 2001 From: "hyperswitch-bot[bot]" <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 06:46:29 +0000 Subject: [PATCH 08/17] chore: run formatter --- crates/hyperswitch_domain_models/src/payment_method_data.rs | 6 +++--- crates/router/src/types/domain/payments.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/hyperswitch_domain_models/src/payment_method_data.rs b/crates/hyperswitch_domain_models/src/payment_method_data.rs index 1bd5574b7e6..8853b33533c 100644 --- a/crates/hyperswitch_domain_models/src/payment_method_data.rs +++ b/crates/hyperswitch_domain_models/src/payment_method_data.rs @@ -701,9 +701,9 @@ impl From for CryptoData { impl From for UpiData { fn from(value: api_models::payments::UpiData) -> Self { match value { - api_models::payments::UpiData::Upi(upi) => Self::Upi(Upi { vpa_id: upi.vpa_id }), - api_models::payments::UpiData::UpiQr(_) => Self::UpiQr(UpiQr {}), - } + api_models::payments::UpiData::Upi(upi) => Self::Upi(Upi { vpa_id: upi.vpa_id }), + api_models::payments::UpiData::UpiQr(_) => Self::UpiQr(UpiQr {}), + } } } diff --git a/crates/router/src/types/domain/payments.rs b/crates/router/src/types/domain/payments.rs index 35e8d9b54fe..4a73570c9ad 100644 --- a/crates/router/src/types/domain/payments.rs +++ b/crates/router/src/types/domain/payments.rs @@ -5,6 +5,6 @@ pub use hyperswitch_domain_models::payment_method_data::{ GooglePayPaymentMethodInfo, GooglePayRedirectData, GooglePayThirdPartySdkData, GooglePayWalletData, GpayTokenizationData, IndomaretVoucherData, KakaoPayRedirection, MbWayRedirection, PayLaterData, PaymentMethodData, SamsungPayWalletData, - SepaAndBacsBillingDetails, SwishQrData, TouchNGoRedirection, VoucherData, UpiData, Upi, UpiQr, WalletData, - WeChatPayQr, + SepaAndBacsBillingDetails, SwishQrData, TouchNGoRedirection, Upi, UpiData, UpiQr, VoucherData, + WalletData, WeChatPayQr, }; From 3b8a8504dcc750512ea60471c65c3cf25dcd7337 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Fri, 24 May 2024 13:38:19 +0530 Subject: [PATCH 09/17] change the next action type --- crates/api_models/src/payments.rs | 13 +++++++++++-- .../stripe/payment_intents/types.rs | 6 ++++++ .../stripe/setup_intents/types.rs | 8 +++++++- .../src/connector/iatapay/transformers.rs | 4 ++-- crates/router/src/core/payments.rs | 1 + .../router/src/core/payments/transformers.rs | 19 +++++++++++++++++++ 6 files changed, 46 insertions(+), 5 deletions(-) diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index 4e398e8729c..8768205cf60 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -1648,8 +1648,8 @@ impl GetPaymentMethodType for CryptoData { impl GetPaymentMethodType for UpiData { fn get_payment_method_type(&self) -> api_enums::PaymentMethodType { match self { - UpiData::Upi(_) => api_enums::PaymentMethodType::UpiCollect, - UpiData::UpiQr(_) => api_enums::PaymentMethodType::UpiIntent, + Self::Upi(_) => api_enums::PaymentMethodType::UpiCollect, + Self::UpiQr(_) => api_enums::PaymentMethodType::UpiIntent, } } } @@ -2953,6 +2953,8 @@ pub enum NextActionData { /// The url to fetch qr code data qr_code_data_url: Option, }, + /// Contains url to fetch Qr code data + FetchQrCodeInformation { qr_code_fetch_url: Url }, /// Contains the download url and the reference number for transaction DisplayVoucherInformation { #[schema(value_type = String)] @@ -3030,6 +3032,13 @@ pub enum QrCodeInformation { }, } +#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)] +pub struct FetchQrCodeInformation +{ pub qr_code_fetch_url: Url } + + + + #[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)] pub struct BankTransferNextStepsData { /// The instructions for performing a bank transfer diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rs index 2d8fb9bb382..c536a7cd1df 100644 --- a/crates/router/src/compatibility/stripe/payment_intents/types.rs +++ b/crates/router/src/compatibility/stripe/payment_intents/types.rs @@ -820,6 +820,9 @@ pub enum StripeNextAction { qr_code_url: Option, qr_code_data_url: Option, }, + FetchQrCodeInformation { + qr_code_fetch_url: url::Url, + }, DisplayVoucherInformation { voucher_details: payments::VoucherNextStepData, }, @@ -861,6 +864,9 @@ pub(crate) fn into_stripe_next_action( qr_code_url, qr_code_data_url, }, + payments::NextActionData::FetchQrCodeInformation { qr_code_fetch_url } => { + StripeNextAction::FetchQrCodeInformation { qr_code_fetch_url } + } payments::NextActionData::DisplayVoucherInformation { voucher_details } => { StripeNextAction::DisplayVoucherInformation { voucher_details } } diff --git a/crates/router/src/compatibility/stripe/setup_intents/types.rs b/crates/router/src/compatibility/stripe/setup_intents/types.rs index a959dcebce4..ba01ccfff46 100644 --- a/crates/router/src/compatibility/stripe/setup_intents/types.rs +++ b/crates/router/src/compatibility/stripe/setup_intents/types.rs @@ -383,6 +383,7 @@ pub enum StripeNextAction { qr_code_url: Option, qr_code_data_url: Option, }, + FetchQrCodeInformation { qr_code_fetch_url: url::Url }, DisplayVoucherInformation { voucher_details: payments::VoucherNextStepData, }, @@ -412,7 +413,7 @@ pub(crate) fn into_stripe_next_action( }, payments::NextActionData::ThirdPartySdkSessionToken { session_token } => { StripeNextAction::ThirdPartySdkSessionToken { session_token } - } + }, payments::NextActionData::QrCodeInformation { image_data_url, display_to_timestamp, @@ -424,6 +425,11 @@ pub(crate) fn into_stripe_next_action( qr_code_url, qr_code_data_url, }, + payments::NextActionData::FetchQrCodeInformation { + qr_code_fetch_url + } => StripeNextAction::FetchQrCodeInformation { + qr_code_fetch_url + }, payments::NextActionData::DisplayVoucherInformation { voucher_details } => { StripeNextAction::DisplayVoucherInformation { voucher_details } } diff --git a/crates/router/src/connector/iatapay/transformers.rs b/crates/router/src/connector/iatapay/transformers.rs index 33d0a7595c8..cadbb9621be 100644 --- a/crates/router/src/connector/iatapay/transformers.rs +++ b/crates/router/src/connector/iatapay/transformers.rs @@ -314,8 +314,8 @@ fn get_iatpay_response( let (connector_metadata, redirection_data) = match checkout_methods.redirect.redirect_url.ends_with("qr") { true => { - let qr_code_info = api_models::payments::QrCodeInformation::QrCodeDataUrl { - qr_code_data_url: url::Url::parse( + let qr_code_info = api_models::payments::FetchQrCodeInformation { + qr_code_fetch_url: url::Url::parse( &checkout_methods.redirect.redirect_url, ) .change_context(errors::ConnectorError::ResponseHandlingFailed)?, diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs index a6befa5269e..6e1966233ff 100644 --- a/crates/router/src/core/payments.rs +++ b/crates/router/src/core/payments.rs @@ -1009,6 +1009,7 @@ impl PaymentRedirectFlow for PaymentRedirectCompleteAuthorize { api_models::payments::NextActionData::DisplayBankTransferInformation { .. } => None, api_models::payments::NextActionData::ThirdPartySdkSessionToken { .. } => None, api_models::payments::NextActionData::QrCodeInformation{..} => None, + api_models::payments::NextActionData::FetchQrCodeInformation{..} => None, api_models::payments::NextActionData::DisplayVoucherInformation{ .. } => None, api_models::payments::NextActionData::WaitScreenInformation{..} => None, api_models::payments::NextActionData::ThreeDsInvoke{..} => None, diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index 592dbd3e19c..8f9ac3b05da 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -535,6 +535,8 @@ where let next_action_containing_qr_code_url = qr_code_next_steps_check(payment_attempt.clone())?; + let next_action_containing_fetch_qr_code_url = fetch_qr_code_url_next_steps_check(payment_attempt.clone())?; + let next_action_containing_wait_screen = wait_screen_next_steps_check(payment_attempt.clone())?; @@ -559,6 +561,11 @@ where .or(next_action_containing_qr_code_url.map(|qr_code_data| { api_models::payments::NextActionData::foreign_from(qr_code_data) })) + .or(next_action_containing_fetch_qr_code_url.map(|fetch_qr_code_data| { + api_models::payments::NextActionData::FetchQrCodeInformation { + qr_code_fetch_url: fetch_qr_code_data.qr_code_fetch_url + } + })) .or(next_action_containing_wait_screen.map(|wait_screen_data| { api_models::payments::NextActionData::WaitScreenInformation { display_from_timestamp: wait_screen_data.display_from_timestamp, @@ -849,6 +856,18 @@ pub fn qr_code_next_steps_check( Ok(qr_code_instructions) } + +pub fn fetch_qr_code_url_next_steps_check( + payment_attempt: storage::PaymentAttempt, +) -> RouterResult> { + let qr_code_steps: Option> = payment_attempt + .connector_metadata + .map(|metadata| metadata.parse_value("FetchQrCodeInformation")); + + let qr_code_fetch_url = qr_code_steps.transpose().ok().flatten(); + Ok(qr_code_fetch_url) +} + pub fn wait_screen_next_steps_check( payment_attempt: storage::PaymentAttempt, ) -> RouterResult> { From 1c032b624fa079641071ce12d60c58174767c896 Mon Sep 17 00:00:00 2001 From: "hyperswitch-bot[bot]" <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 08:09:06 +0000 Subject: [PATCH 10/17] chore: run formatter --- crates/api_models/src/payments.rs | 8 +++----- .../compatibility/stripe/setup_intents/types.rs | 14 +++++++------- .../router/src/connector/iatapay/transformers.rs | 2 +- crates/router/src/core/payments/transformers.rs | 11 ++++++----- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index 8768205cf60..bb85c7716e0 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -3033,11 +3033,9 @@ pub enum QrCodeInformation { } #[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)] -pub struct FetchQrCodeInformation -{ pub qr_code_fetch_url: Url } - - - +pub struct FetchQrCodeInformation { + pub qr_code_fetch_url: Url, +} #[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)] pub struct BankTransferNextStepsData { diff --git a/crates/router/src/compatibility/stripe/setup_intents/types.rs b/crates/router/src/compatibility/stripe/setup_intents/types.rs index ba01ccfff46..c34abdd2f51 100644 --- a/crates/router/src/compatibility/stripe/setup_intents/types.rs +++ b/crates/router/src/compatibility/stripe/setup_intents/types.rs @@ -383,7 +383,9 @@ pub enum StripeNextAction { qr_code_url: Option, qr_code_data_url: Option, }, - FetchQrCodeInformation { qr_code_fetch_url: url::Url }, + FetchQrCodeInformation { + qr_code_fetch_url: url::Url, + }, DisplayVoucherInformation { voucher_details: payments::VoucherNextStepData, }, @@ -413,7 +415,7 @@ pub(crate) fn into_stripe_next_action( }, payments::NextActionData::ThirdPartySdkSessionToken { session_token } => { StripeNextAction::ThirdPartySdkSessionToken { session_token } - }, + } payments::NextActionData::QrCodeInformation { image_data_url, display_to_timestamp, @@ -425,11 +427,9 @@ pub(crate) fn into_stripe_next_action( qr_code_url, qr_code_data_url, }, - payments::NextActionData::FetchQrCodeInformation { - qr_code_fetch_url - } => StripeNextAction::FetchQrCodeInformation { - qr_code_fetch_url - }, + payments::NextActionData::FetchQrCodeInformation { qr_code_fetch_url } => { + StripeNextAction::FetchQrCodeInformation { qr_code_fetch_url } + } payments::NextActionData::DisplayVoucherInformation { voucher_details } => { StripeNextAction::DisplayVoucherInformation { voucher_details } } diff --git a/crates/router/src/connector/iatapay/transformers.rs b/crates/router/src/connector/iatapay/transformers.rs index cadbb9621be..edc858ae6b4 100644 --- a/crates/router/src/connector/iatapay/transformers.rs +++ b/crates/router/src/connector/iatapay/transformers.rs @@ -314,7 +314,7 @@ fn get_iatpay_response( let (connector_metadata, redirection_data) = match checkout_methods.redirect.redirect_url.ends_with("qr") { true => { - let qr_code_info = api_models::payments::FetchQrCodeInformation { + let qr_code_info = api_models::payments::FetchQrCodeInformation { qr_code_fetch_url: url::Url::parse( &checkout_methods.redirect.redirect_url, ) diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index 8f9ac3b05da..59074be4bf6 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -535,7 +535,8 @@ where let next_action_containing_qr_code_url = qr_code_next_steps_check(payment_attempt.clone())?; - let next_action_containing_fetch_qr_code_url = fetch_qr_code_url_next_steps_check(payment_attempt.clone())?; + let next_action_containing_fetch_qr_code_url = + fetch_qr_code_url_next_steps_check(payment_attempt.clone())?; let next_action_containing_wait_screen = wait_screen_next_steps_check(payment_attempt.clone())?; @@ -856,13 +857,13 @@ pub fn qr_code_next_steps_check( Ok(qr_code_instructions) } - pub fn fetch_qr_code_url_next_steps_check( payment_attempt: storage::PaymentAttempt, ) -> RouterResult> { - let qr_code_steps: Option> = payment_attempt - .connector_metadata - .map(|metadata| metadata.parse_value("FetchQrCodeInformation")); + let qr_code_steps: Option> = + payment_attempt + .connector_metadata + .map(|metadata| metadata.parse_value("FetchQrCodeInformation")); let qr_code_fetch_url = qr_code_steps.transpose().ok().flatten(); Ok(qr_code_fetch_url) From 075bb1530277e9425c653ed7ebe686dfcc82895d Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Fri, 24 May 2024 13:48:09 +0530 Subject: [PATCH 11/17] remove qr_code_data_url, --- crates/api_models/src/payments.rs | 5 ----- .../src/compatibility/stripe/payment_intents/types.rs | 3 --- .../src/compatibility/stripe/setup_intents/types.rs | 3 --- crates/router/src/core/payments/transformers.rs | 11 ----------- 4 files changed, 22 deletions(-) diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index bb85c7716e0..9b3e461e97a 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -2950,8 +2950,6 @@ pub enum NextActionData { #[schema(value_type = String)] /// The url for Qr code given by the connector qr_code_url: Option, - /// The url to fetch qr code data - qr_code_data_url: Option, }, /// Contains url to fetch Qr code data FetchQrCodeInformation { qr_code_fetch_url: Url }, @@ -3027,9 +3025,6 @@ pub enum QrCodeInformation { qr_code_url: Url, display_to_timestamp: Option, }, - QrCodeDataUrl { - qr_code_data_url: Url, - }, } #[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)] diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rs index c536a7cd1df..d374ac74dec 100644 --- a/crates/router/src/compatibility/stripe/payment_intents/types.rs +++ b/crates/router/src/compatibility/stripe/payment_intents/types.rs @@ -818,7 +818,6 @@ pub enum StripeNextAction { image_data_url: Option, display_to_timestamp: Option, qr_code_url: Option, - qr_code_data_url: Option, }, FetchQrCodeInformation { qr_code_fetch_url: url::Url, @@ -857,12 +856,10 @@ pub(crate) fn into_stripe_next_action( image_data_url, display_to_timestamp, qr_code_url, - qr_code_data_url, } => StripeNextAction::QrCodeInformation { image_data_url, display_to_timestamp, qr_code_url, - qr_code_data_url, }, payments::NextActionData::FetchQrCodeInformation { qr_code_fetch_url } => { StripeNextAction::FetchQrCodeInformation { qr_code_fetch_url } diff --git a/crates/router/src/compatibility/stripe/setup_intents/types.rs b/crates/router/src/compatibility/stripe/setup_intents/types.rs index c34abdd2f51..9314cd42943 100644 --- a/crates/router/src/compatibility/stripe/setup_intents/types.rs +++ b/crates/router/src/compatibility/stripe/setup_intents/types.rs @@ -381,7 +381,6 @@ pub enum StripeNextAction { image_data_url: Option, display_to_timestamp: Option, qr_code_url: Option, - qr_code_data_url: Option, }, FetchQrCodeInformation { qr_code_fetch_url: url::Url, @@ -420,12 +419,10 @@ pub(crate) fn into_stripe_next_action( image_data_url, display_to_timestamp, qr_code_url, - qr_code_data_url, } => StripeNextAction::QrCodeInformation { image_data_url, display_to_timestamp, qr_code_url, - qr_code_data_url, }, payments::NextActionData::FetchQrCodeInformation { qr_code_fetch_url } => { StripeNextAction::FetchQrCodeInformation { qr_code_fetch_url } diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs index 59074be4bf6..84fc6dc69f5 100644 --- a/crates/router/src/core/payments/transformers.rs +++ b/crates/router/src/core/payments/transformers.rs @@ -1064,7 +1064,6 @@ impl ForeignFrom for api_models::paymen image_data_url: Some(image_data_url), qr_code_url: Some(qr_code_url), display_to_timestamp, - qr_code_data_url: None, }, api_models::payments::QrCodeInformation::QrDataUrl { image_data_url, @@ -1073,7 +1072,6 @@ impl ForeignFrom for api_models::paymen image_data_url: Some(image_data_url), display_to_timestamp, qr_code_url: None, - qr_code_data_url: None, }, api_models::payments::QrCodeInformation::QrCodeImageUrl { qr_code_url, @@ -1082,16 +1080,7 @@ impl ForeignFrom for api_models::paymen qr_code_url: Some(qr_code_url), image_data_url: None, display_to_timestamp, - qr_code_data_url: None, }, - api_models::payments::QrCodeInformation::QrCodeDataUrl { qr_code_data_url } => { - Self::QrCodeInformation { - qr_code_data_url: Some(qr_code_data_url), - image_data_url: None, - display_to_timestamp: None, - qr_code_url: None, - } - } } } } From ee63af99530704d14edd4bb58739812eb102b177 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Fri, 24 May 2024 16:00:28 +0530 Subject: [PATCH 12/17] fix merge conflict --- crates/api_models/src/payments.rs | 6 +++--- crates/openapi/src/openapi.rs | 3 +++ crates/router/src/connector/iatapay/transformers.rs | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index 9245c9d5ca1..9436faf95e3 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -2120,20 +2120,20 @@ pub struct CryptoData { pub pay_currency: Option, } -#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)] +#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)] #[serde(rename_all = "snake_case")] pub enum UpiData { Upi(Upi), UpiQr(UpiQr), } -#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)] +#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)] #[serde(rename_all = "snake_case")] pub struct Upi { pub vpa_id: Option>, } -#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)] +#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)] pub struct UpiQr {} #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)] diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs index 8830c689937..1459c1f52fd 100644 --- a/crates/openapi/src/openapi.rs +++ b/crates/openapi/src/openapi.rs @@ -291,6 +291,8 @@ Never share your secret api keys. Keep them guarded and secure. api_models::payments::CryptoData, api_models::payments::RewardData, api_models::payments::UpiData, + api_models::payments::Upi, + api_models::payments::UpiQr, api_models::payments::VoucherData, api_models::payments::BoletoVoucherData, api_models::payments::AlfamartVoucherData, @@ -308,6 +310,7 @@ Never share your secret api keys. Keep them guarded and secure. api_models::payments::ApplepayConnectorMetadataRequest, api_models::payments::SessionTokenInfo, api_models::payments::SwishQrData, + api_models::payments::UpiData, api_models::payments::AirwallexData, api_models::payments::NoonData, api_models::payments::OrderDetails, diff --git a/crates/router/src/connector/iatapay/transformers.rs b/crates/router/src/connector/iatapay/transformers.rs index 7be74d69e87..d8febcf3c6a 100644 --- a/crates/router/src/connector/iatapay/transformers.rs +++ b/crates/router/src/connector/iatapay/transformers.rs @@ -345,6 +345,7 @@ fn get_iatpay_response( network_txn_id: None, connector_response_reference_id: connector_response_reference_id.clone(), incremental_authorization_allowed: None, + charge_id: None, } } None => types::PaymentsResponseData::TransactionResponse { From 3025a38ae00614268c7f4e7ab5686d838c8a710d Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Fri, 24 May 2024 16:23:46 +0530 Subject: [PATCH 13/17] fix clippy error --- crates/api_models/src/payments.rs | 1 + openapi/openapi_spec.json | 52 +++++++++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index 9436faf95e3..704432e6b55 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -2130,6 +2130,7 @@ pub enum UpiData { #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)] #[serde(rename_all = "snake_case")] pub struct Upi { + #[schema(value_type = Option)] pub vpa_id: Option>, } diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json index 47da1ae1074..738e09234ef 100644 --- a/openapi/openapi_spec.json +++ b/openapi/openapi_spec.json @@ -11756,6 +11756,25 @@ } } }, + { + "type": "object", + "description": "Contains url to fetch Qr code data", + "required": [ + "qr_code_fetch_url", + "type" + ], + "properties": { + "qr_code_fetch_url": { + "$ref": "#/components/schemas/Url" + }, + "type": { + "type": "string", + "enum": [ + "fetch_qr_code_information" + ] + } + } + }, { "type": "object", "description": "Contains the download url and the reference number for transaction", @@ -13510,6 +13529,7 @@ "trustly", "twint", "upi_collect", + "upi_intent", "vipps", "venmo", "walley", @@ -18653,16 +18673,44 @@ }, "additionalProperties": false }, - "UpiData": { + "Upi": { "type": "object", "properties": { "vpa_id": { "type": "string", - "example": "successtest@iata", "nullable": true } } }, + "UpiData": { + "oneOf": [ + { + "type": "object", + "required": [ + "upi" + ], + "properties": { + "upi": { + "$ref": "#/components/schemas/Upi" + } + } + }, + { + "type": "object", + "required": [ + "upi_qr" + ], + "properties": { + "upi_qr": { + "$ref": "#/components/schemas/UpiQr" + } + } + } + ] + }, + "UpiQr": { + "type": "object" + }, "ValueType": { "oneOf": [ { From c4627c7ee1173cd452cd5ccb80ecf4d4d6763988 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Sun, 26 May 2024 18:47:39 +0530 Subject: [PATCH 14/17] update payment method data --- crates/api_models/src/payments.rs | 14 +++++++------- .../src/payment_method_data.rs | 12 ++++++------ crates/openapi/src/openapi.rs | 4 ++-- .../compatibility/stripe/payment_intents/types.rs | 4 ++-- .../router/src/connector/iatapay/transformers.rs | 4 ++-- crates/router/src/types/domain/payments.rs | 2 +- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index 704432e6b55..93cbfcc9e7a 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -1665,8 +1665,8 @@ impl GetPaymentMethodType for CryptoData { impl GetPaymentMethodType for UpiData { fn get_payment_method_type(&self) -> api_enums::PaymentMethodType { match self { - Self::Upi(_) => api_enums::PaymentMethodType::UpiCollect, - Self::UpiQr(_) => api_enums::PaymentMethodType::UpiIntent, + Self::UpiCollect(_) => api_enums::PaymentMethodType::UpiCollect, + Self::UpiIntent(_) => api_enums::PaymentMethodType::UpiIntent, } } } @@ -2123,19 +2123,19 @@ pub struct CryptoData { #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)] #[serde(rename_all = "snake_case")] pub enum UpiData { - Upi(Upi), - UpiQr(UpiQr), + UpiCollect(UpiCollectData), + UpiIntent(UpiIntentData), } #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)] #[serde(rename_all = "snake_case")] -pub struct Upi { - #[schema(value_type = Option)] +pub struct UpiCollectData { + #[schema(value_type = Option, example = "successtest@iata")] pub vpa_id: Option>, } #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)] -pub struct UpiQr {} +pub struct UpiIntentData {} #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)] pub struct SofortBilling { diff --git a/crates/hyperswitch_domain_models/src/payment_method_data.rs b/crates/hyperswitch_domain_models/src/payment_method_data.rs index 8853b33533c..67209e7cce2 100644 --- a/crates/hyperswitch_domain_models/src/payment_method_data.rs +++ b/crates/hyperswitch_domain_models/src/payment_method_data.rs @@ -290,18 +290,18 @@ pub struct CryptoData { #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)] #[serde(rename_all = "snake_case")] pub enum UpiData { - Upi(Upi), - UpiQr(UpiQr), + UpiCollect(UpiCollectData), + UpiIntent(UpiIntentData), } #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)] #[serde(rename_all = "snake_case")] -pub struct Upi { +pub struct UpiCollectData { pub vpa_id: Option>, } #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)] -pub struct UpiQr {} +pub struct UpiIntentData {} #[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(rename_all = "snake_case")] @@ -701,8 +701,8 @@ impl From for CryptoData { impl From for UpiData { fn from(value: api_models::payments::UpiData) -> Self { match value { - api_models::payments::UpiData::Upi(upi) => Self::Upi(Upi { vpa_id: upi.vpa_id }), - api_models::payments::UpiData::UpiQr(_) => Self::UpiQr(UpiQr {}), + api_models::payments::UpiData::UpiCollect(upi) => Self::UpiCollect(UpiCollectData { vpa_id: upi.vpa_id }), + api_models::payments::UpiData::UpiIntent(_) => Self::UpiIntent(UpiIntentData {}), } } } diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs index 1459c1f52fd..2aa01c23c8b 100644 --- a/crates/openapi/src/openapi.rs +++ b/crates/openapi/src/openapi.rs @@ -291,8 +291,8 @@ Never share your secret api keys. Keep them guarded and secure. api_models::payments::CryptoData, api_models::payments::RewardData, api_models::payments::UpiData, - api_models::payments::Upi, - api_models::payments::UpiQr, + api_models::payments::UpiCollectData, + api_models::payments::UpiIntentData, api_models::payments::VoucherData, api_models::payments::BoletoVoucherData, api_models::payments::AlfamartVoucherData, diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rs index d374ac74dec..c5fcfeac8c4 100644 --- a/crates/router/src/compatibility/stripe/payment_intents/types.rs +++ b/crates/router/src/compatibility/stripe/payment_intents/types.rs @@ -142,7 +142,7 @@ impl From for payments::WalletData { impl From for payments::UpiData { fn from(upi_data: StripeUpi) -> Self { - Self::Upi(payments::Upi { + Self::UpiCollect(payments::UpiCollectData { vpa_id: Some(upi_data.vpa_id), }) } @@ -894,7 +894,7 @@ fn get_pmd_based_on_payment_method_type( ) -> Option { match payment_method_type { Some(api_enums::PaymentMethodType::UpiIntent) => Some(payments::PaymentMethodData::Upi( - payments::UpiData::UpiQr(payments::UpiQr {}), + payments::UpiData::UpiIntent(payments::UpiIntentData {}), )), _ => None, } diff --git a/crates/router/src/connector/iatapay/transformers.rs b/crates/router/src/connector/iatapay/transformers.rs index d8febcf3c6a..b36792e90ca 100644 --- a/crates/router/src/connector/iatapay/transformers.rs +++ b/crates/router/src/connector/iatapay/transformers.rs @@ -149,13 +149,13 @@ impl let (payer_info, preferred_checkout_method) = match item.router_data.request.payment_method_data.clone() { domain::PaymentMethodData::Upi(upi_type) => match upi_type { - domain::UpiData::Upi(upi_data) => ( + domain::UpiData::UpiCollect(upi_data) => ( upi_data.vpa_id.map(|id| PayerInfo { token_id: id.switch_strategy(), }), Some(PreferredCheckoutMethod::Vpa), ), - domain::UpiData::UpiQr(_) => (None, Some(PreferredCheckoutMethod::Qr)), + domain::UpiData::UpiIntent(_) => (None, Some(PreferredCheckoutMethod::Qr)), }, domain::PaymentMethodData::Card(_) | domain::PaymentMethodData::CardRedirect(_) diff --git a/crates/router/src/types/domain/payments.rs b/crates/router/src/types/domain/payments.rs index 4a73570c9ad..b89d5d49e0b 100644 --- a/crates/router/src/types/domain/payments.rs +++ b/crates/router/src/types/domain/payments.rs @@ -5,6 +5,6 @@ pub use hyperswitch_domain_models::payment_method_data::{ GooglePayPaymentMethodInfo, GooglePayRedirectData, GooglePayThirdPartySdkData, GooglePayWalletData, GpayTokenizationData, IndomaretVoucherData, KakaoPayRedirection, MbWayRedirection, PayLaterData, PaymentMethodData, SamsungPayWalletData, - SepaAndBacsBillingDetails, SwishQrData, TouchNGoRedirection, Upi, UpiData, UpiQr, VoucherData, + SepaAndBacsBillingDetails, SwishQrData, TouchNGoRedirection, UpiCollectData, UpiData, UpiIntentData, VoucherData, WalletData, WeChatPayQr, }; From bfdaf7ce3f8e8e6bef32b68a9c72ce787c686ca6 Mon Sep 17 00:00:00 2001 From: "hyperswitch-bot[bot]" <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Date: Sun, 26 May 2024 13:18:31 +0000 Subject: [PATCH 15/17] chore: run formatter --- crates/hyperswitch_domain_models/src/payment_method_data.rs | 4 +++- crates/router/src/types/domain/payments.rs | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/hyperswitch_domain_models/src/payment_method_data.rs b/crates/hyperswitch_domain_models/src/payment_method_data.rs index 67209e7cce2..7517918ed95 100644 --- a/crates/hyperswitch_domain_models/src/payment_method_data.rs +++ b/crates/hyperswitch_domain_models/src/payment_method_data.rs @@ -701,7 +701,9 @@ impl From for CryptoData { impl From for UpiData { fn from(value: api_models::payments::UpiData) -> Self { match value { - api_models::payments::UpiData::UpiCollect(upi) => Self::UpiCollect(UpiCollectData { vpa_id: upi.vpa_id }), + api_models::payments::UpiData::UpiCollect(upi) => { + Self::UpiCollect(UpiCollectData { vpa_id: upi.vpa_id }) + } api_models::payments::UpiData::UpiIntent(_) => Self::UpiIntent(UpiIntentData {}), } } diff --git a/crates/router/src/types/domain/payments.rs b/crates/router/src/types/domain/payments.rs index b89d5d49e0b..51d3210a70f 100644 --- a/crates/router/src/types/domain/payments.rs +++ b/crates/router/src/types/domain/payments.rs @@ -5,6 +5,6 @@ pub use hyperswitch_domain_models::payment_method_data::{ GooglePayPaymentMethodInfo, GooglePayRedirectData, GooglePayThirdPartySdkData, GooglePayWalletData, GpayTokenizationData, IndomaretVoucherData, KakaoPayRedirection, MbWayRedirection, PayLaterData, PaymentMethodData, SamsungPayWalletData, - SepaAndBacsBillingDetails, SwishQrData, TouchNGoRedirection, UpiCollectData, UpiData, UpiIntentData, VoucherData, - WalletData, WeChatPayQr, + SepaAndBacsBillingDetails, SwishQrData, TouchNGoRedirection, UpiCollectData, UpiData, + UpiIntentData, VoucherData, WalletData, WeChatPayQr, }; From 2d03a696b0d33c217e032fc9f01751321fbc1fe3 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Mon, 27 May 2024 13:18:04 +0530 Subject: [PATCH 16/17] fix open api spec --- crates/api_models/src/payments.rs | 5 ++++- openapi/openapi_spec.json | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs index 93cbfcc9e7a..29a7d8fb6a4 100644 --- a/crates/api_models/src/payments.rs +++ b/crates/api_models/src/payments.rs @@ -2970,7 +2970,10 @@ pub enum NextActionData { qr_code_url: Option, }, /// Contains url to fetch Qr code data - FetchQrCodeInformation { qr_code_fetch_url: Url }, + FetchQrCodeInformation { + #[schema(value_type = String)] + qr_code_fetch_url: Url, + }, /// Contains the download url and the reference number for transaction DisplayVoucherInformation { #[schema(value_type = String)] diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json index 738e09234ef..b5c8df7c9e5 100644 --- a/openapi/openapi_spec.json +++ b/openapi/openapi_spec.json @@ -11765,7 +11765,7 @@ ], "properties": { "qr_code_fetch_url": { - "$ref": "#/components/schemas/Url" + "type": "string" }, "type": { "type": "string", @@ -18673,11 +18673,12 @@ }, "additionalProperties": false }, - "Upi": { + "UpiCollectData": { "type": "object", "properties": { "vpa_id": { "type": "string", + "example": "successtest@iata", "nullable": true } } @@ -18687,28 +18688,28 @@ { "type": "object", "required": [ - "upi" + "upi_collect" ], "properties": { - "upi": { - "$ref": "#/components/schemas/Upi" + "upi_collect": { + "$ref": "#/components/schemas/UpiCollectData" } } }, { "type": "object", "required": [ - "upi_qr" + "upi_intent" ], "properties": { - "upi_qr": { - "$ref": "#/components/schemas/UpiQr" + "upi_intent": { + "$ref": "#/components/schemas/UpiIntentData" } } } ] }, - "UpiQr": { + "UpiIntentData": { "type": "object" }, "ValueType": { From a81a6a3733535ecca442fa2346362f7964a035bb Mon Sep 17 00:00:00 2001 From: SamraatBansal <55536657+SamraatBansal@users.noreply.github.com> Date: Mon, 27 May 2024 16:19:01 +0530 Subject: [PATCH 17/17] Update crates/openapi/src/openapi.rs --- crates/openapi/src/openapi.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs index 2aa01c23c8b..9d1983e1eba 100644 --- a/crates/openapi/src/openapi.rs +++ b/crates/openapi/src/openapi.rs @@ -310,7 +310,6 @@ Never share your secret api keys. Keep them guarded and secure. api_models::payments::ApplepayConnectorMetadataRequest, api_models::payments::SessionTokenInfo, api_models::payments::SwishQrData, - api_models::payments::UpiData, api_models::payments::AirwallexData, api_models::payments::NoonData, api_models::payments::OrderDetails,