Skip to content

Commit eb6f27d

Browse files
feat(core): Payments core modification for open banking connectors (#3947)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
1 parent ecc862c commit eb6f27d

File tree

101 files changed

+1101
-48
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+1101
-48
lines changed

api-reference/openapi_spec.json

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12714,6 +12714,33 @@
1271412714
},
1271512715
"additionalProperties": false
1271612716
},
12717+
"OpenBankingData": {
12718+
"oneOf": [
12719+
{
12720+
"type": "object",
12721+
"required": [
12722+
"open_banking_pis"
12723+
],
12724+
"properties": {
12725+
"open_banking_pis": {
12726+
"type": "object"
12727+
}
12728+
}
12729+
}
12730+
]
12731+
},
12732+
"OpenBankingSessionToken": {
12733+
"type": "object",
12734+
"required": [
12735+
"open_banking_session_token"
12736+
],
12737+
"properties": {
12738+
"open_banking_session_token": {
12739+
"type": "string",
12740+
"description": "The session token for OpenBanking Connectors"
12741+
}
12742+
}
12743+
},
1271712744
"OrderDetails": {
1271812745
"type": "object",
1271912746
"required": [
@@ -13737,7 +13764,8 @@
1373713764
"real_time_payment",
1373813765
"upi",
1373913766
"voucher",
13740-
"gift_card"
13767+
"gift_card",
13768+
"open_banking"
1374113769
]
1374213770
},
1374313771
"PaymentMethodCollectLinkRequest": {
@@ -14132,6 +14160,18 @@
1413214160
"$ref": "#/components/schemas/CardToken"
1413314161
}
1413414162
}
14163+
},
14164+
{
14165+
"type": "object",
14166+
"title": "OpenBanking",
14167+
"required": [
14168+
"open_banking"
14169+
],
14170+
"properties": {
14171+
"open_banking": {
14172+
"$ref": "#/components/schemas/OpenBankingData"
14173+
}
14174+
}
1413514175
}
1413614176
]
1413714177
},
@@ -14338,6 +14378,17 @@
1433814378
"type": "object"
1433914379
}
1434014380
}
14381+
},
14382+
{
14383+
"type": "object",
14384+
"required": [
14385+
"open_banking"
14386+
],
14387+
"properties": {
14388+
"open_banking": {
14389+
"type": "object"
14390+
}
14391+
}
1434114392
}
1434214393
]
1434314394
},
@@ -14700,7 +14751,8 @@
1470014751
"seicomart",
1470114752
"pay_easy",
1470214753
"local_bank_transfer",
14703-
"mifinity"
14754+
"mifinity",
14755+
"open_banking_pis"
1470414756
]
1470514757
},
1470614758
"PaymentMethodUpdate": {
@@ -20171,6 +20223,27 @@
2017120223
}
2017220224
]
2017320225
},
20226+
{
20227+
"allOf": [
20228+
{
20229+
"$ref": "#/components/schemas/OpenBankingSessionToken"
20230+
},
20231+
{
20232+
"type": "object",
20233+
"required": [
20234+
"wallet_name"
20235+
],
20236+
"properties": {
20237+
"wallet_name": {
20238+
"type": "string",
20239+
"enum": [
20240+
"open_banking"
20241+
]
20242+
}
20243+
}
20244+
}
20245+
]
20246+
},
2017420247
{
2017520248
"type": "object",
2017620249
"required": [

crates/api_models/src/payments.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,7 @@ mod payment_method_data_serde {
16001600
| PaymentMethodData::Voucher(_)
16011601
| PaymentMethodData::Card(_)
16021602
| PaymentMethodData::MandatePayment
1603+
| PaymentMethodData::OpenBanking(_)
16031604
| PaymentMethodData::Wallet(_) => {
16041605
payment_method_data_request.serialize(serializer)
16051606
}
@@ -1657,6 +1658,8 @@ pub enum PaymentMethodData {
16571658
GiftCard(Box<GiftCardData>),
16581659
#[schema(title = "CardToken")]
16591660
CardToken(CardToken),
1661+
#[schema(title = "OpenBanking")]
1662+
OpenBanking(OpenBankingData),
16601663
}
16611664

16621665
pub trait GetAddressFromPaymentMethodData {
@@ -1680,6 +1683,7 @@ impl GetAddressFromPaymentMethodData for PaymentMethodData {
16801683
| Self::Upi(_)
16811684
| Self::GiftCard(_)
16821685
| Self::CardToken(_)
1686+
| Self::OpenBanking(_)
16831687
| Self::MandatePayment => None,
16841688
}
16851689
}
@@ -1717,6 +1721,7 @@ impl PaymentMethodData {
17171721
Self::Upi(_) => Some(api_enums::PaymentMethod::Upi),
17181722
Self::Voucher(_) => Some(api_enums::PaymentMethod::Voucher),
17191723
Self::GiftCard(_) => Some(api_enums::PaymentMethod::GiftCard),
1724+
Self::OpenBanking(_) => Some(api_enums::PaymentMethod::OpenBanking),
17201725
Self::CardToken(_) | Self::MandatePayment => None,
17211726
}
17221727
}
@@ -1785,6 +1790,14 @@ impl GetPaymentMethodType for PayLaterData {
17851790
}
17861791
}
17871792

1793+
impl GetPaymentMethodType for OpenBankingData {
1794+
fn get_payment_method_type(&self) -> api_enums::PaymentMethodType {
1795+
match self {
1796+
Self::OpenBankingPIS {} => api_enums::PaymentMethodType::OpenBankingPIS,
1797+
}
1798+
}
1799+
}
1800+
17881801
impl GetPaymentMethodType for BankRedirectData {
17891802
fn get_payment_method_type(&self) -> api_enums::PaymentMethodType {
17901803
match self {
@@ -1983,6 +1996,7 @@ pub enum AdditionalPaymentData {
19831996
Voucher {},
19841997
CardRedirect {},
19851998
CardToken {},
1999+
OpenBanking {},
19862000
}
19872001

19882002
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
@@ -2673,6 +2687,12 @@ pub struct SamsungPayWalletData {
26732687
pub token: Secret<String>,
26742688
}
26752689

2690+
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
2691+
#[serde(rename_all = "snake_case")]
2692+
pub enum OpenBankingData {
2693+
#[serde(rename = "open_banking_pis")]
2694+
OpenBankingPIS {},
2695+
}
26762696
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
26772697
#[serde(rename_all = "snake_case")]
26782698
pub struct GooglePayWalletData {
@@ -2946,6 +2966,7 @@ where
29462966
| PaymentMethodDataResponse::Upi {}
29472967
| PaymentMethodDataResponse::Wallet {}
29482968
| PaymentMethodDataResponse::BankTransfer {}
2969+
| PaymentMethodDataResponse::OpenBanking {}
29492970
| PaymentMethodDataResponse::Voucher {} => {
29502971
payment_method_data_response.serialize(serializer)
29512972
}
@@ -2979,6 +3000,7 @@ pub enum PaymentMethodDataResponse {
29793000
GiftCard {},
29803001
CardRedirect {},
29813002
CardToken {},
3003+
OpenBanking {},
29823004
}
29833005

29843006
#[derive(Eq, PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, ToSchema)]
@@ -4146,6 +4168,7 @@ impl From<AdditionalPaymentData> for PaymentMethodDataResponse {
41464168
AdditionalPaymentData::GiftCard {} => Self::GiftCard {},
41474169
AdditionalPaymentData::CardRedirect {} => Self::CardRedirect {},
41484170
AdditionalPaymentData::CardToken {} => Self::CardToken {},
4171+
AdditionalPaymentData::OpenBanking {} => Self::OpenBanking {},
41494172
}
41504173
}
41514174
}
@@ -4531,6 +4554,8 @@ pub enum SessionToken {
45314554
Paypal(Box<PaypalSessionTokenResponse>),
45324555
/// The session response structure for Apple Pay
45334556
ApplePay(Box<ApplepaySessionTokenResponse>),
4557+
/// Session token for OpenBanking PIS flow
4558+
OpenBanking(OpenBankingSessionToken),
45344559
/// Whenever there is no session token response or an error in session response
45354560
NoSessionTokenReceived,
45364561
}
@@ -4607,6 +4632,13 @@ pub struct PaypalSessionTokenResponse {
46074632
pub sdk_next_action: SdkNextAction,
46084633
}
46094634

4635+
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
4636+
#[serde(rename_all = "lowercase")]
4637+
pub struct OpenBankingSessionToken {
4638+
/// The session token for OpenBanking Connectors
4639+
pub open_banking_session_token: String,
4640+
}
4641+
46104642
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
46114643
#[serde(rename_all = "lowercase")]
46124644
pub struct ApplepaySessionTokenResponse {

crates/common_enums/src/enums.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,8 @@ pub enum PaymentMethodType {
15691569
PayEasy,
15701570
LocalBankTransfer,
15711571
Mifinity,
1572+
#[serde(rename = "open_banking_pis")]
1573+
OpenBankingPIS,
15721574
}
15731575

15741576
/// Indicates the type of payment method. Eg: 'card', 'wallet', etc.
@@ -1606,6 +1608,7 @@ pub enum PaymentMethod {
16061608
Upi,
16071609
Voucher,
16081610
GiftCard,
1611+
OpenBanking,
16091612
}
16101613

16111614
/// The type of the payment that differentiates between normal and various types of mandate payments. Use 'setup_mandate' in case of zero auth flow.

crates/common_enums/src/transformers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,6 +1882,7 @@ impl From<PaymentMethodType> for PaymentMethod {
18821882
PaymentMethodType::FamilyMart => Self::Voucher,
18831883
PaymentMethodType::Seicomart => Self::Voucher,
18841884
PaymentMethodType::PayEasy => Self::Voucher,
1885+
PaymentMethodType::OpenBankingPIS => Self::OpenBanking,
18851886
}
18861887
}
18871888
}

crates/connector_configs/src/response_modifier.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ impl ConnectorApiIntegrationPayload {
1919
let mut voucher_details: Vec<Provider> = Vec::new();
2020
let mut gift_card_details: Vec<Provider> = Vec::new();
2121
let mut card_redirect_details: Vec<Provider> = Vec::new();
22+
let mut open_banking_details: Vec<Provider> = Vec::new();
2223

2324
if let Some(payment_methods_enabled) = response.payment_methods_enabled.clone() {
2425
for methods in payment_methods_enabled {
@@ -160,6 +161,18 @@ impl ConnectorApiIntegrationPayload {
160161
}
161162
}
162163
}
164+
api_models::enums::PaymentMethod::OpenBanking => {
165+
if let Some(payment_method_types) = methods.payment_method_types {
166+
for method_type in payment_method_types {
167+
open_banking_details.push(Provider {
168+
payment_method_type: method_type.payment_method_type,
169+
accepted_currencies: method_type.accepted_currencies.clone(),
170+
accepted_countries: method_type.accepted_countries.clone(),
171+
payment_experience: method_type.payment_experience,
172+
})
173+
}
174+
}
175+
}
163176
api_models::enums::PaymentMethod::Upi => {
164177
if let Some(payment_method_types) = methods.payment_method_types {
165178
for method_type in payment_method_types {

crates/connector_configs/src/transformer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ impl DashboardRequestPayload {
138138
| PaymentMethod::Upi
139139
| PaymentMethod::Voucher
140140
| PaymentMethod::GiftCard
141+
| PaymentMethod::OpenBanking
141142
| PaymentMethod::CardRedirect => {
142143
if let Some(provider) = payload.provider {
143144
let val = Self::transform_payment_method(

crates/euclid/src/dssa/graph.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ impl cgraph::NodeViz for dir::DirValue {
6969
Self::SetupFutureUsage(sfu) => sfu.to_string(),
7070
Self::CardRedirectType(crt) => crt.to_string(),
7171
Self::RealTimePaymentType(rtpt) => rtpt.to_string(),
72+
Self::OpenBankingType(ob) => ob.to_string(),
7273
}
7374
}
7475
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ fn lower_comparison_inner<O: EuclidDirFilter>(
264264

265265
dir::DirKeyKind::UpiType => lower_enum!(UpiType, value),
266266

267+
dir::DirKeyKind::OpenBankingType => lower_enum!(OpenBankingType, value),
268+
267269
dir::DirKeyKind::VoucherType => lower_enum!(VoucherType, value),
268270

269271
dir::DirKeyKind::GiftCardType => lower_enum!(GiftCardType, value),

crates/euclid/src/frontend/dir.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,13 @@ pub enum DirKeyKind {
319319
props(Category = "Payment Method Types")
320320
)]
321321
RealTimePaymentType,
322+
#[serde(rename = "open_banking")]
323+
#[strum(
324+
serialize = "open_banking",
325+
detailed_message = "Supported types of open banking payment method",
326+
props(Category = "Payment Method Types")
327+
)]
328+
OpenBankingType,
322329
}
323330

324331
pub trait EuclidDirFilter: Sized
@@ -367,6 +374,7 @@ impl DirKeyKind {
367374
Self::SetupFutureUsage => types::DataType::EnumVariant,
368375
Self::CardRedirectType => types::DataType::EnumVariant,
369376
Self::RealTimePaymentType => types::DataType::EnumVariant,
377+
Self::OpenBankingType => types::DataType::EnumVariant,
370378
}
371379
}
372380
pub fn get_value_set(&self) -> Option<Vec<DirValue>> {
@@ -498,6 +506,11 @@ impl DirKeyKind {
498506
.map(DirValue::RealTimePaymentType)
499507
.collect(),
500508
),
509+
Self::OpenBankingType => Some(
510+
enums::OpenBankingType::iter()
511+
.map(DirValue::OpenBankingType)
512+
.collect(),
513+
),
501514
}
502515
}
503516
}
@@ -565,6 +578,8 @@ pub enum DirValue {
565578
CardRedirectType(enums::CardRedirectType),
566579
#[serde(rename = "real_time_payment")]
567580
RealTimePaymentType(enums::RealTimePaymentType),
581+
#[serde(rename = "open_banking")]
582+
OpenBankingType(enums::OpenBankingType),
568583
}
569584

570585
impl DirValue {
@@ -599,6 +614,7 @@ impl DirValue {
599614
Self::VoucherType(_) => (DirKeyKind::VoucherType, None),
600615
Self::GiftCardType(_) => (DirKeyKind::GiftCardType, None),
601616
Self::RealTimePaymentType(_) => (DirKeyKind::RealTimePaymentType, None),
617+
Self::OpenBankingType(_) => (DirKeyKind::OpenBankingType, None),
602618
};
603619

604620
DirKey::new(kind, data)
@@ -634,6 +650,7 @@ impl DirValue {
634650
Self::SetupFutureUsage(_) => None,
635651
Self::CardRedirectType(_) => None,
636652
Self::RealTimePaymentType(_) => None,
653+
Self::OpenBankingType(_) => None,
637654
}
638655
}
639656

0 commit comments

Comments
 (0)