feat(connector): [shift4] Blik, Klarna, Bitpay PMs added (#8478)

This commit is contained in:
sweta-sharma
2025-07-03 19:16:23 +05:30
committed by GitHub
parent 2253d981c8
commit 37a95e3733
9 changed files with 154 additions and 6 deletions

View File

@ -822,6 +822,9 @@ boleto = { country = "BR", currency = "BRL" }
trustly = { currency = "CZK,DKK,EUR,GBP,NOK,SEK" }
ali_pay = { country = "CN", currency = "CNY" }
we_chat_pay = { country = "CN", currency = "CNY" }
klarna = { currency = "EUR,GBP,CHF,SEK" }
blik = { country = "PL", currency = "PLN" }
crypto_currency = { currency = "USD,GBP,AED" }
[pm_filters.inespay]
sepa = { country = "ES", currency = "EUR"}

View File

@ -655,6 +655,9 @@ boleto = { country = "BR", currency = "BRL" }
trustly = { currency = "CZK,DKK,EUR,GBP,NOK,SEK" }
ali_pay = { country = "CN", currency = "CNY" }
we_chat_pay = { country = "CN", currency = "CNY" }
klarna = { currency = "EUR,GBP,CHF,SEK" }
blik = { country = "PL", currency = "PLN" }
crypto_currency = { currency = "USD,GBP,AED" }
[pm_filters.placetopay]
credit = { country = "BE,CH,CO,CR,EC,HN,MX,PA,PR,UY", currency = "CLP,COP,USD"}

View File

@ -665,6 +665,9 @@ boleto = { country = "BR", currency = "BRL" }
trustly = { currency = "CZK,DKK,EUR,GBP,NOK,SEK" }
ali_pay = { country = "CN", currency = "CNY" }
we_chat_pay = { country = "CN", currency = "CNY" }
klarna = { currency = "EUR,GBP,CHF,SEK" }
blik = { country = "PL", currency = "PLN" }
crypto_currency = { currency = "USD,GBP,AED" }
[pm_filters.bluesnap]
credit = { country = "AD,AE,AG,AL,AM,AO,AR,AT,AU,AZ,BA,BB,BD,BE,BG,BH,BI,BJ,BN,BO,BR,BS,BT,BW,BY,BZ,CA,CD,CF,CG,CH,CI,CL,CM,CN,CO,CR,CV,CY,CZ,DE,DK,DJ,DM,DO,DZ,EC,EE,EG,ER,ES,ET,FI,FJ,FM,FR,GA,GB,GD,GE,GG,GH,GM,GN,GQ,GR,GT,GW,GY,HN,HR,HT,HU,ID,IE,IL,IN,IS,IT,JM,JP,JO,KE,KG,KH,KI,KM,KN,KR,KW,KZ,LA,LB,LC,LI,LK,LR,LS,LT,LU,LV,MA,MC,MD,ME,MG,MH,MK,ML,MM,MN,MR,MT,MU,MV,MW,MX,MY,MZ,NA,NE,NG,NI,NL,NO,NP,NR,NZ,OM,PA,PE,PG,PH,PK,PL,PS,PT,PW,PY,QA,RO,RS,RW,SA,SB,SC,SE,SG,SI,SK,SL,SM,SN,SO,SR,SS,ST,SV,SZ,TD,TG,TH,TJ,TL,TM,TN,TO,TR,TT,TV,TZ,UA,UG,US,UY,UZ,VA,VC,VE,VN,VU,WS,ZA,ZM,ZW", currency = "AED,AFN,ALL,AMD,ANG,ARS,AUD,AWG,BAM,BBD,BGN,BHD,BMD,BND,BOB,BRL,BSD,BWP,CAD,CHF,CLP,CNY,COP,CRC,CZK,DKK,DOP,DZD,EGP,EUR,FJD,GBP,GEL,GIP,GTQ,HKD,HUF,IDR,ILS,INR,ISK,JMD,JPY,KES,KHR,KRW,KWD,KYD,KZT,LBP,LKR,MAD,MDL,MKD,MUR,MWK,MXN,MYR,NAD,NGN,NOK,NPR,NZD,OMR,PAB,PEN,PGK,PHP,PLN,PKR,QAR,RON,RSD,RUB,SAR,SCR,SDG,SEK,SGD,THB,TND,TRY,TTD,TWD,TZS,UAH,USD,UYU,UZS,VND,XAF,XCD,XOF,ZAR"}

View File

@ -686,6 +686,9 @@ boleto = { country = "BR", currency = "BRL" }
trustly = { currency = "CZK,DKK,EUR,GBP,NOK,SEK" }
ali_pay = { country = "CN", currency = "CNY" }
we_chat_pay = { country = "CN", currency = "CNY" }
klarna = { currency = "EUR,GBP,CHF,SEK" }
blik = { country = "PL", currency = "PLN" }
crypto_currency = { currency = "USD,GBP,AED" }
[pm_filters.placetopay]
credit = { country = "BE,CH,CO,CR,EC,HN,MX,PA,PR,UY", currency = "CLP,COP,USD"}

View File

@ -848,6 +848,9 @@ boleto = { country = "BR", currency = "BRL" }
trustly = { currency = "CZK,DKK,EUR,GBP,NOK,SEK" }
ali_pay = { country = "CN", currency = "CNY" }
we_chat_pay = { country = "CN", currency = "CNY" }
klarna = { currency = "EUR,GBP,CHF,SEK" }
blik = { country = "PL", currency = "PLN" }
crypto_currency = { currency = "USD,GBP,AED" }
[pm_filters.placetopay]
credit = { country = "BE,CH,CO,CR,EC,HN,MX,PA,PR,UY", currency = "CLP,COP,USD"}

View File

@ -784,6 +784,9 @@ boleto = { country = "BR", currency = "BRL" }
trustly = { currency = "CZK,DKK,EUR,GBP,NOK,SEK" }
ali_pay = { country = "CN", currency = "CNY" }
we_chat_pay = { country = "CN", currency = "CNY" }
klarna = { currency = "EUR,GBP,CHF,SEK" }
blik = { country = "PL", currency = "PLN" }
crypto_currency = { currency = "USD,GBP,AED" }
[pm_filters.inespay]
sepa = { country = "ES", currency = "EUR"}

View File

@ -920,6 +920,17 @@ lazy_static! {
}
);
shift4_supported_payment_methods.add(
enums::PaymentMethod::BankRedirect,
enums::PaymentMethodType::Blik,
PaymentMethodDetails{
mandates: enums::FeatureStatus::NotSupported,
refunds: enums::FeatureStatus::Supported,
supported_capture_methods: supported_capture_methods2.clone(),
specific_features: None
}
);
shift4_supported_payment_methods.add(
enums::PaymentMethod::Voucher,
enums::PaymentMethodType::Boleto,
@ -991,6 +1002,28 @@ lazy_static! {
},
);
shift4_supported_payment_methods.add(
enums::PaymentMethod::PayLater,
enums::PaymentMethodType::Klarna,
PaymentMethodDetails {
mandates: enums::FeatureStatus::NotSupported,
refunds: enums::FeatureStatus::Supported,
supported_capture_methods: supported_capture_methods2.clone(),
specific_features: None,
},
);
shift4_supported_payment_methods.add(
enums::PaymentMethod::Crypto,
enums::PaymentMethodType::CryptoCurrency,
PaymentMethodDetails {
mandates: enums::FeatureStatus::NotSupported,
refunds: enums::FeatureStatus::Supported,
supported_capture_methods: supported_capture_methods2.clone(),
specific_features: None,
},
);
shift4_supported_payment_methods
};

View File

@ -9,8 +9,8 @@ use common_utils::{
use error_stack::ResultExt;
use hyperswitch_domain_models::{
payment_method_data::{
BankRedirectData, BankTransferData, Card as CardData, GiftCardData, PaymentMethodData,
VoucherData, WalletData,
BankRedirectData, BankTransferData, Card as CardData, CryptoData, GiftCardData,
PayLaterData, PaymentMethodData, VoucherData, WalletData,
},
router_data::{ConnectorAuthType, RouterData},
router_flow_types::refunds::{Execute, RSync},
@ -135,6 +135,8 @@ pub enum Shift4PaymentMethod {
Cards3DSRequest(Box<Cards3DSRequest>),
VoucherRequest(Box<VoucherRequest>),
WalletRequest(Box<WalletRequest>),
PayLaterRequest(Box<PayLaterRequest>),
CryptoRequest(Box<CryptoRequest>),
}
#[derive(Debug, Serialize)]
@ -144,6 +146,20 @@ pub struct WalletRequest {
payment_method: PaymentMethod,
}
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PayLaterRequest {
flow: Flow,
payment_method: PaymentMethod,
}
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CryptoRequest {
flow: Flow,
payment_method: PaymentMethod,
}
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct VoucherRequest {
@ -185,7 +201,7 @@ pub struct Flow {
}
#[derive(Debug, Serialize)]
#[serde(rename_all = "lowercase")]
#[serde(rename_all = "snake_case")]
pub enum PaymentMethodType {
Eps,
Giropay,
@ -195,6 +211,9 @@ pub enum PaymentMethodType {
Trustly,
Alipay,
Wechatpay,
Blik,
KlarnaDebitRisk,
Bitpay,
}
#[derive(Debug, Serialize)]
@ -264,6 +283,48 @@ where
}
}
impl TryFrom<&PayLaterData> for PaymentMethodType {
type Error = Error;
fn try_from(value: &PayLaterData) -> Result<Self, Self::Error> {
match value {
PayLaterData::KlarnaRedirect { .. } => Ok(Self::KlarnaDebitRisk),
PayLaterData::AffirmRedirect { .. }
| PayLaterData::AfterpayClearpayRedirect { .. }
| PayLaterData::PayBrightRedirect { .. }
| PayLaterData::WalleyRedirect { .. }
| PayLaterData::AlmaRedirect { .. }
| PayLaterData::AtomeRedirect { .. }
| PayLaterData::KlarnaSdk { .. } => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("Shift4"),
)
.into()),
}
}
}
impl<T, Req> TryFrom<(&RouterData<T, Req, PaymentsResponseData>, &PayLaterData)>
for Shift4PaymentMethod
where
Req: Shift4AuthorizePreprocessingCommon,
{
type Error = Error;
fn try_from(
(item, pay_later_data): (&RouterData<T, Req, PaymentsResponseData>, &PayLaterData),
) -> Result<Self, Self::Error> {
let flow = Flow::try_from(item.request.get_router_return_url())?;
let method_type = PaymentMethodType::try_from(pay_later_data)?;
let billing = Billing::try_from(item)?;
let payment_method = PaymentMethod {
method_type,
billing,
};
Ok(Self::BankRedirectRequest(Box::new(BankRedirectRequest {
payment_method,
flow,
})))
}
}
impl<T, Req> TryFrom<&RouterData<T, Req, PaymentsResponseData>> for Shift4PaymentMethod
where
Req: Shift4AuthorizePreprocessingCommon,
@ -281,10 +342,12 @@ where
PaymentMethodData::GiftCard(ref giftcard_data) => {
Self::try_from(giftcard_data.as_ref())
}
PaymentMethodData::PayLater(ref pay_later_data) => {
Self::try_from((item, pay_later_data))
}
PaymentMethodData::Crypto(ref crypto_data) => Self::try_from((item, crypto_data)),
PaymentMethodData::CardRedirect(_)
| PaymentMethodData::PayLater(_)
| PaymentMethodData::BankDebit(_)
| PaymentMethodData::Crypto(_)
| PaymentMethodData::MandatePayment
| PaymentMethodData::Reward
| PaymentMethodData::RealTimePayment(_)
@ -527,6 +590,37 @@ where
}
}
impl TryFrom<&CryptoData> for PaymentMethodType {
type Error = Error;
fn try_from(_value: &CryptoData) -> Result<Self, Self::Error> {
Ok(Self::Bitpay)
}
}
impl<T, Req> TryFrom<(&RouterData<T, Req, PaymentsResponseData>, &CryptoData)>
for Shift4PaymentMethod
where
Req: Shift4AuthorizePreprocessingCommon,
{
type Error = Error;
fn try_from(
(item, redirect_data): (&RouterData<T, Req, PaymentsResponseData>, &CryptoData),
) -> Result<Self, Self::Error> {
let flow = Flow::try_from(item.request.get_router_return_url())?;
let method_type = PaymentMethodType::try_from(redirect_data)?;
let billing = Billing::try_from(item)?;
let payment_method = PaymentMethod {
method_type,
billing,
};
Ok(Self::CryptoRequest(Box::new(CryptoRequest {
payment_method,
flow,
})))
}
}
impl<T> TryFrom<&Shift4RouterData<&RouterData<T, CompleteAuthorizeData, PaymentsResponseData>>>
for Shift4PaymentsRequest
{
@ -585,8 +679,8 @@ impl TryFrom<&BankRedirectData> for PaymentMethodType {
BankRedirectData::Ideal { .. } => Ok(Self::Ideal),
BankRedirectData::Sofort { .. } => Ok(Self::Sofort),
BankRedirectData::Trustly { .. } => Ok(Self::Trustly),
BankRedirectData::Blik { .. } => Ok(Self::Blik),
BankRedirectData::BancontactCard { .. }
| BankRedirectData::Blik { .. }
| BankRedirectData::Eft { .. }
| BankRedirectData::Przelewy24 { .. }
| BankRedirectData::Bizum {}

View File

@ -473,6 +473,9 @@ boleto = { country = "BR", currency = "BRL" }
trustly = { currency = "CZK,DKK,EUR,GBP,NOK,SEK" }
ali_pay = { country = "CN", currency = "CNY" }
we_chat_pay = { country = "CN", currency = "CNY" }
klarna = { currency = "EUR,GBP,CHF,SEK" }
blik = { country = "PL", currency = "PLN" }
crypto_currency = { currency = "USD,GBP,AED" }
[pm_filters.getnet]
credit = { country = "AR, BR, CL, MX, UY, ES, PT, DE, IT, FR, NL, BE, AT, PL, CH, GB, IE, LU, DK, SE, NO, FI, IN, AE", currency = "ARS, BRL, CLP, MXN, UYU, EUR, PLN, CHF, GBP, DKK, SEK, NOK, INR, AED" }