Skip to content

Commit

Permalink
feat(connector): [Fiuu] Add support for cards recurring payments (#6361)
Browse files Browse the repository at this point in the history
Co-authored-by: Chikke Srujan <[email protected]>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 25, 2024
1 parent ce732db commit 4647a2f
Show file tree
Hide file tree
Showing 11 changed files with 798 additions and 70 deletions.
3 changes: 3 additions & 0 deletions config/deployments/integration_test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ red_pagos = { country = "UY", currency = "UYU" }
[pm_filters.zsl]
local_bank_transfer = { country = "CN", currency = "CNY" }

[pm_filters.fiuu]
duit_now = { country ="MY", currency = "MYR" }

[payout_method_filters.adyenplatform]
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" }

Expand Down
4 changes: 4 additions & 0 deletions config/deployments/production.toml
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,10 @@ red_pagos = { country = "UY", currency = "UYU" }
[pm_filters.zsl]
local_bank_transfer = { country = "CN", currency = "CNY" }


[pm_filters.fiuu]
duit_now = { country ="MY", currency = "MYR" }

[payout_method_filters.adyenplatform]
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" }

Expand Down
4 changes: 4 additions & 0 deletions config/deployments/sandbox.toml
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,10 @@ red_pagos = { country = "UY", currency = "UYU" }
[pm_filters.zsl]
local_bank_transfer = { country = "CN", currency = "CNY" }


[pm_filters.fiuu]
duit_now = { country ="MY", currency = "MYR" }

[payout_method_filters.adyenplatform]
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" }

Expand Down
7 changes: 5 additions & 2 deletions config/development.toml
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,9 @@ region = ""
credit = { currency = "USD" }
debit = { currency = "USD" }

[pm_filters.fiuu]
duit_now = { country ="MY", currency = "MYR" }

[tokenization]
stripe = { long_lived_token = false, payment_method = "wallet", payment_method_type = { type = "disable_only", list = "google_pay" } }
checkout = { long_lived_token = false, payment_method = "wallet", apple_pay_pre_decrypt_flow = "network_tokenization" }
Expand Down Expand Up @@ -590,8 +593,8 @@ pay_later.klarna = { connector_list = "adyen" }
wallet.google_pay = { connector_list = "stripe,adyen,cybersource,bankofamerica" }
wallet.apple_pay = { connector_list = "stripe,adyen,cybersource,noon,bankofamerica" }
wallet.paypal = { connector_list = "adyen" }
card.credit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree" }
card.debit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree" }
card.credit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,fiuu" }
card.debit = { connector_list = "stripe,adyen,authorizedotnet,cybersource,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,fiuu" }
bank_debit.ach = { connector_list = "gocardless,adyen" }
bank_debit.becs = { connector_list = "gocardless" }
bank_debit.bacs = { connector_list = "adyen" }
Expand Down
48 changes: 38 additions & 10 deletions crates/hyperswitch_connectors/src/connectors/fiuu.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod transformers;

use std::collections::HashMap;
use std::collections::{HashMap, HashSet};

use common_enums::{CaptureMethod, PaymentMethodType};
use common_utils::{
Expand All @@ -12,6 +12,7 @@ use common_utils::{
};
use error_stack::ResultExt;
use hyperswitch_domain_models::{
payment_method_data::PaymentMethodData,
router_data::{AccessToken, ErrorResponse, RouterData},
router_flow_types::{
access_token_auth::AccessTokenAuth,
Expand Down Expand Up @@ -43,7 +44,11 @@ use serde::{Deserialize, Serialize};
use serde_json::Value;
use transformers::{self as fiuu, FiuuWebhooksResponse};

use crate::{constants::headers, types::ResponseRouterData, utils};
use crate::{
constants::headers,
types::ResponseRouterData,
utils::{self, PaymentMethodDataType},
};

fn parse_response<T>(data: &[u8]) -> Result<T, errors::ConnectorError>
where
Expand Down Expand Up @@ -210,6 +215,15 @@ impl ConnectorValidation for Fiuu {
),
}
}
fn validate_mandate_payment(
&self,
pm_type: Option<PaymentMethodType>,
pm_data: PaymentMethodData,
) -> CustomResult<(), errors::ConnectorError> {
let mandate_supported_pmd: HashSet<PaymentMethodDataType> =
HashSet::from([PaymentMethodDataType::Card]);
utils::is_mandate_supported(pm_data, pm_type, mandate_supported_pmd, self.id())
}
}

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

fn get_url(
&self,
_req: &PaymentsAuthorizeRouterData,
req: &PaymentsAuthorizeRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
Ok(format!(
"{}RMS/API/Direct/1.4.0/index.php",
self.base_url(connectors)
))
let url = if req.request.off_session == Some(true) {
format!(
"{}/RMS/API/Recurring/input_v7.php",
self.base_url(connectors)
)
} else {
format!(
"{}RMS/API/Direct/1.4.0/index.php",
self.base_url(connectors)
)
};
Ok(url)
}

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

let connector_router_data = fiuu::FiuuRouterData::from((amount, req));
let payment_request = fiuu::FiuuPaymentRequest::try_from(&connector_router_data)?;
let connector_req = build_form_from_struct(payment_request)
.change_context(errors::ConnectorError::ParsingFailed)?;
let connector_req = if req.request.off_session == Some(true) {
let recurring_request = fiuu::FiuuMandateRequest::try_from(&connector_router_data)?;
build_form_from_struct(recurring_request)
.change_context(errors::ConnectorError::ParsingFailed)?
} else {
let payment_request = fiuu::FiuuPaymentRequest::try_from(&connector_router_data)?;
build_form_from_struct(payment_request)
.change_context(errors::ConnectorError::ParsingFailed)?
};
Ok(RequestContent::FormData(connector_req))
}

Expand Down
Loading

0 comments on commit 4647a2f

Please sign in to comment.