Skip to content

Commit 4647a2f

Browse files
srujanchikkeChikke Srujanhyperswitch-bot[bot]
authored
feat(connector): [Fiuu] Add support for cards recurring payments (#6361)
Co-authored-by: Chikke Srujan <[email protected]> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
1 parent ce732db commit 4647a2f

File tree

11 files changed

+798
-70
lines changed

11 files changed

+798
-70
lines changed

config/deployments/integration_test.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@ red_pagos = { country = "UY", currency = "UYU" }
341341
[pm_filters.zsl]
342342
local_bank_transfer = { country = "CN", currency = "CNY" }
343343

344+
[pm_filters.fiuu]
345+
duit_now = { country ="MY", currency = "MYR" }
346+
344347
[payout_method_filters.adyenplatform]
345348
sepa = { country = "ES,SK,AT,NL,DE,BE,FR,FI,PT,IE,EE,LT,LV,IT,CZ,DE,HU,NO,PL,SE,GB,CH" , currency = "EUR,CZK,DKK,HUF,NOK,PLN,SEK,GBP,CHF" }
346349

config/deployments/production.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,10 @@ red_pagos = { country = "UY", currency = "UYU" }
354354
[pm_filters.zsl]
355355
local_bank_transfer = { country = "CN", currency = "CNY" }
356356

357+
358+
[pm_filters.fiuu]
359+
duit_now = { country ="MY", currency = "MYR" }
360+
357361
[payout_method_filters.adyenplatform]
358362
sepa = { country = "ES,SK,AT,NL,DE,BE,FR,FI,PT,IE,EE,LT,LV,IT,CZ,DE,HU,NO,PL,SE,GB,CH" , currency = "EUR,CZK,DKK,HUF,NOK,PLN,SEK,GBP,CHF" }
359363

config/deployments/sandbox.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,10 @@ red_pagos = { country = "UY", currency = "UYU" }
358358
[pm_filters.zsl]
359359
local_bank_transfer = { country = "CN", currency = "CNY" }
360360

361+
362+
[pm_filters.fiuu]
363+
duit_now = { country ="MY", currency = "MYR" }
364+
361365
[payout_method_filters.adyenplatform]
362366
sepa = { country = "ES,SK,AT,NL,DE,BE,FR,FI,PT,IE,EE,LT,LV,IT,CZ,DE,HU,NO,PL,SE,GB,CH" , currency = "EUR,CZK,DKK,HUF,NOK,PLN,SEK,GBP,CHF" }
363367

config/development.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,9 @@ region = ""
531531
credit = { currency = "USD" }
532532
debit = { currency = "USD" }
533533

534+
[pm_filters.fiuu]
535+
duit_now = { country ="MY", currency = "MYR" }
536+
534537
[tokenization]
535538
stripe = { long_lived_token = false, payment_method = "wallet", payment_method_type = { type = "disable_only", list = "google_pay" } }
536539
checkout = { long_lived_token = false, payment_method = "wallet", apple_pay_pre_decrypt_flow = "network_tokenization" }
@@ -590,8 +593,8 @@ pay_later.klarna = { connector_list = "adyen" }
590593
wallet.google_pay = { connector_list = "stripe,adyen,cybersource,bankofamerica" }
591594
wallet.apple_pay = { connector_list = "stripe,adyen,cybersource,noon,bankofamerica" }
592595
wallet.paypal = { connector_list = "adyen" }
593-
card.credit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree" }
594-
card.debit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree" }
596+
card.credit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,fiuu" }
597+
card.debit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,fiuu" }
595598
bank_debit.ach = { connector_list = "gocardless,adyen" }
596599
bank_debit.becs = { connector_list = "gocardless" }
597600
bank_debit.bacs = { connector_list = "adyen" }

crates/hyperswitch_connectors/src/connectors/fiuu.rs

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pub mod transformers;
22

3-
use std::collections::HashMap;
3+
use std::collections::{HashMap, HashSet};
44

55
use common_enums::{CaptureMethod, PaymentMethodType};
66
use common_utils::{
@@ -12,6 +12,7 @@ use common_utils::{
1212
};
1313
use error_stack::ResultExt;
1414
use hyperswitch_domain_models::{
15+
payment_method_data::PaymentMethodData,
1516
router_data::{AccessToken, ErrorResponse, RouterData},
1617
router_flow_types::{
1718
access_token_auth::AccessTokenAuth,
@@ -43,7 +44,11 @@ use serde::{Deserialize, Serialize};
4344
use serde_json::Value;
4445
use transformers::{self as fiuu, FiuuWebhooksResponse};
4546

46-
use crate::{constants::headers, types::ResponseRouterData, utils};
47+
use crate::{
48+
constants::headers,
49+
types::ResponseRouterData,
50+
utils::{self, PaymentMethodDataType},
51+
};
4752

4853
fn parse_response<T>(data: &[u8]) -> Result<T, errors::ConnectorError>
4954
where
@@ -210,6 +215,15 @@ impl ConnectorValidation for Fiuu {
210215
),
211216
}
212217
}
218+
fn validate_mandate_payment(
219+
&self,
220+
pm_type: Option<PaymentMethodType>,
221+
pm_data: PaymentMethodData,
222+
) -> CustomResult<(), errors::ConnectorError> {
223+
let mandate_supported_pmd: HashSet<PaymentMethodDataType> =
224+
HashSet::from([PaymentMethodDataType::Card]);
225+
utils::is_mandate_supported(pm_data, pm_type, mandate_supported_pmd, self.id())
226+
}
213227
}
214228

215229
impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for Fiuu {
@@ -231,13 +245,21 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
231245

232246
fn get_url(
233247
&self,
234-
_req: &PaymentsAuthorizeRouterData,
248+
req: &PaymentsAuthorizeRouterData,
235249
connectors: &Connectors,
236250
) -> CustomResult<String, errors::ConnectorError> {
237-
Ok(format!(
238-
"{}RMS/API/Direct/1.4.0/index.php",
239-
self.base_url(connectors)
240-
))
251+
let url = if req.request.off_session == Some(true) {
252+
format!(
253+
"{}/RMS/API/Recurring/input_v7.php",
254+
self.base_url(connectors)
255+
)
256+
} else {
257+
format!(
258+
"{}RMS/API/Direct/1.4.0/index.php",
259+
self.base_url(connectors)
260+
)
261+
};
262+
Ok(url)
241263
}
242264

243265
fn get_request_body(
@@ -252,9 +274,15 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
252274
)?;
253275

254276
let connector_router_data = fiuu::FiuuRouterData::from((amount, req));
255-
let payment_request = fiuu::FiuuPaymentRequest::try_from(&connector_router_data)?;
256-
let connector_req = build_form_from_struct(payment_request)
257-
.change_context(errors::ConnectorError::ParsingFailed)?;
277+
let connector_req = if req.request.off_session == Some(true) {
278+
let recurring_request = fiuu::FiuuMandateRequest::try_from(&connector_router_data)?;
279+
build_form_from_struct(recurring_request)
280+
.change_context(errors::ConnectorError::ParsingFailed)?
281+
} else {
282+
let payment_request = fiuu::FiuuPaymentRequest::try_from(&connector_router_data)?;
283+
build_form_from_struct(payment_request)
284+
.change_context(errors::ConnectorError::ParsingFailed)?
285+
};
258286
Ok(RequestContent::FormData(connector_req))
259287
}
260288

0 commit comments

Comments
 (0)