Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(ucs): added upi_source support for upi (#10675)
kanikac199310630561548
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex 154110e772..22444a4251 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -37992,6 +37992,14 @@"description": "Masked VPA ID","example": "ab********@okhdfcbank","nullable": true+ },+ "upi_source": {+ "allOf": [+ {+ "$ref": "#/components/schemas/UpiSource"+ }+ ],+ "nullable": true}}},@@ -38000,8 +38008,17 @@"properties": {"vpa_id": {"type": "string",+ "description": "The Virtual Payment Address (VPA) for UPI collect payment","example": "successtest@iata","nullable": true+ },+ "upi_source": {+ "allOf": [+ {+ "$ref": "#/components/schemas/UpiSource"+ }+ ],+ "nullable": true}}},@@ -38043,10 +38060,30 @@]},"UpiIntentData": {- "type": "object"+ "type": "object",+ "properties": {+ "upi_source": {+ "allOf": [+ {+ "$ref": "#/components/schemas/UpiSource"+ }+ ],+ "nullable": true+ }+ }},"UpiQrData": {- "type": "object"+ "type": "object",+ "properties": {+ "upi_source": {+ "allOf": [+ {+ "$ref": "#/components/schemas/UpiSource"+ }+ ],+ "nullable": true+ }+ }},"UpiResponse": {"allOf": [@@ -38063,6 +38100,16 @@}]},+ "UpiSource": {+ "type": "string",+ "description": "The source type for UPI payments. This indicates what payment source is being used for the UPI transaction.",+ "enum": [+ "UPI_CC",+ "UPI_CL",+ "UPI_ACCOUNT",+ "UPI_CC_CL"+ ]+ },"ValueType": {"oneOf": [{diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex f1f445b862..2bea87699b 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -27922,6 +27922,14 @@"description": "Masked VPA ID","example": "ab********@okhdfcbank","nullable": true+ },+ "upi_source": {+ "allOf": [+ {+ "$ref": "#/components/schemas/UpiSource"+ }+ ],+ "nullable": true}}},@@ -27930,8 +27938,17 @@"properties": {"vpa_id": {"type": "string",+ "description": "The Virtual Payment Address (VPA) for UPI collect payment","example": "successtest@iata","nullable": true+ },+ "upi_source": {+ "allOf": [+ {+ "$ref": "#/components/schemas/UpiSource"+ }+ ],+ "nullable": true}}},@@ -27973,10 +27990,30 @@]},"UpiIntentData": {- "type": "object"+ "type": "object",+ "properties": {+ "upi_source": {+ "allOf": [+ {+ "$ref": "#/components/schemas/UpiSource"+ }+ ],+ "nullable": true+ }+ }},"UpiQrData": {- "type": "object"+ "type": "object",+ "properties": {+ "upi_source": {+ "allOf": [+ {+ "$ref": "#/components/schemas/UpiSource"+ }+ ],+ "nullable": true+ }+ }},"UpiResponse": {"allOf": [@@ -27993,6 +28030,16 @@}]},+ "UpiSource": {+ "type": "string",+ "description": "The source type for UPI payments. This indicates what payment source is being used for the UPI transaction.",+ "enum": [+ "UPI_CC",+ "UPI_CL",+ "UPI_ACCOUNT",+ "UPI_CC_CL"+ ]+ },"ValueType": {"oneOf": [{diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex a61e4f87ac..3274ac0205 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -4625,28 +4625,60 @@ pub enum UpiData {UpiQr(UpiQrData),}+#[derive(+ Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema, SmithyModel,+)]+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]+#[smithy(namespace = "com.hyperswitch.smithy.types")]+/// The source type for UPI payments. This indicates what payment source is being used for the UPI transaction.+pub enum UpiSource {+ /// UPI payment using a credit card+ UpiCc,+ /// UPI payment using a credit line+ UpiCl,+ /// UPI payment using a bank account (savings)+ UpiAccount,+ /// UPI payment using a combination of credit card and credit line+ UpiCcCl,+}+#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema, SmithyModel,)]#[serde(rename_all = "snake_case")]#[smithy(namespace = "com.hyperswitch.smithy.types")]pub struct UpiCollectData {+ /// The Virtual Payment Address (VPA) for UPI collect payment#[schema(value_type = Option<String>, example = "successtest@iata")]#[smithy(value_type = "Option<String>")]pub vpa_id: Option<Secret<String, pii::UpiVpaMaskingStrategy>>,+ /// The UPI source type (Credit Card, Credit Line, Account, or Credit Card + Credit Line)+ #[schema(value_type = Option<UpiSource>)]+ #[smithy(value_type = "Option<UpiSource>")]+ pub upi_source: Option<UpiSource>,}#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema, SmithyModel,)]#[smithy(namespace = "com.hyperswitch.smithy.types")]-pub struct UpiQrData {}+pub struct UpiQrData {+ /// The UPI source type (Credit Card, Credit Line, Account, or Credit Card + Credit Line)+ #[schema(value_type = Option<UpiSource>)]+ #[smithy(value_type = "Option<UpiSource>")]+ pub upi_source: Option<UpiSource>,+}#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema, SmithyModel,)]#[smithy(namespace = "com.hyperswitch.smithy.types")]-pub struct UpiIntentData {}+pub struct UpiIntentData {+ /// The UPI source type (Credit Card, Credit Line, Account, or Credit Card + Credit Line)+ #[schema(value_type = Option<UpiSource>)]+ #[smithy(value_type = "Option<UpiSource>")]+ pub upi_source: Option<UpiSource>,+}#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]pub struct SofortBilling {diff --git a/crates/api_models/src/payments/additional_info.rs b/crates/api_models/src/payments/additional_info.rsindex 7de22e2e6b..23be4e1892 100644--- a/crates/api_models/src/payments/additional_info.rs+++ b/crates/api_models/src/payments/additional_info.rs@@ -5,7 +5,7 @@ use masking::Secret;use smithy::SmithyModel;use utoipa::ToSchema;-use crate::enums as api_enums;+use crate::{enums as api_enums, payments};#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema, SmithyModel,@@ -349,6 +349,9 @@ pub struct UpiCollectAdditionalData {#[schema(value_type = Option<String>, example = "ab********@okhdfcbank")]#[smithy(value_type = "Option<String>")]pub vpa_id: Option<MaskedUpiVpaId>,+ #[schema(value_type = Option<UpiSource>)]+ #[smithy(value_type = "Option<UpiSource>")]+ pub upi_source: Option<payments::UpiSource>,}#[derive(diff --git a/crates/hyperswitch_domain_models/src/payment_method_data.rs b/crates/hyperswitch_domain_models/src/payment_method_data.rsindex bf9087e168..ea93017221 100644--- a/crates/hyperswitch_domain_models/src/payment_method_data.rs+++ b/crates/hyperswitch_domain_models/src/payment_method_data.rs@@ -832,17 +832,53 @@ pub enum UpiData {UpiQr(UpiQrData),}+#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]+pub enum UpiSource {+ UpiCc, // UPI Credit Card+ UpiCl, // UPI Credit Line+ UpiAccount, // UPI Bank Account (Savings)+ UpiCcCl, // UPI Credit Card + Credit Line+}++impl From<api_models::payments::UpiSource> for UpiSource {+ fn from(value: api_models::payments::UpiSource) -> Self {+ match value {+ api_models::payments::UpiSource::UpiCc => Self::UpiCc,+ api_models::payments::UpiSource::UpiCl => Self::UpiCl,+ api_models::payments::UpiSource::UpiAccount => Self::UpiAccount,+ api_models::payments::UpiSource::UpiCcCl => Self::UpiCcCl,+ }+ }+}++impl From<UpiSource> for api_models::payments::UpiSource {+ fn from(value: UpiSource) -> Self {+ match value {+ UpiSource::UpiCc => Self::UpiCc,+ UpiSource::UpiCl => Self::UpiCl,+ UpiSource::UpiAccount => Self::UpiAccount,+ UpiSource::UpiCcCl => Self::UpiCcCl,+ }+ }+}+#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]#[serde(rename_all = "snake_case")]pub struct UpiCollectData {pub vpa_id: Option<Secret<String, pii::UpiVpaMaskingStrategy>>,+ pub upi_source: Option<UpiSource>,}#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]-pub struct UpiIntentData {}+pub struct UpiIntentData {+ pub upi_source: Option<UpiSource>,+}#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]-pub struct UpiQrData {}+pub struct UpiQrData {+ pub upi_source: Option<UpiSource>,+}#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize)]#[serde(rename_all = "snake_case")]@@ -1763,11 +1799,16 @@ impl From<CryptoData> for api_models::payments::CryptoData {impl From<api_models::payments::UpiData> 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::UpiIntent(_) => Self::UpiIntent(UpiIntentData {}),- api_models::payments::UpiData::UpiQr(_) => Self::UpiQr(UpiQrData {}),+ api_models::payments::UpiData::UpiCollect(upi) => Self::UpiCollect(UpiCollectData {+ vpa_id: upi.vpa_id,+ upi_source: upi.upi_source.map(UpiSource::from),+ }),+ api_models::payments::UpiData::UpiIntent(upi) => Self::UpiIntent(UpiIntentData {+ upi_source: upi.upi_source.map(UpiSource::from),+ }),+ api_models::payments::UpiData::UpiQr(upi) => Self::UpiQr(UpiQrData {+ upi_source: upi.upi_source.map(UpiSource::from),+ }),}}}@@ -1778,12 +1819,17 @@ impl From<UpiData> for api_models::payments::additional_info::UpiAdditionalDataUpiData::UpiCollect(upi) => Self::UpiCollect(Box::new(payment_additional_types::UpiCollectAdditionalData {vpa_id: upi.vpa_id.map(MaskedUpiVpaId::from),+ upi_source: upi.upi_source.map(api_models::payments::UpiSource::from),},)),- UpiData::UpiIntent(_) => {- Self::UpiIntent(Box::new(api_models::payments::UpiIntentData {}))+ UpiData::UpiIntent(upi) => {+ Self::UpiIntent(Box::new(api_models::payments::UpiIntentData {+ upi_source: upi.upi_source.map(api_models::payments::UpiSource::from),+ }))}- UpiData::UpiQr(_) => Self::UpiQr(Box::new(api_models::payments::UpiQrData {})),+ UpiData::UpiQr(upi) => Self::UpiQr(Box::new(api_models::payments::UpiQrData {+ upi_source: upi.upi_source.map(api_models::payments::UpiSource::from),+ })),}}}diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rsindex 507ea24f9c..c8861eed9c 100644--- a/crates/openapi/src/openapi.rs+++ b/crates/openapi/src/openapi.rs@@ -486,6 +486,7 @@ 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::UpiSource,api_models::payments::UpiCollectData,api_models::payments::UpiIntentData,api_models::payments::UpiQrData,diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rsindex c70468befe..f34e135f0e 100644--- a/crates/openapi/src/openapi_v2.rs+++ b/crates/openapi/src/openapi_v2.rs@@ -422,6 +422,7 @@ 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::UpiSource,api_models::payments::UpiCollectData,api_models::payments::UpiIntentData,api_models::payments::UpiQrData,diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rsindex 8904928da1..ff8bbf6fe5 100644--- a/crates/router/src/compatibility/stripe/payment_intents/types.rs+++ b/crates/router/src/compatibility/stripe/payment_intents/types.rs@@ -153,6 +153,7 @@ impl From<StripeUpi> for payments::UpiData {fn from(upi_data: StripeUpi) -> Self {Self::UpiCollect(payments::UpiCollectData {vpa_id: Some(upi_data.vpa_id),+ upi_source: None,})}}@@ -959,7 +960,7 @@ fn get_pmd_based_on_payment_method_type() -> Option<payments::PaymentMethodData> {match payment_method_type {Some(api_enums::PaymentMethodType::UpiIntent) => Some(payments::PaymentMethodData::Upi(- payments::UpiData::UpiIntent(payments::UpiIntentData {}),+ payments::UpiData::UpiIntent(payments::UpiIntentData { upi_source: None }),)),Some(api_enums::PaymentMethodType::Fps) => {Some(payments::PaymentMethodData::RealTimePayment(Box::new(diff --git a/crates/router/src/core/unified_connector_service.rs b/crates/router/src/core/unified_connector_service.rsindex 9938d92e70..2bfdde89f1 100644--- a/crates/router/src/core/unified_connector_service.rs+++ b/crates/router/src/core/unified_connector_service.rs@@ -668,20 +668,32 @@ pub fn build_unified_connector_service_payment_method() => {let upi_details = payments_grpc::UpiCollect {vpa_id: upi_collect_data.vpa_id.map(|vpa| vpa.expose().into()),- upi_source: None,+ upi_source: upi_collect_data+ .upi_source+ .map(payments_grpc::UpiSource::foreign_try_from)+ .transpose()?+ .map(|upi_source| upi_source.into()),};PaymentMethod::UpiCollect(upi_details)}- hyperswitch_domain_models::payment_method_data::UpiData::UpiIntent(_) => {+ hyperswitch_domain_models::payment_method_data::UpiData::UpiIntent(upi_intent_data) => {let upi_details = payments_grpc::UpiIntent {app_name: None,- upi_source: None,+ upi_source: upi_intent_data+ .upi_source+ .map(payments_grpc::UpiSource::foreign_try_from)+ .transpose()?+ .map(|upi_source| upi_source.into()),};PaymentMethod::UpiIntent(upi_details)}- hyperswitch_domain_models::payment_method_data::UpiData::UpiQr(_) => {+ hyperswitch_domain_models::payment_method_data::UpiData::UpiQr(upi_qr_data) => {let upi_details = payments_grpc::UpiQr {- upi_source: None,+ upi_source: upi_qr_data+ .upi_source+ .map(payments_grpc::UpiSource::foreign_try_from)+ .transpose()?+ .map(|upi_source| upi_source.into()),};PaymentMethod::UpiQr(upi_details)}diff --git a/crates/router/src/core/unified_connector_service/transformers.rs b/crates/router/src/core/unified_connector_service/transformers.rsindex a01e226450..859fc2ee5c 100644--- a/crates/router/src/core/unified_connector_service/transformers.rs+++ b/crates/router/src/core/unified_connector_service/transformers.rs@@ -2835,6 +2835,25 @@ impl transformers::ForeignTryFrom<common_enums::CardNetwork> for payments_grpc::}}+impl transformers::ForeignTryFrom<hyperswitch_domain_models::payment_method_data::UpiSource>+ for payments_grpc::UpiSource+{+ type Error = error_stack::Report<UnifiedConnectorServiceError>;++ fn foreign_try_from(+ upi_source: hyperswitch_domain_models::payment_method_data::UpiSource,+ ) -> Result<Self, Self::Error> {+ match upi_source {+ hyperswitch_domain_models::payment_method_data::UpiSource::UpiCc => Ok(Self::UpiCc),+ hyperswitch_domain_models::payment_method_data::UpiSource::UpiCl => Ok(Self::UpiCl),+ hyperswitch_domain_models::payment_method_data::UpiSource::UpiAccount => {+ Ok(Self::UpiAccount)+ }+ hyperswitch_domain_models::payment_method_data::UpiSource::UpiCcCl => Ok(Self::UpiCcCl),+ }+ }+}+impl transformers::ForeignTryFrom<hyperswitch_domain_models::payment_method_data::NetworkTokenData>for payments_grpc::NetworkTokenData{