Skip to content

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

feat(feature): [Zift] Add Cards Support (#10171)

awasthi21e5f32f1a5779
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index d8dce96335..a334acb087 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -14453,6 +14453,7 @@
"riskified",
"xendit",
"zen",
+ "zift",
"zsl"
]
},
@@ -34100,6 +34101,7 @@
"worldpayxml",
"xendit",
"zen",
+ "zift",
"plaid",
"zsl"
]
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index dd73ed4169..13f30b4407 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -9098,6 +9098,7 @@
"riskified",
"xendit",
"zen",
+ "zift",
"zsl"
]
},
@@ -24793,6 +24794,7 @@
"worldpayxml",
"xendit",
"zen",
+ "zift",
"plaid",
"zsl"
]
diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml
index 49bd441ecf..281ae904a2 100644
--- a/config/deployments/integration_test.toml
+++ b/config/deployments/integration_test.toml
@@ -165,7 +165,7 @@ worldpayvantiv.secondary_base_url = "https://onlinessr.vantivprelive.com"
worldpayvantiv.third_base_url = "https://services.vantivprelive.com"
worldpayxml.base_url = "https://secure-test.worldpay.com/jsp/merchant/xml/paymentService.jsp"
xendit.base_url = "https://api.xendit.co"
-zift.base_url = "https://sandbox-secure.zift.io/gates/xurl?"
+zift.base_url = "https://sandbox-secure.zift.io/"
zen.base_url = "https://api.zen-test.com/"
zen.secondary_base_url = "https://secure.zen-test.com/"
zsl.base_url = "https://api.sitoffalb.net/"
@@ -238,8 +238,8 @@ bank_debit.ach = { connector_list = "gocardless,adyen,stripe" }
bank_debit.becs = { connector_list = "gocardless,stripe,adyen" }
bank_debit.bacs = { connector_list = "stripe,gocardless" }
bank_debit.sepa = { connector_list = "gocardless,adyen,stripe,deutschebank" }
-card.credit.connector_list = "aci,checkout,stripe,adyen,authorizedotnet,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,nuvei,payme,wellsfargo,bamboraapac,elavon,fiuu,nexixpay,novalnet,paybox,paypal,xendit,moneris,archipel,worldpayvantiv,payload,paysafe,finix,tesouro"
-card.debit.connector_list = "aci,checkout,stripe,adyen,authorizedotnet,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,nuvei,payme,wellsfargo,bamboraapac,elavon,fiuu,nexixpay,novalnet,paybox,paypal,xendit,moneris,archipel,worldpayvantiv,payload,paysafe,finix,tesouro"
+card.credit.connector_list = "aci,checkout,stripe,adyen,zift,authorizedotnet,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,nuvei,payme,wellsfargo,bamboraapac,elavon,fiuu,nexixpay,novalnet,paybox,paypal,xendit,moneris,archipel,worldpayvantiv,payload,paysafe,finix,tesouro"
+card.debit.connector_list = "aci,checkout,stripe,adyen,zift,authorizedotnet,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,nuvei,payme,wellsfargo,bamboraapac,elavon,fiuu,nexixpay,novalnet,paybox,paypal,xendit,moneris,archipel,worldpayvantiv,payload,paysafe,finix,tesouro"
pay_later.klarna.connector_list = "adyen,aci"
wallet.apple_pay.connector_list = "stripe,adyen,cybersource,noon,bankofamerica,nexinets,novalnet,nuvei,authorizedotnet,wellsfargo,finix"
wallet.samsung_pay.connector_list = "cybersource"
diff --git a/config/deployments/production.toml b/config/deployments/production.toml
index 6ce7e8993f..e9c1567662 100644
--- a/config/deployments/production.toml
+++ b/config/deployments/production.toml
@@ -168,7 +168,7 @@ worldpayvantiv.secondary_base_url = "https://onlinessr.vantivcnp.com"
worldpayvantiv.third_base_url = "https://services.vantivprelive.com" # pre-live environment
worldpayxml.base_url = "https://secure.worldpay.com/jsp/merchant/xml/paymentService.jsp"
xendit.base_url = "https://api.xendit.co"
-zift.base_url = "https://sandbox-secure.zift.io/gates/xurl?"
+zift.base_url = "https://secure.zift.io/"
zen.base_url = "https://api.zen.com/"
zen.secondary_base_url = "https://secure.zen.com/"
zsl.base_url = "https://apirh.prodoffalb.net/"
@@ -238,8 +238,8 @@ bank_debit.ach = { connector_list = "gocardless,adyen,stripe" }
bank_debit.becs = { connector_list = "gocardless,stripe,adyen" }
bank_debit.bacs = { connector_list = "stripe,gocardless" }
bank_debit.sepa = { connector_list = "gocardless,adyen,stripe,deutschebank" }
-card.credit.connector_list = "aci,checkout,stripe,adyen,authorizedotnet,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,nuvei,payme,wellsfargo,bamboraapac,elavon,fiuu,nexixpay,novalnet,paybox,paypal,xendit,moneris,archipel,worldpayvantiv,payload,paysafe,finix,tesouro"
-card.debit.connector_list = "aci,checkout,stripe,adyen,authorizedotnet,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,nuvei,payme,wellsfargo,bamboraapac,elavon,fiuu,nexixpay,novalnet,paybox,paypal,xendit,moneris,archipel,worldpayvantiv,payload,paysafe,finix,tesouro"
+card.credit.connector_list = "aci,checkout,stripe,zift,adyen,authorizedotnet,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,nuvei,payme,wellsfargo,bamboraapac,elavon,fiuu,nexixpay,novalnet,paybox,paypal,xendit,moneris,archipel,worldpayvantiv,payload,paysafe,finix,tesouro"
+card.debit.connector_list = "aci,checkout,stripe,zift,adyen,authorizedotnet,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,nuvei,payme,wellsfargo,bamboraapac,elavon,fiuu,nexixpay,novalnet,paybox,paypal,xendit,moneris,archipel,worldpayvantiv,payload,paysafe,finix,tesouro"
pay_later.klarna.connector_list = "adyen,aci"
wallet.apple_pay.connector_list = "stripe,adyen,cybersource,noon,bankofamerica,nexinets,novalnet,nuvei,authorizedotnet,wellsfargo,finix"
wallet.samsung_pay.connector_list = "cybersource"
diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml
index 03e89d1f50..0c378be14f 100644
--- a/config/deployments/sandbox.toml
+++ b/config/deployments/sandbox.toml
@@ -221,8 +221,8 @@ bank_debit.ach = { connector_list = "gocardless,adyen" }
bank_debit.becs = { connector_list = "gocardless,adyen" }
bank_debit.bacs = { connector_list = "gocardless" }
bank_debit.sepa = { connector_list = "gocardless,adyen" }
-card.credit.connector_list = "checkout,stripe,adyen,authorizedotnet,cybersource,datatrans,worldpay,nmi,bankofamerica,wellsfargo,bamboraapac,nexixpay,novalnet,paypal,archipel,tesouro"
-card.debit.connector_list = "checkout,stripe,adyen,authorizedotnet,cybersource,datatrans,worldpay,nmi,bankofamerica,wellsfargo,bamboraapac,nexixpay,novalnet,paypal,archipel,tesouro"
+card.credit.connector_list = "checkout,stripe,adyen,zift,authorizedotnet,cybersource,datatrans,worldpay,nmi,bankofamerica,wellsfargo,bamboraapac,nexixpay,novalnet,paypal,archipel,tesouro"
+card.debit.connector_list = "checkout,stripe,adyen,zift,authorizedotnet,cybersource,datatrans,worldpay,nmi,bankofamerica,wellsfargo,bamboraapac,nexixpay,novalnet,paypal,archipel,tesouro"
pay_later.klarna.connector_list = "adyen"
wallet.apple_pay.connector_list = "adyen,cybersource,bankofamerica,novalnet,nuvei,authorizedotnet"
wallet.samsung_pay.connector_list = "cybersource"
diff --git a/config/development.toml b/config/development.toml
index ec723a387d..fcd4476372 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -359,7 +359,7 @@ worldpayvantiv.secondary_base_url = "https://onlinessr.vantivprelive.com"
worldpayvantiv.third_base_url = "https://services.vantivprelive.com"
worldpayxml.base_url = "https://secure-test.worldpay.com/jsp/merchant/xml/paymentService.jsp"
xendit.base_url = "https://api.xendit.co"
-zift.base_url = "https://sandbox-secure.zift.io/gates/xurl?"
+zift.base_url = "https://sandbox-secure.zift.io/"
trustpay.base_url = "https://test-tpgw.trustpay.eu/"
trustpayments.base_url = "https://webservices.securetrading.net/"
tsys.base_url = "https://stagegw.transnox.com/"
@@ -1117,8 +1117,8 @@ bank_debit.ach = { connector_list = "gocardless,adyen,stripe" }
bank_debit.becs = { connector_list = "gocardless,stripe,adyen" }
bank_debit.bacs = { connector_list = "stripe,gocardless" }
bank_debit.sepa = { connector_list = "gocardless,adyen,stripe,deutschebank" }
-card.credit.connector_list = "aci,checkout,stripe,adyen,authorizedotnet,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,nuvei,payme,wellsfargo,bamboraapac,elavon,fiuu,nexixpay,novalnet,paybox,paypal,xendit,moneris,archipel,worldpayvantiv,payload,paysafe,finix,tesouro"
-card.debit.connector_list = "aci,checkout,stripe,adyen,authorizedotnet,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,nuvei,payme,wellsfargo,bamboraapac,elavon,fiuu,nexixpay,novalnet,paybox,paypal,xendit,moneris,archipel,worldpayvantiv,payload,paysafe,finix,tesouro"
+card.credit.connector_list = "aci,checkout,stripe,adyen,zift,authorizedotnet,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,nuvei,payme,wellsfargo,bamboraapac,elavon,fiuu,nexixpay,novalnet,paybox,paypal,xendit,moneris,archipel,worldpayvantiv,payload,paysafe,finix,tesouro"
+card.debit.connector_list = "aci,checkout,stripe,adyen,zift,authorizedotnet,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,braintree,nuvei,payme,wellsfargo,bamboraapac,elavon,fiuu,nexixpay,novalnet,paybox,paypal,xendit,moneris,archipel,worldpayvantiv,payload,paysafe,finix,tesouro"
pay_later.klarna.connector_list = "adyen,aci"
wallet.apple_pay.connector_list = "stripe,adyen,cybersource,noon,bankofamerica,nuvei,nexinets,novalnet,authorizedotnet,wellsfargo,worldpayvantiv,finix"
wallet.samsung_pay.connector_list = "cybersource"
diff --git a/config/docker_compose.toml b/config/docker_compose.toml
index f6b443dc2e..4580d7cd2e 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -256,7 +256,7 @@ worldpayvantiv.secondary_base_url = "https://onlinessr.vantivprelive.com"
worldpayvantiv.third_base_url = "https://services.vantivprelive.com"
worldpayxml.base_url = "https://secure-test.worldpay.com/jsp/merchant/xml/paymentService.jsp"
xendit.base_url = "https://api.xendit.co"
-zift.base_url = "https://sandbox-secure.zift.io/gates/xurl?"
+zift.base_url = "https://sandbox-secure.zift.io/"
zen.base_url = "https://api.zen-test.com/"
zen.secondary_base_url = "https://secure.zen-test.com/"
zsl.base_url = "https://api.sitoffalb.net/"
@@ -1037,12 +1037,12 @@ bank_redirect.open_banking_uk.connector_list = "adyen"
[mandates.supported_payment_methods]
pay_later.klarna = { connector_list = "adyen,aci" }
-wallet.google_pay = { connector_list = "stripe,cybersource,adyen,bankofamerica,authorizedotnet,noon,novalnet,multisafepay,wellsfargo,nuvei" }
-wallet.apple_pay = { connector_list = "stripe,adyen,cybersource,noon,bankofamerica,authorizedotnet,novalnet,multisafepay,wellsfargo,nuvei" }
+wallet.google_pay = { connector_list = "stripe,cybersource,adyen,zift,bankofamerica,authorizedotnet,noon,novalnet,multisafepay,wellsfargo,nuvei" }
+wallet.apple_pay = { connector_list = "stripe,adyen,cybersource,zift,noon,bankofamerica,authorizedotnet,novalnet,multisafepay,wellsfargo,nuvei" }
wallet.samsung_pay = { connector_list = "cybersource" }
wallet.paypal = { connector_list = "adyen,novalnet,authorizedotnet" }
-card.credit = { connector_list = "aci,checkout,stripe,adyen,authorizedotnet,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,elavon,xendit,novalnet,bamboraapac,archipel,wellsfargo,worldpayvantiv,payload" }
-card.debit = { connector_list = "aci,checkout,stripe,adyen,authorizedotnet,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,elavon,xendit,novalnet,bamboraapac,archipel,wellsfargo,worldpayvantiv,payload" }
+card.credit = { connector_list = "aci,checkout,stripe,adyen,authorizedotnet,zift,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,elavon,xendit,novalnet,bamboraapac,archipel,wellsfargo,worldpayvantiv,payload" }
+card.debit = { connector_list = "aci,checkout,stripe,adyen,authorizedotnet,zift,cybersource,datatrans,globalpay,worldpay,multisafepay,nmi,nexinets,noon,bankofamerica,elavon,xendit,novalnet,bamboraapac,archipel,wellsfargo,worldpayvantiv,payload" }
bank_debit.ach = { connector_list = "gocardless,adyen" }
bank_debit.becs = { connector_list = "gocardless" }
bank_debit.bacs = { connector_list = "adyen" }
diff --git a/crates/common_enums/src/connector_enums.rs b/crates/common_enums/src/connector_enums.rs
index f3450134e0..9f29138609 100644
--- a/crates/common_enums/src/connector_enums.rs
+++ b/crates/common_enums/src/connector_enums.rs
@@ -180,6 +180,7 @@ pub enum RoutableConnectors {
Worldpayxml,
Xendit,
Zen,
+ Zift,
Plaid,
Zsl,
}
@@ -371,6 +372,7 @@ pub enum Connector {
Riskified,
Xendit,
Zen,
+ Zift,
Zsl,
}
@@ -482,6 +484,7 @@ impl Connector {
| Self::Coinbase
| Self::Coingate
| Self::Cryptopay
+ | Self::Zift
| Self::Custombilling
| Self::Deutschebank
| Self::Digitalvirgo
@@ -693,6 +696,7 @@ impl From<RoutableConnectors> for Connector {
RoutableConnectors::Jpmorgan => Self::Jpmorgan,
RoutableConnectors::Klarna => Self::Klarna,
RoutableConnectors::Loonio => Self::Loonio,
+ RoutableConnectors::Zift => Self::Zift,
RoutableConnectors::Mifinity => Self::Mifinity,
RoutableConnectors::Mollie => Self::Mollie,
RoutableConnectors::Moneris => Self::Moneris,
@@ -884,6 +888,7 @@ impl TryFrom<Connector> for RoutableConnectors {
Connector::Xendit => Ok(Self::Xendit),
Connector::Zen => Ok(Self::Zen),
Connector::Plaid => Ok(Self::Plaid),
+ Connector::Zift => Ok(Self::Zift),
Connector::Zsl => Ok(Self::Zsl),
Connector::Recurly => Ok(Self::Recurly),
Connector::Getnet => Ok(Self::Getnet),
diff --git a/crates/connector_configs/src/connector.rs b/crates/connector_configs/src/connector.rs
index 02c018d021..aab0bd8c40 100644
--- a/crates/connector_configs/src/connector.rs
+++ b/crates/connector_configs/src/connector.rs
@@ -614,6 +614,7 @@ impl ConnectorConfig {
Connector::CtpMastercard => Ok(connector_data.ctp_mastercard),
Connector::Xendit => Ok(connector_data.xendit),
Connector::Paytm => Ok(connector_data.paytm),
+ Connector::Zift => Ok(connector_data.zift),
Connector::Phonepe => Ok(connector_data.phonepe),
Connector::Payjustnow => Ok(connector_data.payjustnow),
}
diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.toml
index 49ca8e73cb..6e89a3a999 100644
--- a/crates/connector_configs/toml/development.toml
+++ b/crates/connector_configs/toml/development.toml
@@ -7557,8 +7557,45 @@ type="MultiSelect"
options=["CRYPTOGRAM_3DS"]
[zift]
-[zift.connector_auth.HeaderKey]
-api_key = "API Key"
+[[zift.credit]]
+ payment_method_type = "Mastercard"
+[[zift.credit]]
+ payment_method_type = "Visa"
+[[zift.credit]]
+ payment_method_type = "Interac"
+[[zift.credit]]
+ payment_method_type = "AmericanExpress"
+[[zift.credit]]
+ payment_method_type = "JCB"
+[[zift.credit]]
+ payment_method_type = "DinersClub"
+[[zift.credit]]
+ payment_method_type = "Discover"
+[[zift.credit]]
+ payment_method_type = "CartesBancaires"
+[[zift.credit]]
+ payment_method_type = "UnionPay"
+[[zift.debit]]
+ payment_method_type = "Mastercard"
+[[zift.debit]]
+ payment_method_type = "Visa"
+[[zift.debit]]
+ payment_method_type = "Interac"
+[[zift.debit]]
+ payment_method_type = "AmericanExpress"
+[[zift.debit]]
+ payment_method_type = "JCB"
+[[zift.debit]]
+ payment_method_type = "DinersClub"
+[[zift.debit]]
+ payment_method_type = "Discover"
+[[zift.debit]]
+ payment_method_type = "CartesBancaires"
+[[zift.debit]]
+[zift.connector_auth.SignatureKey]
+api_key="Username"
+api_secret="Password"
+key1="Account ID"
[payjustnow]
[payjustnow.connector_auth.BodyKey]
diff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.toml
index 409db3b5fc..2719eab870 100644
--- a/crates/connector_configs/toml/production.toml
+++ b/crates/connector_configs/toml/production.toml
@@ -6293,8 +6293,45 @@ type="MultiSelect"
options=["CRYPTOGRAM_3DS"]
[zift]
-[zift.connector_auth.HeaderKey]
-api_key = "API Key"
+[[zift.credit]]
+ payment_method_type = "Mastercard"
+[[zift.credit]]
+ payment_method_type = "Visa"
+[[zift.credit]]
+ payment_method_type = "Interac"
+[[zift.credit]]
+ payment_method_type = "AmericanExpress"
+[[zift.credit]]
+ payment_method_type = "JCB"
+[[zift.credit]]
+ payment_method_type = "DinersClub"
+[[zift.credit]]
+ payment_method_type = "Discover"
+[[zift.credit]]
+ payment_method_type = "CartesBancaires"
+[[zift.credit]]
+ payment_method_type = "UnionPay"
+[[zift.debit]]
+ payment_method_type = "Mastercard"
+[[zift.debit]]
+ payment_method_type = "Visa"
+[[zift.debit]]
+ payment_method_type = "Interac"
+[[zift.debit]]
+ payment_method_type = "AmericanExpress"
+[[zift.debit]]
+ payment_method_type = "JCB"
+[[zift.debit]]
+ payment_method_type = "DinersClub"
+[[zift.debit]]
+ payment_method_type = "Discover"
+[[zift.debit]]
+ payment_method_type = "CartesBancaires"
+[[zift.debit]]
+[zift.connector_auth.SignatureKey]
+api_key="Username"
+api_secret="Password"
+key1="Account ID"
[payjustnow]
[payjustnow.connector_auth.BodyKey]
diff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.toml
index 86de497c7e..7dbcc86b63 100644
--- a/crates/connector_configs/toml/sandbox.toml
+++ b/crates/connector_configs/toml/sandbox.toml
@@ -7530,7 +7530,45 @@ type="MultiSelect"
options=["CRYPTOGRAM_3DS"]
[zift]
-[zift.connector_auth.HeaderKey]
+[[zift.credit]]
+ payment_method_type = "Mastercard"
+[[zift.credit]]
+ payment_method_type = "Visa"
+[[zift.credit]]
+ payment_method_type = "Interac"
+[[zift.credit]]
+ payment_method_type = "AmericanExpress"
+[[zift.credit]]
+ payment_method_type = "JCB"
+[[zift.credit]]
+ payment_method_type = "DinersClub"
+[[zift.credit]]
+ payment_method_type = "Discover"
+[[zift.credit]]
+ payment_method_type = "CartesBancaires"
+[[zift.credit]]
+ payment_method_type = "UnionPay"
+[[zift.debit]]
+ payment_method_type = "Mastercard"
+[[zift.debit]]
+ payment_method_type = "Visa"
+[[zift.debit]]
+ payment_method_type = "Interac"
+[[zift.debit]]
+ payment_method_type = "AmericanExpress"
+[[zift.debit]]
+ payment_method_type = "JCB"
+[[zift.debit]]
+ payment_method_type = "DinersClub"
+[[zift.debit]]
+ payment_method_type = "Discover"
+[[zift.debit]]
+ payment_method_type = "CartesBancaires"
+[[zift.debit]]
+[zift.connector_auth.SignatureKey]
+api_key="Username"
+api_secret="Password"
+key1="Account ID"
api_key = "API Key"
[payjustnow]
diff --git a/crates/hyperswitch_connectors/src/connectors/zift.rs b/crates/hyperswitch_connectors/src/connectors/zift.rs
index 020403e605..0091cfb056 100644
--- a/crates/hyperswitch_connectors/src/connectors/zift.rs
+++ b/crates/hyperswitch_connectors/src/connectors/zift.rs
@@ -5,7 +5,6 @@ use std::sync::LazyLock;
use common_enums::enums;
use common_utils::{
errors::CustomResult,
- ext_traits::BytesExt,
request::{Method, Request, RequestBuilder, RequestContent},
types::{AmountConvertor, StringMinorUnit, StringMinorUnitForConnector},
};
@@ -24,11 +23,12 @@ use hyperswitch_domain_models::{
RefundsData, SetupMandateRequestData,
},
router_response_types::{
- ConnectorInfo, PaymentsResponseData, RefundsResponseData, SupportedPaymentMethods,
+ ConnectorInfo, PaymentMethodDetails, PaymentsResponseData, RefundsResponseData,
+ SupportedPaymentMethods, SupportedPaymentMethodsExt,
},
types::{
- PaymentsAuthorizeRouterData, PaymentsCaptureRouterData, PaymentsSyncRouterData,
- RefundSyncRouterData, RefundsRouterData,
+ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData,
+ PaymentsSyncRouterData, RefundSyncRouterData, RefundsRouterData,
},
};
use hyperswitch_interfaces::{
@@ -42,7 +42,6 @@ use hyperswitch_interfaces::{
types::{self, Response},
webhooks,
};
-use masking::{ExposeInterface, Mask};
use transformers as zift;
use crate::{constants::headers, types::ResponseRouterData, utils};
@@ -85,16 +84,13 @@ where
{
fn build_headers(
&self,
- req: &RouterData<Flow, Request, Response>,
+ _req: &RouterData<Flow, Request, Response>,
_connectors: &Connectors,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
- let mut header = vec![(
+ Ok(vec![(
headers::CONTENT_TYPE.to_string(),
self.get_content_type().to_string().into(),
- )];
- let mut api_key = self.get_auth_header(&req.connector_auth_type)?;
- header.append(&mut api_key);
- Ok(header)
+ )])
}
}
@@ -104,14 +100,11 @@ impl ConnectorCommon for Zift {
}
fn get_currency_unit(&self) -> api::CurrencyUnit {
- api::CurrencyUnit::Base
- // TODO! Check connector documentation, on which unit they are processing the currency.
- // If the connector accepts amount in lower unit ( i.e cents for USD) then return api::CurrencyUnit::Minor,
- // if connector accepts amount in base unit (i.e dollars for USD) then return api::CurrencyUnit::Base
+ api::CurrencyUnit::Minor
}
fn common_get_content_type(&self) -> &'static str {
- "application/json"
+ "application/x-www-form-urlencoded"
}
fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str {
@@ -120,14 +113,9 @@ impl ConnectorCommon for Zift {
fn get_auth_header(
&self,
- auth_type: &ConnectorAuthType,
+ _auth_type: &ConnectorAuthType,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
- let auth = zift::ZiftAuthType::try_from(auth_type)
- .change_context(errors::ConnectorError::FailedToObtainAuthType)?;
- Ok(vec![(
- headers::AUTHORIZATION.to_string(),
- auth.api_key.expose().into_masked(),
- )])
+ Ok(vec![])
}
fn build_error_response(
@@ -135,9 +123,7 @@ impl ConnectorCommon for Zift {
res: Response,
event_builder: Option<&mut ConnectorEvent>,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
- let response: zift::ZiftErrorResponse = res
- .response
- .parse_struct("ZiftErrorResponse")
+ let response: zift::ZiftErrorResponse = serde_urlencoded::from_bytes(&res.response)
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
@@ -145,9 +131,9 @@ impl ConnectorCommon for Zift {
Ok(ErrorResponse {
status_code: res.status_code,
- code: response.code,
- message: response.message,
- reason: response.reason,
+ code: response.response_code,
+ message: response.response_message.clone(),
+ reason: Some(response.response_message),
attempt_status: None,
connector_transaction_id: None,
network_advice_code: None,
@@ -164,12 +150,14 @@ impl ConnectorValidation for Zift {
_pm_type: Option<enums::PaymentMethodType>,
pm_data: PaymentMethodData,
) -> CustomResult<(), errors::ConnectorError> {
+ let connector = self.id();
match pm_data {
- PaymentMethodData::Card(_) => Err(errors::ConnectorError::NotImplemented(
- "validate_mandate_payment does not support cards".to_string(),
- )
+ PaymentMethodData::Card(_) => Ok(()),
+ _ => Err(errors::ConnectorError::NotSupported {
+ message: " mandate payment".to_string(),
+ connector,
+ }
.into()),
- _ => Ok(()),
}
}
@@ -208,9 +196,9 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
fn get_url(
&self,
_req: &PaymentsAuthorizeRouterData,
- _connectors: &Connectors,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ Ok(format!("{}gates/xurl", self.base_url(connectors)))
}
fn get_request_body(
@@ -226,7 +214,7 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
let connector_router_data = zift::ZiftRouterData::from((amount, req));
let connector_req = zift::ZiftPaymentsRequest::try_from(&connector_router_data)?;
- Ok(RequestContent::Json(Box::new(connector_req)))
+ Ok(RequestContent::FormUrlEncoded(Box::new(connector_req)))
}
fn build_request(
@@ -257,10 +245,9 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsAuthorizeRouterData, errors::ConnectorError> {
- let response: zift::ZiftPaymentsResponse = res
- .response
- .parse_struct("Zift PaymentsAuthorizeResponse")
+ let response: zift::ZiftAuthPaymentsResponse = serde_urlencoded::from_bytes(&res.response)
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
@@ -291,13 +278,21 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Zif
fn get_content_type(&self) -> &'static str {
self.common_get_content_type()
}
+ fn get_request_body(
+ &self,
+ req: &PaymentsSyncRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let connector_req = zift::ZiftSyncRequest::try_from(req)?;
+ Ok(RequestContent::FormUrlEncoded(Box::new(connector_req)))
+ }
fn get_url(
&self,
_req: &PaymentsSyncRouterData,
- _connectors: &Connectors,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ Ok(format!("{}gates/xurl", self.base_url(connectors)))
}
fn build_request(
@@ -307,9 +302,12 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Zif
) -> CustomResult<Option<Request>, errors::ConnectorError> {
Ok(Some(
RequestBuilder::new()
- .method(Method::Get)
+ .method(Method::Post)
.url(&types::PaymentsSyncType::get_url(self, req, connectors)?)
.attach_default_headers()
+ .set_body(types::PaymentsSyncType::get_request_body(
+ self, req, connectors,
+ )?)
.headers(types::PaymentsSyncType::get_headers(self, req, connectors)?)
.build(),
))
@@ -321,10 +319,9 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Zif
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsSyncRouterData, errors::ConnectorError> {
- let response: zift::ZiftPaymentsResponse = res
- .response
- .parse_struct("zift PaymentsSyncResponse")
+ let response: zift::ZiftSyncResponse = serde_urlencoded::from_bytes(&res.response)
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
RouterData::try_from(ResponseRouterData {
@@ -359,17 +356,24 @@ impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> fo
fn get_url(
&self,
_req: &PaymentsCaptureRouterData,
- _connectors: &Connectors,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ Ok(format!("{}gates/xurl", self.base_url(connectors)))
}
fn get_request_body(
&self,
- _req: &PaymentsCaptureRouterData,
+ req: &PaymentsCaptureRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_request_body method".to_string()).into())
+ let amount = utils::convert_amount(
+ self.amount_converter,
+ req.request.minor_amount_to_capture,
+ req.request.currency,
+ )?;
+ let connector_router_data = zift::ZiftRouterData::from((amount, req));
+ let connector_req = zift::ZiftCaptureRequest::try_from(&connector_router_data)?;
+ Ok(RequestContent::FormUrlEncoded(Box::new(connector_req)))
}
fn build_request(
@@ -398,9 +402,7 @@ impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> fo
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsCaptureRouterData, errors::ConnectorError> {
- let response: zift::ZiftPaymentsResponse = res
- .response
- .parse_struct("Zift PaymentsCaptureResponse")
+ let response: zift::ZiftCaptureResponse = serde_urlencoded::from_bytes(&res.response)
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
@@ -420,7 +422,84 @@ impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> fo
}
}
-impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Zift {}
+impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Zift {
+ // fn get_headers(
+ // &self,
+ // req: &PaymentsCancelRouterData,
+ // connectors: &Connectors,
+ // ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
+ // self.build_headers(req, connectors)
+ // }
+
+ // fn get_content_type(&self) -> &'static str {
+ // self.common_get_content_type()
+ // }
+
+ // fn get_url(
+ // &self,
+ // _req: &PaymentsCancelRouterData,
+ // connectors: &Connectors,
+ // ) -> CustomResult<String, errors::ConnectorError> {
+ // Ok(format!("{}gates/xurl", self.base_url(connectors)))
+ // }
+
+ // fn get_request_body(
+ // &self,
+ // req: &PaymentsCancelRouterData,
+ // _connectors: &Connectors,
+ // ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ // let connector_req = zift::ZiftCancelRequest::try_from(req)?;
+ // Ok(RequestContent::FormUrlEncoded(Box::new(connector_req)))
+ // }
+
+ fn build_request(
+ &self,
+ _req: &PaymentsCancelRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ Err(errors::ConnectorError::FlowNotSupported {
+ flow: "Void".to_owned(),
+ connector: "Zift".to_owned(),
+ }
+ .into())
+ // Ok(Some(
+ // RequestBuilder::new()
+ // .method(Method::Post)
+ // .url(&types::PaymentsVoidType::get_url(self, req, connectors)?)
+ // .attach_default_headers()
+ // .headers(types::PaymentsVoidType::get_headers(self, req, connectors)?)
+ // .set_body(types::PaymentsVoidType::get_request_body(
+ // self, req, connectors,
+ // )?)
+ // .build(),
+ // ))
+ }
+
+ // fn handle_response(
+ // &self,
+ // data: &PaymentsCancelRouterData,
+ // event_builder: Option<&mut ConnectorEvent>,
+ // res: Response,
+ // ) -> CustomResult<PaymentsCancelRouterData, errors::ConnectorError> {
+ // let response: zift::ZiftVoidResponse = serde_urlencoded::from_bytes(&res.response)
+ // .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ // event_builder.map(|i| i.set_response_body(&response));
+ // router_env::logger::info!(connector_response=?response);
+ // RouterData::try_from(ResponseRouterData {
+ // response,
+ // data: data.clone(),
+ // http_code: res.status_code,
+ // })
+ // }
+
+ // fn get_error_response(
+ // &self,
+ // res: Response,
+ // event_builder: Option<&mut ConnectorEvent>,
+ // ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
+ // self.build_error_response(res, event_builder)
+ // }
+}
impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Zift {
fn get_headers(
@@ -438,9 +517,9 @@ impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Zift {
fn get_url(
&self,
_req: &RefundsRouterData<Execute>,
- _connectors: &Connectors,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ Ok(format!("{}gates/xurl", self.base_url(connectors)))
}
fn get_request_body(
@@ -456,7 +535,7 @@ impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Zift {
let connector_router_data = zift::ZiftRouterData::from((refund_amount, req));
let connector_req = zift::ZiftRefundRequest::try_from(&connector_router_data)?;
- Ok(RequestContent::Json(Box::new(connector_req)))
+ Ok(RequestContent::FormUrlEncoded(Box::new(connector_req)))
}
fn build_request(
@@ -484,9 +563,7 @@ impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Zift {
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<RefundsRouterData<Execute>, errors::ConnectorError> {
- let response: zift::RefundResponse = res
- .response
- .parse_struct("zift RefundResponse")
+ let response: zift::RefundResponse = serde_urlencoded::from_bytes(&res.response)
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
@@ -507,62 +584,66 @@ impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Zift {
}
impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Zift {
- fn get_headers(
- &self,
- req: &RefundSyncRouterData,
- connectors: &Connectors,
- ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
- self.build_headers(req, connectors)
- }
-
- fn get_content_type(&self) -> &'static str {
- self.common_get_content_type()
- }
+ // fn get_headers(
+ // &self,
+ // req: &RefundSyncRouterData,
+ // connectors: &Connectors,
+ // ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
+ // self.build_headers(req, connectors)
+ // }
+
+ // fn get_content_type(&self) -> &'static str {
+ // self.common_get_content_type()
+ // }
+
+ // fn get_url(
+ // &self,
+ // _req: &RefundSyncRouterData,
+ // connectors: &Connectors,
+ // ) -> CustomResult<String, errors::ConnectorError> {
+ // Ok(format!("{}gates/xurl", self.base_url(connectors)))
+ // }
- fn get_url(
+ fn build_request(
&self,
_req: &RefundSyncRouterData,
_connectors: &Connectors,
- ) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
- }
-
- fn build_request(
- &self,
- req: &RefundSyncRouterData,
- connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
- Ok(Some(
- RequestBuilder::new()
- .method(Method::Get)
- .url(&types::RefundSyncType::get_url(self, req, connectors)?)
- .attach_default_headers()
- .headers(types::RefundSyncType::get_headers(self, req, connectors)?)
- .set_body(types::RefundSyncType::get_request_body(
- self, req, connectors,
- )?)
- .build(),
- ))
- }
-
- fn handle_response(
- &self,
- data: &RefundSyncRouterData,
- event_builder: Option<&mut ConnectorEvent>,
- res: Response,
- ) -> CustomResult<RefundSyncRouterData, errors::ConnectorError> {
- let response: zift::RefundResponse =
- res.response
- .parse_struct("zift RefundSyncResponse")
- .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
- event_builder.map(|i| i.set_response_body(&response));
- router_env::logger::info!(connector_response=?response);
- RouterData::try_from(ResponseRouterData {
- response,
- data: data.clone(),
- http_code: res.status_code,
- })
- }
+ // Ok(Some(
+ // RequestBuilder::new()
+ // .method(Method::Post)
+ // .url(&types::RefundSyncType::get_url(self, req, connectors)?)
+ // .attach_default_headers()
+ // .headers(types::RefundSyncType::get_headers(self, req, connectors)?)
+ // .set_body(types::RefundSyncType::get_request_body(
+ // self, req, connectors,
+ // )?)
+ // .build(),
+ // ))
+ Err(errors::ConnectorError::FlowNotSupported {
+ flow: "RefundSync".to_owned(),
+ connector: "Zift".to_owned(),
+ }
+ .into())
+ }
+ // }
+
+ // fn handle_response(
+ // &self,
+ // data: &RefundSyncRouterData,
+ // event_builder: Option<&mut ConnectorEvent>,
+ // res: Response,
+ // ) -> CustomResult<RefundSyncRouterData, errors::ConnectorError> {
+ // let response: zift::RefundResponse = serde_urlencoded::from_bytes(&res.response)
+ // .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ // event_builder.map(|i| i.set_response_body(&response));
+ // router_env::logger::info!(connector_response=?response);
+ // RouterData::try_from(ResponseRouterData {
+ // response,
+ // data: data.clone(),
+ // http_code: res.status_code,
+ // })
+ // }
fn get_error_response(
&self,
@@ -597,8 +678,64 @@ impl webhooks::IncomingWebhook for Zift {
}
}
-static ZIFT_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> =
- LazyLock::new(SupportedPaymentMethods::new);
+static ZIFT_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> = LazyLock::new(|| {
+ let supported_capture_methods = vec![
+ common_enums::CaptureMethod::Automatic,
+ common_enums::CaptureMethod::Manual,
+ common_enums::CaptureMethod::SequentialAutomatic,
+ ];
+
+ let supported_card_network = vec![
+ common_enums::CardNetwork::AmericanExpress,
+ common_enums::CardNetwork::DinersClub,
+ common_enums::CardNetwork::JCB,
+ common_enums::CardNetwork::Mastercard,
+ common_enums::CardNetwork::Visa,
+ common_enums::CardNetwork::Discover,
+ ];
+
+ let mut zift_supported_payment_methods = SupportedPaymentMethods::new();
+
+ zift_supported_payment_methods.add(
+ common_enums::PaymentMethod::Card,
+ common_enums::PaymentMethodType::Credit,
+ PaymentMethodDetails {
+ mandates: common_enums::FeatureStatus::Supported,
+ refunds: common_enums::FeatureStatus::Supported,
+ supported_capture_methods: supported_capture_methods.clone(),
+ specific_features: Some(
+ api_models::feature_matrix::PaymentMethodSpecificFeatures::Card({
+ api_models::feature_matrix::CardSpecificFeatures {
+ three_ds: common_enums::FeatureStatus::NotSupported,
+ no_three_ds: common_enums::FeatureStatus::Supported,
+ supported_card_networks: supported_card_network.clone(),
+ }
+ }),
+ ),
+ },
+ );
+
+ zift_supported_payment_methods.add(
+ common_enums::PaymentMethod::Card,
+ common_enums::PaymentMethodType::Debit,
+ PaymentMethodDetails {
+ mandates: common_enums::FeatureStatus::Supported,
+ refunds: common_enums::FeatureStatus::Supported,
+ supported_capture_methods: supported_capture_methods.clone(),
+ specific_features: Some(
+ api_models::feature_matrix::PaymentMethodSpecificFeatures::Card({
+ api_models::feature_matrix::CardSpecificFeatures {
+ three_ds: common_enums::FeatureStatus::NotSupported,
+ no_three_ds: common_enums::FeatureStatus::Supported,
+ supported_card_networks: supported_card_network.clone(),
+ }
+ }),
+ ),
+ },
+ );
+
+ zift_supported_payment_methods
+});
static ZIFT_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
display_name: "Zift",
diff --git a/crates/hyperswitch_connectors/src/connectors/zift/transformers.rs b/crates/hyperswitch_connectors/src/connectors/zift/transformers.rs
index e9dfcccc00..86e8fc6e6a 100644
--- a/crates/hyperswitch_connectors/src/connectors/zift/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/zift/transformers.rs
@@ -1,28 +1,64 @@
-use common_enums::enums;
-use common_utils::types::StringMinorUnit;
+use api_models::payments::AdditionalPaymentData;
+use common_enums::{enums, CountryAlpha2};
+use common_utils::{pii, types::StringMinorUnit};
+use error_stack::ResultExt;
use hyperswitch_domain_models::{
payment_method_data::PaymentMethodData,
- router_data::{ConnectorAuthType, RouterData},
- router_flow_types::refunds::{Execute, RSync},
- router_request_types::ResponseId,
- router_response_types::{PaymentsResponseData, RefundsResponseData},
- types::{PaymentsAuthorizeRouterData, RefundsRouterData},
+ router_data::{ConnectorAuthType, ErrorResponse, RouterData},
+ router_flow_types::{refunds::Execute, PSync},
+ router_request_types::{PaymentsAuthorizeData, PaymentsSyncData, ResponseId},
+ router_response_types::{MandateReference, PaymentsResponseData, RefundsResponseData},
+ types::{
+ PaymentsAuthorizeRouterData, PaymentsCaptureRouterData, PaymentsSyncRouterData,
+ RefundsRouterData,
+ },
+};
+use hyperswitch_interfaces::{
+ consts::{NO_ERROR_CODE, NO_ERROR_MESSAGE},
+ errors,
};
-use hyperswitch_interfaces::errors;
use masking::Secret;
use serde::{Deserialize, Serialize};
-use crate::types::{RefundsResponseRouterData, ResponseRouterData};
+use crate::{
+ types::{PaymentsCaptureResponseRouterData, RefundsResponseRouterData, ResponseRouterData},
+ utils::{AdditionalCardInfo, CardData, PaymentsAuthorizeRequestData, RouterData as _},
+};
+
+#[derive(Debug, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct ZiftAuthType {
+ user_name: Secret<String>,
+ password: Secret<String>,
+ account_id: Secret<String>,
+}
+impl TryFrom<&ConnectorAuthType> for ZiftAuthType {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> {
+ if let ConnectorAuthType::SignatureKey {
+ api_key,
+ key1,
+ api_secret,
+ } = auth_type
+ {
+ Ok(Self {
+ user_name: api_key.to_owned(),
+ password: api_secret.to_owned(),
+ account_id: key1.to_owned(),
+ })
+ } else {
+ Err(errors::ConnectorError::FailedToObtainAuthType.into())
+ }
+ }
+}
-//TODO: Fill the struct with respective fields
pub struct ZiftRouterData<T> {
- pub amount: StringMinorUnit, // The type of amount that a connector accepts, for example, String, i64, f64, etc.
+ pub amount: StringMinorUnit,
pub router_data: T,
}
impl<T> From<(StringMinorUnit, T)> for ZiftRouterData<T> {
fn from((amount, item): (StringMinorUnit, T)) -> Self {
- //Todo : use utils to convert the amount to the type of amount that a connector accepts
Self {
amount,
router_data: item,
@@ -30,148 +66,433 @@ impl<T> From<(StringMinorUnit, T)> for ZiftRouterData<T> {
}
}
-//TODO: Fill the struct with respective fields
-#[derive(Default, Debug, Serialize, PartialEq)]
-pub struct ZiftPaymentsRequest {
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub enum RequestType {
+ Sale,
+ #[serde(rename = "sale-auth")]
+ Auth,
+ Capture,
+ Refund,
+ Find,
+}
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub enum PaymentRequestType {
+ Sale,
+ #[serde(rename = "sale-auth")]
+ Auth,
+ Capture,
+}
+
+#[derive(Debug, Clone, Copy, Serialize, PartialEq, Eq)]
+pub enum AccountType {
+ #[serde(rename = "R")]
+ PaymentCard,
+ #[serde(rename = "S")]
+ Savings,
+ #[serde(rename = "C")]
+ Checking,
+}
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
+pub enum TransactionIndustryType {
+ #[serde(rename = "DM")]
+ CardNotPresent,
+ #[serde(rename = "RE")]
+ CardPresent,
+ #[serde(rename = "RS")]
+ Restaurant,
+ #[serde(rename = "LD")]
+ Lodging,
+ #[serde(rename = "PT")]
+ Petroleum,
+}
+#[derive(Debug, Clone, Copy, Serialize, PartialEq, Eq)]
+pub enum HolderType {
+ #[serde(rename = "P")]
+ Personal,
+ #[serde(rename = "O")]
+ Organizational,
+}
+#[derive(Debug, Serialize)]
+#[serde(untagged)]
+pub enum ZiftPaymentsRequest {
+ Card(ZiftCardPaymentRequest),
+ Mandate(ZiftMandatePaymentRequest),
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct ZiftCardPaymentRequest {
+ request_type: RequestType,
+ #[serde(flatten)]
+ auth: ZiftAuthType,
+ account_type: AccountType,
+ account_number: cards::CardNumber,
+ account_accessory: Secret<String>,
+ csc: Secret<String>,
+ transaction_industry_type: TransactionIndustryType,
+ holder_name: Secret<String>,
+ holder_type: HolderType,
+ amount: StringMinorUnit,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ street: Option<Secret<String>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ city: Option<String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ state: Option<Secret<String>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ zip_code: Option<Secret<String>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ country_code: Option<CountryAlpha2>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ email: Option<pii::Email>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ phone: Option<Secret<String>>,
+}
+// Mandate payment (MIT - Merchant Initiated)
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct ZiftMandatePaymentRequest {
+ request_type: RequestType,
+ #[serde(flatten)]
+ auth: ZiftAuthType,
+ account_type: AccountType,
+ token: Secret<String>,
+ account_accessory: Secret<String>,
+ // NO csc for MIT payments
+ transaction_industry_type: TransactionIndustryType,
+ holder_name: Secret<String>,
+ holder_type: HolderType,
amount: StringMinorUnit,
- card: ZiftCard,
+ transaction_mode_type: TransactionModeType,
+
+ // Required for MIT
+ transaction_category_type: TransactionCategoryType,
+ sequence_number: i32,
+ // Billing address
+ #[serde(skip_serializing_if = "Option::is_none")]
+ street: Option<Secret<String>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ city: Option<String>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ state: Option<Secret<String>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ zip_code: Option<Secret<String>>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ country_code: Option<CountryAlpha2>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ email: Option<pii::Email>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ phone: Option<Secret<String>>,
}
-#[derive(Default, Debug, Serialize, Eq, PartialEq)]
-pub struct ZiftCard {
- number: cards::CardNumber,
- expiry_month: Secret<String>,
- expiry_year: Secret<String>,
- cvc: Secret<String>,
- complete: bool,
+#[derive(Debug, Serialize)]
+pub enum TransactionModeType {
+ #[serde(rename = "P")]
+ CardPresent,
+ #[serde(rename = "N")]
+ CardNotPresent,
+}
+#[derive(Debug, Serialize)]
+pub enum TransactionCategoryType {
+ #[serde(rename = "R")]
+ Recurring,
+ #[serde(rename = "I")]
+ Installment,
+ #[serde(rename = "B")]
+ BillPayment,
}
impl TryFrom<&ZiftRouterData<&PaymentsAuthorizeRouterData>> for ZiftPaymentsRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(item: &ZiftRouterData<&PaymentsAuthorizeRouterData>) -> Result<Self, Self::Error> {
+ if item.router_data.is_three_ds() {
+ return Err(
+ errors::ConnectorError::NotImplemented("3DS Authentication".to_string()).into(),
+ );
+ }
+ let auth = ZiftAuthType::try_from(&item.router_data.connector_auth_type)?;
+ let request_type = if item.router_data.request.is_auto_capture()? {
+ RequestType::Sale
+ } else {
+ RequestType::Auth
+ };
match item.router_data.request.payment_method_data.clone() {
- PaymentMethodData::Card(_) => Err(errors::ConnectorError::NotImplemented(
- "Card payment method not implemented".to_string(),
- )
- .into()),
+ PaymentMethodData::Card(card) => {
+ let card_request = ZiftCardPaymentRequest {
+ request_type,
+ auth,
+ account_number: card.card_number.clone(),
+ account_accessory: card.get_expiry_date_as_mmyy()?,
+ transaction_industry_type: TransactionIndustryType::CardPresent,
+ holder_name: item.router_data.get_billing_full_name()?,
+ amount: item.amount.to_owned(),
+ account_type: AccountType::PaymentCard,
+ holder_type: HolderType::Personal,
+ csc: card.card_cvc,
+ street: item.router_data.get_optional_billing_line1(),
+ city: item.router_data.get_optional_billing_city(),
+ state: item.router_data.get_optional_billing_state(),
+ zip_code: item.router_data.get_optional_billing_zip(),
+ country_code: item.router_data.get_optional_billing_country(),
+ email: item.router_data.get_optional_billing_email(),
+ phone: item.router_data.get_optional_billing_phone_number(),
+ };
+ Ok(Self::Card(card_request))
+ }
+ PaymentMethodData::MandatePayment => {
+ let additional_card_details = match item
+ .router_data
+ .request
+ .additional_payment_method_data
+ .clone()
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "additional_payment_method_data",
+ })? {
+ AdditionalPaymentData::Card(card) => *card,
+ _ => Err(errors::ConnectorError::NotSupported {
+ message: "Payment Method Not Supported".to_string(),
+ connector: "DataTrans",
+ })?,
+ };
+ let mandate_request = ZiftMandatePaymentRequest {
+ request_type,
+ auth,
+ account_type: AccountType::PaymentCard,
+ token: Secret::new(item.router_data.request.connector_mandate_id().ok_or(
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "connector_mandate_id",
+ },
+ )?),
+ account_accessory: additional_card_details.get_expiry_date_as_mmyy()?,
+ transaction_industry_type: TransactionIndustryType::CardNotPresent,
+ holder_name: additional_card_details.get_card_holder_name()?,
+ holder_type: HolderType::Personal,
+ amount: item.amount.to_owned(),
+ transaction_mode_type: TransactionModeType::CardNotPresent,
+ transaction_category_type: TransactionCategoryType::Recurring,
+ sequence_number: 2, // Its required for MIT
+ street: item.router_data.get_optional_billing_line1(),
+ city: item.router_data.get_optional_billing_city(),
+ state: item.router_data.get_optional_billing_state(),
+ zip_code: item.router_data.get_optional_billing_zip(),
+ country_code: item.router_data.get_optional_billing_country(),
+ email: item.router_data.get_optional_billing_email(),
+ phone: item.router_data.get_optional_billing_phone_number(),
+ };
+ Ok(Self::Mandate(mandate_request))
+ }
_ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()),
}
}
}
-//TODO: Fill the struct with respective fields
-// Auth Struct
-pub struct ZiftAuthType {
- pub(super) api_key: Secret<String>,
+pub trait ResponseCodeExt {
+ fn is_pending(&self) -> bool;
+ fn is_approved(&self) -> bool;
+ fn is_failed(&self) -> bool;
}
-impl TryFrom<&ConnectorAuthType> for ZiftAuthType {
- type Error = error_stack::Report<errors::ConnectorError>;
- fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> {
- match auth_type {
- ConnectorAuthType::HeaderKey { api_key } => Ok(Self {
- api_key: api_key.to_owned(),
- }),
- _ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),
- }
+impl ResponseCodeExt for String {
+ fn is_pending(&self) -> bool {
+ self == "X02"
}
-}
-// PaymentsResponse
-//TODO: Append the remaining status flags
-#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, PartialEq)]
-#[serde(rename_all = "lowercase")]
-pub enum ZiftPaymentStatus {
- Succeeded,
- Failed,
- #[default]
- Processing,
-}
-
-impl From<ZiftPaymentStatus> for common_enums::AttemptStatus {
- fn from(item: ZiftPaymentStatus) -> Self {
- match item {
- ZiftPaymentStatus::Succeeded => Self::Charged,
- ZiftPaymentStatus::Failed => Self::Failure,
- ZiftPaymentStatus::Processing => Self::Authorizing,
- }
+ fn is_approved(&self) -> bool {
+ self.starts_with('A')
+ }
+ fn is_failed(&self) -> bool {
+ !(self.is_approved() || self.is_pending())
}
}
-//TODO: Fill the struct with respective fields
-#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]
-pub struct ZiftPaymentsResponse {
- status: ZiftPaymentStatus,
- id: String,
+#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]
+#[serde(rename_all = "camelCase")]
+pub struct ZiftErrorResponse {
+ pub response_code: String,
+ pub response_message: String,
+ pub failure_code: String,
+ pub failure_message: String,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
+#[serde(rename_all = "camelCase")]
+pub struct ZiftAuthPaymentsResponse {
+ pub response_code: String,
+ pub response_message: String,
+ pub transaction_id: Option<i64>,
+ pub token: Option<String>,
}
-impl<F, T> TryFrom<ResponseRouterData<F, ZiftPaymentsResponse, T, PaymentsResponseData>>
- for RouterData<F, T, PaymentsResponseData>
-{
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
+#[serde(rename_all = "camelCase")]
+pub struct ZiftCaptureResponse {
+ pub response_code: String,
+ pub response_message: String,
+}
+
+impl TryFrom<PaymentsCaptureResponseRouterData<ZiftCaptureResponse>> for PaymentsCaptureRouterData {
type Error = error_stack::Report<errors::ConnectorError>;
+
fn try_from(
- item: ResponseRouterData<F, ZiftPaymentsResponse, T, PaymentsResponseData>,
+ item: PaymentsCaptureResponseRouterData<ZiftCaptureResponse>,
) -> Result<Self, Self::Error> {
- Ok(Self {
- status: common_enums::AttemptStatus::from(item.response.status),
- response: Ok(PaymentsResponseData::TransactionResponse {
- resource_id: ResponseId::ConnectorTransactionId(item.response.id),
- redirection_data: Box::new(None),
- mandate_reference: Box::new(None),
- connector_metadata: None,
- network_txn_id: None,
- connector_response_reference_id: None,
- incremental_authorization_allowed: None,
- charges: None,
+ let capture_response = &item.response;
+
+ match capture_response.response_code.is_approved() {
+ true => Ok(Self {
+ status: common_enums::AttemptStatus::Charged,
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::NoResponseId,
+ redirection_data: Box::new(None),
+ mandate_reference: Box::new(None),
+ connector_metadata: None,
+ network_txn_id: None,
+ connector_response_reference_id: None,
+ incremental_authorization_allowed: None,
+ charges: None,
+ }),
+ ..item.data
}),
- ..item.data
- })
+
+ false => Ok(Self {
+ status: common_enums::AttemptStatus::CaptureFailed,
+ response: Err(ErrorResponse {
+ code: capture_response.response_code.clone(),
+ message: capture_response.response_message.clone(),
+ reason: Some(capture_response.response_message.clone()),
+ status_code: item.http_code,
+ attempt_status: None,
+ connector_transaction_id: None,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ }),
+ ..item.data
+ }),
+ }
}
}
-//TODO: Fill the struct with respective fields
-// REFUND :
-// Type definition for RefundRequest
-#[derive(Default, Debug, Serialize)]
+impl<F>
+ TryFrom<
+ ResponseRouterData<
+ F,
+ ZiftAuthPaymentsResponse,
+ PaymentsAuthorizeData,
+ PaymentsResponseData,
+ >,
+ > for RouterData<F, PaymentsAuthorizeData, PaymentsResponseData>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: ResponseRouterData<
+ F,
+ ZiftAuthPaymentsResponse,
+ PaymentsAuthorizeData,
+ PaymentsResponseData,
+ >,
+ ) -> Result<Self, Self::Error> {
+ let status = if item.response.response_code.is_approved() {
+ if item.data.request.is_auto_capture()? {
+ common_enums::AttemptStatus::Charged
+ } else {
+ common_enums::AttemptStatus::Authorized
+ }
+ } else if item.response.response_code.is_pending() {
+ common_enums::AttemptStatus::Pending
+ } else {
+ common_enums::AttemptStatus::Failure
+ };
+ if status != common_enums::AttemptStatus::Failure {
+ let mandate_reference: Box<Option<MandateReference>> =
+ if item.data.request.is_customer_initiated_mandate_payment() {
+ Box::new(item.response.token.clone().map(|token| MandateReference {
+ connector_mandate_id: Some(token),
+ payment_method_id: None,
+ mandate_metadata: None,
+ connector_mandate_request_reference_id: None,
+ }))
+ } else {
+ Box::new(None)
+ };
+
+ let transaction_id = item.response.transaction_id.ok_or_else(|| {
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "transaction_id",
+ }
+ })?;
+
+ Ok(Self {
+ status,
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::ConnectorTransactionId(transaction_id.to_string()),
+ redirection_data: Box::new(None),
+ mandate_reference,
+ connector_metadata: None,
+ network_txn_id: None,
+ connector_response_reference_id: None,
+ incremental_authorization_allowed: None,
+ charges: None,
+ }),
+ ..item.data
+ })
+ } else {
+ Ok(Self {
+ status: common_enums::AttemptStatus::Failure,
+ response: Err(ErrorResponse {
+ code: item.response.response_code.clone(),
+ message: item.response.response_message.clone(),
+ reason: Some(item.response.response_message.clone()),
+ status_code: item.http_code,
+ attempt_status: None,
+ connector_transaction_id: item.response.transaction_id.map(|id| id.to_string()),
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ }),
+ ..item.data
+ })
+ }
+ }
+}
+
+#[derive(Debug, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
pub struct ZiftRefundRequest {
- pub amount: StringMinorUnit,
+ request_type: RequestType,
+ #[serde(flatten)]
+ auth: ZiftAuthType,
+ transaction_id: String,
+ amount: StringMinorUnit,
}
impl<F> TryFrom<&ZiftRouterData<&RefundsRouterData<F>>> for ZiftRefundRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(item: &ZiftRouterData<&RefundsRouterData<F>>) -> Result<Self, Self::Error> {
+ let auth = ZiftAuthType::try_from(&item.router_data.connector_auth_type)?;
Ok(Self {
+ request_type: RequestType::Refund,
+ auth,
+ transaction_id: item.router_data.request.connector_transaction_id.clone(),
amount: item.amount.to_owned(),
})
}
}
-// Type definition for Refund Response
-
-#[allow(dead_code)]
-#[derive(Debug, Copy, Serialize, Default, Deserialize, Clone)]
-pub enum RefundStatus {
- Succeeded,
- Failed,
- #[default]
- Processing,
-}
-
-impl From<RefundStatus> for enums::RefundStatus {
- fn from(item: RefundStatus) -> Self {
- match item {
- RefundStatus::Succeeded => Self::Success,
- RefundStatus::Failed => Self::Failure,
- RefundStatus::Processing => Self::Pending,
- //TODO: Review mapping
- }
- }
-}
-
-//TODO: Fill the struct with respective fields
-#[derive(Default, Debug, Clone, Serialize, Deserialize)]
+// impl From<ResponseCode> for enums::RefundStatus {
+// fn from(item: enums::RefundStatus) -> Self {
+// match item {}
+// }
+// }
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
pub struct RefundResponse {
- id: String,
- status: RefundStatus,
+ transaction_id: String,
+ response_code: String,
+ response_message: Option<String>,
}
impl TryFrom<RefundsResponseRouterData<Execute, RefundResponse>> for RefundsRouterData<Execute> {
@@ -179,39 +500,207 @@ impl TryFrom<RefundsResponseRouterData<Execute, RefundResponse>> for RefundsRout
fn try_from(
item: RefundsResponseRouterData<Execute, RefundResponse>,
) -> Result<Self, Self::Error> {
+ let refund_response = &item.response;
+
+ let refund_status = if refund_response.response_code.is_approved() {
+ enums::RefundStatus::Success
+ } else if refund_response.response_code.is_pending() {
+ enums::RefundStatus::Pending
+ } else {
+ enums::RefundStatus::Failure
+ };
+ let response = if refund_response.response_code.is_approved() {
+ Ok(RefundsResponseData {
+ connector_refund_id: item.response.transaction_id.to_string(),
+ refund_status,
+ })
+ } else {
+ Err(ErrorResponse {
+ code: refund_response.response_code.clone(),
+ message: refund_response
+ .response_message
+ .clone()
+ .unwrap_or_else(|| NO_ERROR_MESSAGE.to_string()),
+ reason: refund_response.response_message.clone(),
+ status_code: item.http_code,
+ attempt_status: None,
+ connector_transaction_id: None,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ })
+ };
Ok(Self {
- response: Ok(RefundsResponseData {
- connector_refund_id: item.response.id.to_string(),
- refund_status: enums::RefundStatus::from(item.response.status),
- }),
+ response,
..item.data
})
}
}
-impl TryFrom<RefundsResponseRouterData<RSync, RefundResponse>> for RefundsRouterData<RSync> {
+// impl TryFrom<RefundsResponseRouterData<RSync, RefundResponse>> for RefundsRouterData<RSync> {
+// type Error = error_stack::Report<errors::ConnectorError>;
+// fn try_from(
+// item: RefundsResponseRouterData<RSync, RefundResponse>,
+// ) -> Result<Self, Self::Error> {
+// Ok(Self {
+// response: Ok(RefundsResponseData {
+// connector_refund_id: item.response.transaction_id.to_string(),
+// refund_status: enums::RefundStatus::from(item.response.response_code),
+// }),
+// ..item.data
+// })
+// }
+// }
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
+pub enum TransactionStatus {
+ #[serde(rename = "N")]
+ Pending,
+ #[serde(rename = "P")]
+ Processed,
+ #[serde(rename = "C")]
+ Cancelled,
+ #[serde(rename = "R")]
+ InRebill,
+}
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct ZiftSyncRequest {
+ request_type: RequestType,
+ #[serde(flatten)]
+ auth: ZiftAuthType,
+ transaction_id: i64,
+}
+impl TryFrom<&PaymentsSyncRouterData> for ZiftSyncRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &PaymentsSyncRouterData) -> Result<Self, Self::Error> {
+ let auth = ZiftAuthType::try_from(&item.connector_auth_type)?;
+ let transaction_id = item
+ .request
+ .connector_transaction_id
+ .get_connector_transaction_id()
+ .change_context(errors::ConnectorError::MissingConnectorTransactionID)?;
+
+ Ok(Self {
+ request_type: RequestType::Find,
+ auth,
+ transaction_id: transaction_id
+ .parse::<i64>()
+ .map_err(|_| errors::ConnectorError::ResponseDeserializationFailed)?,
+ })
+ }
+}
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct ZiftSyncResponse {
+ pub transaction_status: TransactionStatus,
+ pub transaction_type: PaymentRequestType,
+ pub response_message: Option<String>,
+ pub response_code: Option<String>,
+}
+
+impl TryFrom<ResponseRouterData<PSync, ZiftSyncResponse, PaymentsSyncData, PaymentsResponseData>>
+ for RouterData<PSync, PaymentsSyncData, PaymentsResponseData>
+{
type Error = error_stack::Report<errors::ConnectorError>;
+
fn try_from(
- item: RefundsResponseRouterData<RSync, RefundResponse>,
+ item: ResponseRouterData<PSync, ZiftSyncResponse, PaymentsSyncData, PaymentsResponseData>,
) -> Result<Self, Self::Error> {
+ let attempt_status = match item.response.transaction_type {
+ // Sale transactions
+ PaymentRequestType::Sale => match item.response.transaction_status {
+ TransactionStatus::Processed => common_enums::AttemptStatus::Charged,
+ TransactionStatus::Pending | TransactionStatus::InRebill => {
+ common_enums::AttemptStatus::Pending
+ }
+ TransactionStatus::Cancelled => common_enums::AttemptStatus::Failure,
+ },
+
+ // Auth transactions (sale-auth)
+ PaymentRequestType::Auth => match item.response.transaction_status {
+ TransactionStatus::Processed => common_enums::AttemptStatus::Authorized,
+ TransactionStatus::Pending | TransactionStatus::InRebill => {
+ common_enums::AttemptStatus::Pending
+ }
+ TransactionStatus::Cancelled => common_enums::AttemptStatus::Failure,
+ },
+
+ // Capture transactions
+ PaymentRequestType::Capture => match item.response.transaction_status {
+ TransactionStatus::Processed => common_enums::AttemptStatus::Charged,
+ TransactionStatus::Pending | TransactionStatus::InRebill => {
+ common_enums::AttemptStatus::CaptureInitiated
+ }
+ TransactionStatus::Cancelled => common_enums::AttemptStatus::CaptureFailed,
+ },
+ };
+ let response = if attempt_status == common_enums::AttemptStatus::Failure {
+ Err(ErrorResponse {
+ code: item
+ .response
+ .response_code
+ .clone()
+ .unwrap_or_else(|| NO_ERROR_CODE.to_string()),
+ message: item
+ .response
+ .response_message
+ .clone()
+ .unwrap_or_else(|| NO_ERROR_MESSAGE.to_string()),
+ reason: item.response.response_message,
+ status_code: item.http_code,
+ attempt_status: Some(attempt_status),
+ connector_transaction_id: None,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ })
+ } else {
+ Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::NoResponseId,
+ redirection_data: Box::new(None),
+ mandate_reference: Box::new(None),
+ connector_metadata: None,
+ network_txn_id: None,
+ connector_response_reference_id: None,
+ incremental_authorization_allowed: None,
+ charges: None,
+ })
+ };
+
Ok(Self {
- response: Ok(RefundsResponseData {
- connector_refund_id: item.response.id.to_string(),
- refund_status: enums::RefundStatus::from(item.response.status),
- }),
+ status: attempt_status,
+ response,
..item.data
})
}
}
-//TODO: Fill the struct with respective fields
-#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]
-pub struct ZiftErrorResponse {
- pub status_code: u16,
- pub code: String,
- pub message: String,
- pub reason: Option<String>,
- pub network_advice_code: Option<String>,
- pub network_decline_code: Option<String>,
- pub network_error_message: Option<String>,
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct ZiftCaptureRequest {
+ request_type: RequestType,
+ #[serde(flatten)]
+ auth: ZiftAuthType,
+ transaction_id: i64,
+ amount: StringMinorUnit,
+}
+
+impl TryFrom<&ZiftRouterData<&PaymentsCaptureRouterData>> for ZiftCaptureRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &ZiftRouterData<&PaymentsCaptureRouterData>) -> Result<Self, Self::Error> {
+ let auth = ZiftAuthType::try_from(&item.router_data.connector_auth_type)?;
+ Ok(Self {
+ request_type: RequestType::Capture,
+ auth,
+ transaction_id: item
+ .router_data
+ .request
+ .connector_transaction_id
+ .parse::<i64>()
+ .map_err(|_| errors::ConnectorError::ResponseDeserializationFailed)?,
+ amount: item.amount.to_owned(),
+ })
+ }
}
diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rs
index c270ddffac..f4e1955678 100644
--- a/crates/hyperswitch_connectors/src/utils.rs
+++ b/crates/hyperswitch_connectors/src/utils.rs
@@ -1795,6 +1795,8 @@ impl AddressDetailsData for AddressDetails {
pub trait AdditionalCardInfo {
fn get_card_expiry_year_2_digit(&self) -> Result<Secret<String>, errors::ConnectorError>;
fn get_card_expiry_year_4_digit(&self) -> Result<Secret<String>, errors::ConnectorError>;
+ fn get_expiry_date_as_mmyy(&self) -> Result<Secret<String>, errors::ConnectorError>;
+ fn get_card_holder_name(&self) -> Result<Secret<String>, errors::ConnectorError>;
}
impl AdditionalCardInfo for payments::AdditionalCardInfo {
@@ -1829,6 +1831,26 @@ impl AdditionalCardInfo for payments::AdditionalCardInfo {
Err(errors::ConnectorError::RequestEncodingFailed)
}
}
+ fn get_expiry_date_as_mmyy(&self) -> Result<Secret<String>, errors::ConnectorError> {
+ let year = self.get_card_expiry_year_2_digit()?.expose();
+ let month_binding =
+ self.card_exp_month
+ .clone()
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "card_exp_month",
+ })?;
+ let month = month_binding.peek();
+ let month_str = format!("{:0>2}", month);
+ Ok(Secret::new(format!("{month_str}{year}")))
+ }
+
+ fn get_card_holder_name(&self) -> Result<Secret<String>, errors::ConnectorError> {
+ self.card_holder_name
+ .clone()
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "card_holder_name",
+ })
+ }
}
pub trait PhoneDetailsData {
diff --git a/crates/payment_methods/src/configs/payment_connector_required_fields.rs b/crates/payment_methods/src/configs/payment_connector_required_fields.rs
index abe5f4e356..d61ca4fd93 100644
--- a/crates/payment_methods/src/configs/payment_connector_required_fields.rs
+++ b/crates/payment_methods/src/configs/payment_connector_required_fields.rs
@@ -1514,6 +1514,10 @@ fn get_cards_required_fields() -> HashMap<Connector, RequiredFieldFinal> {
.concat(),
),
),
+ (
+ Connector::Zift,
+ fields(vec![], vec![], [card_with_name()].concat()),
+ ),
(
Connector::Nuvei,
fields(
diff --git a/crates/router/src/core/connector_validation.rs b/crates/router/src/core/connector_validation.rs
index df6cedcef8..f650c48064 100644
--- a/crates/router/src/core/connector_validation.rs
+++ b/crates/router/src/core/connector_validation.rs
@@ -121,6 +121,10 @@ impl ConnectorAuthTypeAndMetadataValidation<'_> {
bitpay::transformers::BitpayAuthType::try_from(self.auth_type)?;
Ok(())
}
+ api_models::connector_enums::Connector::Zift => {
+ zift::transformers::ZiftAuthType::try_from(self.auth_type)?;
+ Ok(())
+ }
api_enums::Connector::Bambora => {
bambora::transformers::BamboraAuthType::try_from(self.auth_type)?;
Ok(())
diff --git a/crates/router/src/types/api/connector_mapping.rs b/crates/router/src/types/api/connector_mapping.rs
index 143086afcc..a0800c42b6 100644
--- a/crates/router/src/types/api/connector_mapping.rs
+++ b/crates/router/src/types/api/connector_mapping.rs
@@ -183,6 +183,7 @@ impl ConnectorData {
enums::Connector::Coingate => {
Ok(ConnectorEnum::Old(Box::new(connector::Coingate::new())))
}
+ enums::Connector::Zift => Ok(ConnectorEnum::Old(Box::new(connector::Zift::new()))),
enums::Connector::Cryptopay => {
Ok(ConnectorEnum::Old(Box::new(connector::Cryptopay::new())))
}
diff --git a/crates/router/src/types/api/feature_matrix.rs b/crates/router/src/types/api/feature_matrix.rs
index 6b9e6b0242..6bb0cda8c4 100644
--- a/crates/router/src/types/api/feature_matrix.rs
+++ b/crates/router/src/types/api/feature_matrix.rs
@@ -399,6 +399,7 @@ impl FeatureMatrixConnectorData {
enums::Connector::Silverflow => {
Ok(ConnectorEnum::Old(Box::new(connector::Silverflow::new())))
}
+ enums::Connector::Zift => Ok(ConnectorEnum::Old(Box::new(connector::Zift::new()))),
enums::Connector::Riskified => {
Ok(ConnectorEnum::Old(Box::new(connector::Riskified::new())))
}
diff --git a/crates/router/src/types/connector_transformers.rs b/crates/router/src/types/connector_transformers.rs
index d6709efc8d..cb23e22ae5 100644
--- a/crates/router/src/types/connector_transformers.rs
+++ b/crates/router/src/types/connector_transformers.rs
@@ -133,6 +133,7 @@ impl ForeignTryFrom<api_enums::Connector> for common_enums::RoutableConnectors {
api_enums::Connector::Redsys => Self::Redsys,
api_enums::Connector::Santander => Self::Santander,
api_enums::Connector::Shift4 => Self::Shift4,
+ api_enums::Connector::Zift => Self::Zift,
api_enums::Connector::Silverflow => Self::Silverflow,
api_enums::Connector::Signifyd => {
Err(common_utils::errors::ValidationError::InvalidValue {
diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml
index 5cc8b45242..18d5376da8 100644
--- a/loadtest/config/development.toml
+++ b/loadtest/config/development.toml
@@ -222,7 +222,7 @@ worldpayvantiv.secondary_base_url = "https://onlinessr.vantivprelive.com"
worldpayvantiv.third_base_url = "https://services.vantivprelive.com"
worldpayxml.base_url = "https://secure-test.worldpay.com/jsp/merchant/xml/paymentService.jsp"
xendit.base_url = "https://api.xendit.co"
-zift.base_url = "https://sandbox-secure.zift.io/gates/xurl?"
+zift.base_url = "https://sandbox-secure.zift.io/"
wise.base_url = "https://api.sandbox.transferwise.tech/"
zen.base_url = "https://api.zen-test.com/"
zen.secondary_base_url = "https://secure.zen-test.com/"