Skip to content

Commit c9fa94f

Browse files
AkshayaFoigerhyperswitch-bot[bot]SamraatBansal
authored
feat(connector): [Iatapay] add upi qr support (#4728)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: SamraatBansal <[email protected]>
1 parent d15cb31 commit c9fa94f

File tree

22 files changed

+257
-65
lines changed

22 files changed

+257
-65
lines changed

crates/api_models/src/payments.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,7 +1664,10 @@ impl GetPaymentMethodType for CryptoData {
16641664

16651665
impl GetPaymentMethodType for UpiData {
16661666
fn get_payment_method_type(&self) -> api_enums::PaymentMethodType {
1667-
api_enums::PaymentMethodType::UpiCollect
1667+
match self {
1668+
Self::UpiCollect(_) => api_enums::PaymentMethodType::UpiCollect,
1669+
Self::UpiIntent(_) => api_enums::PaymentMethodType::UpiIntent,
1670+
}
16681671
}
16691672
}
16701673
impl GetPaymentMethodType for VoucherData {
@@ -2119,11 +2122,21 @@ pub struct CryptoData {
21192122

21202123
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
21212124
#[serde(rename_all = "snake_case")]
2122-
pub struct UpiData {
2125+
pub enum UpiData {
2126+
UpiCollect(UpiCollectData),
2127+
UpiIntent(UpiIntentData),
2128+
}
2129+
2130+
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
2131+
#[serde(rename_all = "snake_case")]
2132+
pub struct UpiCollectData {
21232133
#[schema(value_type = Option<String>, example = "successtest@iata")]
21242134
pub vpa_id: Option<Secret<String, pii::UpiVpaMaskingStrategy>>,
21252135
}
21262136

2137+
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
2138+
pub struct UpiIntentData {}
2139+
21272140
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
21282141
pub struct SofortBilling {
21292142
/// The country associated with the billing
@@ -2960,6 +2973,11 @@ pub enum NextActionData {
29602973
/// The url for Qr code given by the connector
29612974
qr_code_url: Option<Url>,
29622975
},
2976+
/// Contains url to fetch Qr code data
2977+
FetchQrCodeInformation {
2978+
#[schema(value_type = String)]
2979+
qr_code_fetch_url: Url,
2980+
},
29632981
/// Contains the download url and the reference number for transaction
29642982
DisplayVoucherInformation {
29652983
#[schema(value_type = String)]
@@ -3045,6 +3063,11 @@ pub struct SdkNextActionData {
30453063
pub next_action: NextActionCall,
30463064
}
30473065

3066+
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
3067+
pub struct FetchQrCodeInformation {
3068+
pub qr_code_fetch_url: Url,
3069+
}
3070+
30483071
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
30493072
pub struct BankTransferNextStepsData {
30503073
/// The instructions for performing a bank transfer

crates/common_enums/src/enums.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,6 +1430,7 @@ pub enum PaymentMethodType {
14301430
Trustly,
14311431
Twint,
14321432
UpiCollect,
1433+
UpiIntent,
14331434
Vipps,
14341435
Venmo,
14351436
Walley,

crates/common_enums/src/transformers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,6 +1854,7 @@ impl From<PaymentMethodType> for PaymentMethod {
18541854
PaymentMethodType::Trustly => Self::BankRedirect,
18551855
PaymentMethodType::Twint => Self::Wallet,
18561856
PaymentMethodType::UpiCollect => Self::Upi,
1857+
PaymentMethodType::UpiIntent => Self::Upi,
18571858
PaymentMethodType::Vipps => Self::Wallet,
18581859
PaymentMethodType::Venmo => Self::Wallet,
18591860
PaymentMethodType::Walley => Self::PayLater,

crates/euclid/src/frontend/dir/enums.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ pub enum CryptoType {
268268
#[strum(serialize_all = "snake_case")]
269269
pub enum UpiType {
270270
UpiCollect,
271+
UpiIntent,
271272
}
272273

273274
#[derive(

crates/euclid/src/frontend/dir/lowering.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ impl From<enums::UpiType> for global_enums::PaymentMethodType {
7575
fn from(value: enums::UpiType) -> Self {
7676
match value {
7777
enums::UpiType::UpiCollect => Self::UpiCollect,
78+
enums::UpiType::UpiIntent => Self::UpiIntent,
7879
}
7980
}
8081
}

crates/euclid/src/frontend/dir/transformers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ impl IntoDirValue for (global_enums::PaymentMethodType, global_enums::PaymentMet
109109
}
110110
global_enums::PaymentMethodType::Evoucher => Ok(dirval!(RewardType = Evoucher)),
111111
global_enums::PaymentMethodType::UpiCollect => Ok(dirval!(UpiType = UpiCollect)),
112+
global_enums::PaymentMethodType::UpiIntent => Ok(dirval!(UpiType = UpiIntent)),
112113
global_enums::PaymentMethodType::SamsungPay => Ok(dirval!(WalletType = SamsungPay)),
113114
global_enums::PaymentMethodType::GoPay => Ok(dirval!(WalletType = GoPay)),
114115
global_enums::PaymentMethodType::KakaoPay => Ok(dirval!(WalletType = KakaoPay)),

crates/hyperswitch_domain_models/src/payment_method_data.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,20 @@ pub struct CryptoData {
289289

290290
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
291291
#[serde(rename_all = "snake_case")]
292-
pub struct UpiData {
292+
pub enum UpiData {
293+
UpiCollect(UpiCollectData),
294+
UpiIntent(UpiIntentData),
295+
}
296+
297+
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
298+
#[serde(rename_all = "snake_case")]
299+
pub struct UpiCollectData {
293300
pub vpa_id: Option<Secret<String, pii::UpiVpaMaskingStrategy>>,
294301
}
295302

303+
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
304+
pub struct UpiIntentData {}
305+
296306
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
297307
#[serde(rename_all = "snake_case")]
298308
pub enum VoucherData {
@@ -690,8 +700,12 @@ impl From<api_models::payments::CryptoData> for CryptoData {
690700

691701
impl From<api_models::payments::UpiData> for UpiData {
692702
fn from(value: api_models::payments::UpiData) -> Self {
693-
let api_models::payments::UpiData { vpa_id } = value;
694-
Self { vpa_id }
703+
match value {
704+
api_models::payments::UpiData::UpiCollect(upi) => {
705+
Self::UpiCollect(UpiCollectData { vpa_id: upi.vpa_id })
706+
}
707+
api_models::payments::UpiData::UpiIntent(_) => Self::UpiIntent(UpiIntentData {}),
708+
}
695709
}
696710
}
697711

crates/kgraph_utils/src/mca.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ fn get_dir_value_payment_method(
7777

7878
api_enums::PaymentMethodType::ClassicReward => Ok(dirval!(RewardType = ClassicReward)),
7979
api_enums::PaymentMethodType::Evoucher => Ok(dirval!(RewardType = Evoucher)),
80-
api_enums::PaymentMethodType::UpiCollect => Ok(dirval!(UpiType = UpiCollect)),
8180
api_enums::PaymentMethodType::SamsungPay => Ok(dirval!(WalletType = SamsungPay)),
8281
api_enums::PaymentMethodType::GoPay => Ok(dirval!(WalletType = GoPay)),
8382
api_enums::PaymentMethodType::KakaoPay => Ok(dirval!(WalletType = KakaoPay)),
@@ -133,6 +132,8 @@ fn get_dir_value_payment_method(
133132
api_enums::PaymentMethodType::Oxxo => Ok(dirval!(VoucherType = Oxxo)),
134133
api_enums::PaymentMethodType::CardRedirect => Ok(dirval!(CardRedirectType = CardRedirect)),
135134
api_enums::PaymentMethodType::Venmo => Ok(dirval!(WalletType = Venmo)),
135+
api_enums::PaymentMethodType::UpiIntent => Ok(dirval!(UpiType = UpiIntent)),
136+
api_enums::PaymentMethodType::UpiCollect => Ok(dirval!(UpiType = UpiCollect)),
136137
}
137138
}
138139

crates/kgraph_utils/src/transformers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ impl IntoDirValue for (api_enums::PaymentMethodType, api_enums::PaymentMethod) {
230230
api_enums::PaymentMethodType::ClassicReward => Ok(dirval!(RewardType = ClassicReward)),
231231
api_enums::PaymentMethodType::Evoucher => Ok(dirval!(RewardType = Evoucher)),
232232
api_enums::PaymentMethodType::UpiCollect => Ok(dirval!(UpiType = UpiCollect)),
233+
api_enums::PaymentMethodType::UpiIntent => Ok(dirval!(UpiType = UpiIntent)),
233234
api_enums::PaymentMethodType::SamsungPay => Ok(dirval!(WalletType = SamsungPay)),
234235
api_enums::PaymentMethodType::GoPay => Ok(dirval!(WalletType = GoPay)),
235236
api_enums::PaymentMethodType::KakaoPay => Ok(dirval!(WalletType = KakaoPay)),

crates/openapi/src/openapi.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ Never share your secret api keys. Keep them guarded and secure.
291291
api_models::payments::CryptoData,
292292
api_models::payments::RewardData,
293293
api_models::payments::UpiData,
294+
api_models::payments::UpiCollectData,
295+
api_models::payments::UpiIntentData,
294296
api_models::payments::VoucherData,
295297
api_models::payments::BoletoVoucherData,
296298
api_models::payments::AlfamartVoucherData,

0 commit comments

Comments
 (0)