mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
feat(router): add new payment methods for Bank redirects, BNPL and wallet (#864)
This commit is contained in:
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -2767,7 +2767,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "opentelemetry"
|
name = "opentelemetry"
|
||||||
version = "0.18.0"
|
version = "0.18.0"
|
||||||
source = "git+https://github.com/open-telemetry/opentelemetry-rust/?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658"
|
source = "git+https://github.com/open-telemetry/opentelemetry-rust?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"opentelemetry_api",
|
"opentelemetry_api",
|
||||||
"opentelemetry_sdk",
|
"opentelemetry_sdk",
|
||||||
@ -2776,7 +2776,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "opentelemetry-otlp"
|
name = "opentelemetry-otlp"
|
||||||
version = "0.11.0"
|
version = "0.11.0"
|
||||||
source = "git+https://github.com/open-telemetry/opentelemetry-rust/?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658"
|
source = "git+https://github.com/open-telemetry/opentelemetry-rust?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"futures",
|
"futures",
|
||||||
@ -2793,7 +2793,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "opentelemetry-proto"
|
name = "opentelemetry-proto"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/open-telemetry/opentelemetry-rust/?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658"
|
source = "git+https://github.com/open-telemetry/opentelemetry-rust?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
@ -2805,7 +2805,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "opentelemetry_api"
|
name = "opentelemetry_api"
|
||||||
version = "0.18.0"
|
version = "0.18.0"
|
||||||
source = "git+https://github.com/open-telemetry/opentelemetry-rust/?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658"
|
source = "git+https://github.com/open-telemetry/opentelemetry-rust?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fnv",
|
"fnv",
|
||||||
"futures-channel",
|
"futures-channel",
|
||||||
@ -2820,7 +2820,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "opentelemetry_sdk"
|
name = "opentelemetry_sdk"
|
||||||
version = "0.18.0"
|
version = "0.18.0"
|
||||||
source = "git+https://github.com/open-telemetry/opentelemetry-rust/?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658"
|
source = "git+https://github.com/open-telemetry/opentelemetry-rust?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
|
|||||||
@ -142,6 +142,12 @@ adyen = { banks = "bank_austria,bawag_psk_ag,dolomitenbank,easybank_ag,erste_ban
|
|||||||
stripe = { banks = "abn_amro,asn_bank,bunq,handelsbanken,ing,knab,moneyou,rabobank,regiobank,revolut,sns_bank,triodos_bank,van_lanschot" }
|
stripe = { banks = "abn_amro,asn_bank,bunq,handelsbanken,ing,knab,moneyou,rabobank,regiobank,revolut,sns_bank,triodos_bank,van_lanschot" }
|
||||||
adyen = { banks = "abn_amro,asn_bank,bunq,handelsbanken,ing,knab,moneyou,rabobank,regiobank,revolut,sns_bank,triodos_bank,van_lanschot" }
|
adyen = { banks = "abn_amro,asn_bank,bunq,handelsbanken,ing,knab,moneyou,rabobank,regiobank,revolut,sns_bank,triodos_bank,van_lanschot" }
|
||||||
|
|
||||||
|
[bank_config.online_banking_czech_republic]
|
||||||
|
adyen = { banks = "ceska_sporitelna,komercni_banka,platnosc_online_karta_platnicza"}
|
||||||
|
|
||||||
|
[bank_config.online_banking_slovakia]
|
||||||
|
adyen = { banks = "e_platby_v_u_b,postova_banka,sporo_pay,tatra_pay,viamo,volksbank_gruppe,volkskredit_bank_ag,vr_bank_braunau"}
|
||||||
|
|
||||||
[pm_filters.stripe]
|
[pm_filters.stripe]
|
||||||
google_pay = { country = "AL,DZ,AS,AO,AG,AR,AU,AT,AZ,BH,BY,BE,BR,BG,CA,CL,CO,HR,CZ,DK,DO,EG,EE,FI,FR,DE,GR,HK,HU,IN,ID,IE,IL,IT,JP,JO,KZ,KE,KW,LV,LB,LT,LU,MY,MX,NL,NZ,NO,OM,PK,PA,PE,PH,PL,PT,QA,RO,RU,SA,SG,SK,ZA,ES,LK,SE,CH,TW,TH,TR,UA,AE,GB,US,UY,VN" }
|
google_pay = { country = "AL,DZ,AS,AO,AG,AR,AU,AT,AZ,BH,BY,BE,BR,BG,CA,CL,CO,HR,CZ,DK,DO,EG,EE,FI,FR,DE,GR,HK,HU,IN,ID,IE,IL,IT,JP,JO,KZ,KE,KW,LV,LB,LT,LU,MY,MX,NL,NZ,NO,OM,PK,PA,PE,PH,PL,PT,QA,RO,RU,SA,SG,SK,ZA,ES,LK,SE,CH,TW,TH,TR,UA,AE,GB,US,UY,VN" }
|
||||||
apple_pay = { country = "AU,CN,HK,JP,MO,MY,NZ,SG,TW,AM,AT,AZ,BY,BE,BG,HR,CY,CZ,DK,EE,FO,FI,FR,GE,DE,GR,GL,GG,HU,IS,IE,IM,IT,KZ,JE,LV,LI,LT,LU,MT,MD,MC,ME,NL,NO,PL,PT,RO,SM,RS,SK,SI,ES,SE,CH,UA,GB,AR,CO,CR,BR,MX,PE,BH,IL,JO,KW,PS,QA,SA,AE,CA,UM,US" }
|
apple_pay = { country = "AU,CN,HK,JP,MO,MY,NZ,SG,TW,AM,AT,AZ,BY,BE,BG,HR,CY,CZ,DK,EE,FO,FI,FR,GE,DE,GR,GL,GG,HU,IS,IE,IM,IT,KZ,JE,LV,LI,LT,LU,MT,MD,MC,ME,NL,NO,PL,PT,RO,SM,RS,SK,SI,ES,SE,CH,UA,GB,AR,CO,CR,BR,MX,PE,BH,IL,JO,KW,PS,QA,SA,AE,CA,UM,US" }
|
||||||
|
|||||||
@ -409,19 +409,34 @@ pub enum PaymentExperience {
|
|||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
#[strum(serialize_all = "snake_case")]
|
#[strum(serialize_all = "snake_case")]
|
||||||
pub enum PaymentMethodType {
|
pub enum PaymentMethodType {
|
||||||
Credit,
|
|
||||||
Debit,
|
|
||||||
Giropay,
|
|
||||||
Ideal,
|
|
||||||
Sofort,
|
|
||||||
Eps,
|
|
||||||
Klarna,
|
|
||||||
Affirm,
|
Affirm,
|
||||||
AfterpayClearpay,
|
AfterpayClearpay,
|
||||||
GooglePay,
|
AliPay,
|
||||||
ApplePay,
|
ApplePay,
|
||||||
Paypal,
|
BancontactCard,
|
||||||
|
Blik,
|
||||||
|
Credit,
|
||||||
CryptoCurrency,
|
CryptoCurrency,
|
||||||
|
Debit,
|
||||||
|
Eps,
|
||||||
|
Giropay,
|
||||||
|
GooglePay,
|
||||||
|
Ideal,
|
||||||
|
Klarna,
|
||||||
|
MbWay,
|
||||||
|
MobilePay,
|
||||||
|
OnlineBankingCzechRepublic,
|
||||||
|
OnlineBankingFinland,
|
||||||
|
OnlineBankingPoland,
|
||||||
|
OnlineBankingSlovakia,
|
||||||
|
PayBright,
|
||||||
|
Paypal,
|
||||||
|
Przelewy24,
|
||||||
|
Sofort,
|
||||||
|
Swish,
|
||||||
|
Trustly,
|
||||||
|
Walley,
|
||||||
|
WeChatPay,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
@ -684,6 +699,8 @@ pub enum BankNames {
|
|||||||
AmericanExpress,
|
AmericanExpress,
|
||||||
BankOfAmerica,
|
BankOfAmerica,
|
||||||
Barclays,
|
Barclays,
|
||||||
|
#[serde(rename = "BLIK - PSP")]
|
||||||
|
BlikPSP,
|
||||||
CapitalOne,
|
CapitalOne,
|
||||||
Chase,
|
Chase,
|
||||||
Citi,
|
Citi,
|
||||||
@ -711,13 +728,21 @@ pub enum BankNames {
|
|||||||
Bank99Ag,
|
Bank99Ag,
|
||||||
BankhausCarlSpangler,
|
BankhausCarlSpangler,
|
||||||
BankhausSchelhammerUndSchatteraAg,
|
BankhausSchelhammerUndSchatteraAg,
|
||||||
|
#[serde(rename = "Bank Millennium")]
|
||||||
|
BankMillennium,
|
||||||
|
#[serde(rename = "Bank PEKAO S.A.")]
|
||||||
|
BankPEKAOSA,
|
||||||
BawagPskAg,
|
BawagPskAg,
|
||||||
BksBankAg,
|
BksBankAg,
|
||||||
BrullKallmusBankAg,
|
BrullKallmusBankAg,
|
||||||
BtvVierLanderBank,
|
BtvVierLanderBank,
|
||||||
CapitalBankGraweGruppeAg,
|
CapitalBankGraweGruppeAg,
|
||||||
|
#[serde(rename = "Česká spořitelna")]
|
||||||
|
CeskaSporitelna,
|
||||||
Dolomitenbank,
|
Dolomitenbank,
|
||||||
EasybankAg,
|
EasybankAg,
|
||||||
|
#[serde(rename = "ePlatby VÚB")]
|
||||||
|
EPlatbyVUB,
|
||||||
ErsteBankUndSparkassen,
|
ErsteBankUndSparkassen,
|
||||||
HypoAlpeadriabankInternationalAg,
|
HypoAlpeadriabankInternationalAg,
|
||||||
HypoNoeLbFurNiederosterreichUWien,
|
HypoNoeLbFurNiederosterreichUWien,
|
||||||
@ -725,17 +750,57 @@ pub enum BankNames {
|
|||||||
HypoTirolBankAg,
|
HypoTirolBankAg,
|
||||||
HypoVorarlbergBankAg,
|
HypoVorarlbergBankAg,
|
||||||
HypoBankBurgenlandAktiengesellschaft,
|
HypoBankBurgenlandAktiengesellschaft,
|
||||||
|
#[serde(rename = "Komercní banka")]
|
||||||
|
KomercniBanka,
|
||||||
|
#[serde(rename = "mBank - mTransfer")]
|
||||||
|
MBank,
|
||||||
MarchfelderBank,
|
MarchfelderBank,
|
||||||
OberbankAg,
|
OberbankAg,
|
||||||
OsterreichischeArzteUndApothekerbank,
|
OsterreichischeArzteUndApothekerbank,
|
||||||
|
#[serde(rename = "Pay with ING")]
|
||||||
|
PayWithING,
|
||||||
|
#[serde(rename = "Płacę z iPKO")]
|
||||||
|
PlaceZIPKO,
|
||||||
|
#[serde(rename = "Płatność online kartą płatniczą")]
|
||||||
|
PlatnoscOnlineKartaPlatnicza,
|
||||||
PosojilnicaBankEGen,
|
PosojilnicaBankEGen,
|
||||||
|
#[serde(rename = "Poštová banka")]
|
||||||
|
PostovaBanka,
|
||||||
RaiffeisenBankengruppeOsterreich,
|
RaiffeisenBankengruppeOsterreich,
|
||||||
SchelhammerCapitalBankAg,
|
SchelhammerCapitalBankAg,
|
||||||
SchoellerbankAg,
|
SchoellerbankAg,
|
||||||
SpardaBankWien,
|
SpardaBankWien,
|
||||||
|
SporoPay,
|
||||||
|
#[serde(rename = "Santander-Przelew24")]
|
||||||
|
SantanderPrzelew24,
|
||||||
|
TatraPay,
|
||||||
|
Viamo,
|
||||||
VolksbankGruppe,
|
VolksbankGruppe,
|
||||||
VolkskreditbankAg,
|
VolkskreditbankAg,
|
||||||
VrBankBraunau,
|
VrBankBraunau,
|
||||||
|
#[serde(rename = "Pay with Alior Bank")]
|
||||||
|
PayWithAliorBank,
|
||||||
|
#[serde(rename = "Banki Spółdzielcze")]
|
||||||
|
BankiSpoldzielcze,
|
||||||
|
#[serde(rename = "Pay with Inteligo")]
|
||||||
|
PayWithInteligo,
|
||||||
|
#[serde(rename = "BNP Paribas Poland")]
|
||||||
|
BNPParibasPoland,
|
||||||
|
#[serde(rename = "Bank Nowy S.A.")]
|
||||||
|
BankNowySA,
|
||||||
|
#[serde(rename = "Credit Agricole")]
|
||||||
|
CreditAgricole,
|
||||||
|
#[serde(rename = "Pay with BOŚ")]
|
||||||
|
PayWithBOS,
|
||||||
|
#[serde(rename = "Pay with CitiHandlowy")]
|
||||||
|
PayWithCitiHandlowy,
|
||||||
|
#[serde(rename = "Pay with Plus Bank")]
|
||||||
|
PayWithPlusBank,
|
||||||
|
#[serde(rename = "Toyota Bank")]
|
||||||
|
ToyotaBank,
|
||||||
|
VeloBank,
|
||||||
|
#[serde(rename = "e-transfer Pocztowy24")]
|
||||||
|
ETransferPocztowy24,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
|
|||||||
@ -454,6 +454,8 @@ pub enum PayLaterData {
|
|||||||
#[schema(value_type = String)]
|
#[schema(value_type = String)]
|
||||||
billing_name: Secret<String>,
|
billing_name: Secret<String>,
|
||||||
},
|
},
|
||||||
|
PayBright {},
|
||||||
|
Walley {},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
|
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||||
@ -510,6 +512,26 @@ impl From<&PaymentMethodData> for AdditionalPaymentData {
|
|||||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
|
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum BankRedirectData {
|
pub enum BankRedirectData {
|
||||||
|
BancontactCard {
|
||||||
|
/// The card number
|
||||||
|
#[schema(value_type = String, example = "4242424242424242")]
|
||||||
|
card_number: Secret<String, pii::CardNumber>,
|
||||||
|
/// The card's expiry month
|
||||||
|
#[schema(value_type = String, example = "24")]
|
||||||
|
card_exp_month: Secret<String>,
|
||||||
|
|
||||||
|
/// The card's expiry year
|
||||||
|
#[schema(value_type = String, example = "24")]
|
||||||
|
card_exp_year: Secret<String>,
|
||||||
|
|
||||||
|
/// The card holder's name
|
||||||
|
#[schema(value_type = String, example = "John Test")]
|
||||||
|
card_holder_name: Secret<String>,
|
||||||
|
},
|
||||||
|
Blik {
|
||||||
|
// Blik Code
|
||||||
|
blik_code: String,
|
||||||
|
},
|
||||||
Eps {
|
Eps {
|
||||||
/// The billing details for bank redirection
|
/// The billing details for bank redirection
|
||||||
billing_details: BankRedirectBilling,
|
billing_details: BankRedirectBilling,
|
||||||
@ -530,6 +552,23 @@ pub enum BankRedirectData {
|
|||||||
#[schema(value_type = BankNames, example = "abn_amro")]
|
#[schema(value_type = BankNames, example = "abn_amro")]
|
||||||
bank_name: api_enums::BankNames,
|
bank_name: api_enums::BankNames,
|
||||||
},
|
},
|
||||||
|
OnlineBankingCzechRepublic {
|
||||||
|
// Issuer banks
|
||||||
|
issuer: api_enums::BankNames,
|
||||||
|
},
|
||||||
|
OnlineBankingFinland {
|
||||||
|
// Shopper Email
|
||||||
|
email: Option<Secret<String, pii::Email>>,
|
||||||
|
},
|
||||||
|
OnlineBankingPoland {
|
||||||
|
// Issuer banks
|
||||||
|
issuer: api_enums::BankNames,
|
||||||
|
},
|
||||||
|
OnlineBankingSlovakia {
|
||||||
|
// Issuer value corresponds to the bank
|
||||||
|
issuer: api_enums::BankNames,
|
||||||
|
},
|
||||||
|
Przelewy24 {},
|
||||||
Sofort {
|
Sofort {
|
||||||
/// The billing details for bank redirection
|
/// The billing details for bank redirection
|
||||||
billing_details: BankRedirectBilling,
|
billing_details: BankRedirectBilling,
|
||||||
@ -542,6 +581,8 @@ pub enum BankRedirectData {
|
|||||||
#[schema(example = "en")]
|
#[schema(example = "en")]
|
||||||
preferred_language: String,
|
preferred_language: String,
|
||||||
},
|
},
|
||||||
|
Swish {},
|
||||||
|
Trustly {},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
|
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||||
@ -565,14 +606,21 @@ pub struct BankRedirectBilling {
|
|||||||
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum WalletData {
|
pub enum WalletData {
|
||||||
/// The wallet data for Google pay
|
/// The wallet data for Ali Pay redirect
|
||||||
GooglePay(GooglePayWalletData),
|
AliPay(AliPayRedirection),
|
||||||
/// The wallet data for Apple pay
|
/// The wallet data for Apple pay
|
||||||
ApplePay(ApplePayWalletData),
|
ApplePay(ApplePayWalletData),
|
||||||
/// The wallet data for Paypal
|
/// The wallet data for Google pay
|
||||||
PaypalSdk(PayPalWalletData),
|
GooglePay(GooglePayWalletData),
|
||||||
|
MbWay(Box<MbWayRedirection>),
|
||||||
|
/// The wallet data for MobilePay redirect
|
||||||
|
MobilePay(Box<MobilePayRedirection>),
|
||||||
/// This is for paypal redirection
|
/// This is for paypal redirection
|
||||||
PaypalRedirect(PaypalRedirection),
|
PaypalRedirect(PaypalRedirection),
|
||||||
|
/// The wallet data for Paypal
|
||||||
|
PaypalSdk(PayPalWalletData),
|
||||||
|
/// The wallet data for WeChat Pay Redirection
|
||||||
|
WeChatPayRedirect(Box<WeChatPayRedirection>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||||
@ -588,9 +636,24 @@ pub struct GooglePayWalletData {
|
|||||||
pub tokenization_data: GpayTokenizationData,
|
pub tokenization_data: GpayTokenizationData,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||||
|
pub struct WeChatPayRedirection {}
|
||||||
|
|
||||||
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||||
pub struct PaypalRedirection {}
|
pub struct PaypalRedirection {}
|
||||||
|
|
||||||
|
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||||
|
pub struct AliPayRedirection {}
|
||||||
|
|
||||||
|
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||||
|
pub struct MobilePayRedirection {}
|
||||||
|
|
||||||
|
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||||
|
pub struct MbWayRedirection {
|
||||||
|
/// Telephone number of the shopper. Should be Portuguese phone number.
|
||||||
|
pub telephone_number: Secret<String>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||||
pub struct GooglePayPaymentMethodInfo {
|
pub struct GooglePayPaymentMethodInfo {
|
||||||
/// The name of the card network
|
/// The name of the card network
|
||||||
|
|||||||
@ -191,6 +191,8 @@ impl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Payment Sync can be useful only incase of Redirect flow.
|
||||||
|
/// For payments which doesn't involve redrection we have to rely on webhooks.
|
||||||
impl
|
impl
|
||||||
services::ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsResponseData>
|
services::ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsResponseData>
|
||||||
for Adyen
|
for Adyen
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -19,13 +19,15 @@ use crate::{
|
|||||||
types::{self, api, storage::enums, ErrorResponse},
|
types::{self, api, storage::enums, ErrorResponse},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type Error = error_stack::Report<errors::ConnectorError>;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct GlobalPayMeta {
|
pub struct GlobalPayMeta {
|
||||||
account_name: String,
|
account_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<&types::PaymentsAuthorizeRouterData> for GlobalpayPaymentsRequest {
|
impl TryFrom<&types::PaymentsAuthorizeRouterData> for GlobalpayPaymentsRequest {
|
||||||
type Error = error_stack::Report<errors::ConnectorError>;
|
type Error = Error;
|
||||||
fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result<Self, Self::Error> {
|
fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result<Self, Self::Error> {
|
||||||
let metadata: GlobalPayMeta =
|
let metadata: GlobalPayMeta =
|
||||||
utils::to_connector_meta_from_secret(item.connector_meta_data.clone())?;
|
utils::to_connector_meta_from_secret(item.connector_meta_data.clone())?;
|
||||||
@ -84,7 +86,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for GlobalpayPaymentsRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<&types::PaymentsCaptureRouterData> for requests::GlobalpayCaptureRequest {
|
impl TryFrom<&types::PaymentsCaptureRouterData> for requests::GlobalpayCaptureRequest {
|
||||||
type Error = error_stack::Report<errors::ConnectorError>;
|
type Error = Error;
|
||||||
fn try_from(value: &types::PaymentsCaptureRouterData) -> Result<Self, Self::Error> {
|
fn try_from(value: &types::PaymentsCaptureRouterData) -> Result<Self, Self::Error> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
amount: Some(value.request.amount_to_capture.to_string()),
|
amount: Some(value.request.amount_to_capture.to_string()),
|
||||||
@ -93,7 +95,7 @@ impl TryFrom<&types::PaymentsCaptureRouterData> for requests::GlobalpayCaptureRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<&types::PaymentsCancelRouterData> for requests::GlobalpayCancelRequest {
|
impl TryFrom<&types::PaymentsCancelRouterData> for requests::GlobalpayCancelRequest {
|
||||||
type Error = error_stack::Report<errors::ConnectorError>;
|
type Error = Error;
|
||||||
fn try_from(value: &types::PaymentsCancelRouterData) -> Result<Self, Self::Error> {
|
fn try_from(value: &types::PaymentsCancelRouterData) -> Result<Self, Self::Error> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
amount: value.request.amount.map(|amount| amount.to_string()),
|
amount: value.request.amount.map(|amount| amount.to_string()),
|
||||||
@ -107,7 +109,7 @@ pub struct GlobalpayAuthType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<&types::ConnectorAuthType> for GlobalpayAuthType {
|
impl TryFrom<&types::ConnectorAuthType> for GlobalpayAuthType {
|
||||||
type Error = error_stack::Report<errors::ConnectorError>;
|
type Error = Error;
|
||||||
fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {
|
fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {
|
||||||
match auth_type {
|
match auth_type {
|
||||||
types::ConnectorAuthType::BodyKey { api_key, key1 } => Ok(Self {
|
types::ConnectorAuthType::BodyKey { api_key, key1 } => Ok(Self {
|
||||||
@ -131,7 +133,7 @@ impl TryFrom<GlobalpayRefreshTokenResponse> for types::AccessToken {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<&types::RefreshTokenRouterData> for GlobalpayRefreshTokenRequest {
|
impl TryFrom<&types::RefreshTokenRouterData> for GlobalpayRefreshTokenRequest {
|
||||||
type Error = error_stack::Report<errors::ConnectorError>;
|
type Error = Error;
|
||||||
|
|
||||||
fn try_from(item: &types::RefreshTokenRouterData) -> Result<Self, Self::Error> {
|
fn try_from(item: &types::RefreshTokenRouterData) -> Result<Self, Self::Error> {
|
||||||
let globalpay_auth = GlobalpayAuthType::try_from(&item.connector_auth_type)
|
let globalpay_auth = GlobalpayAuthType::try_from(&item.connector_auth_type)
|
||||||
@ -220,7 +222,7 @@ impl<F, T>
|
|||||||
TryFrom<types::ResponseRouterData<F, GlobalpayPaymentsResponse, T, types::PaymentsResponseData>>
|
TryFrom<types::ResponseRouterData<F, GlobalpayPaymentsResponse, T, types::PaymentsResponseData>>
|
||||||
for types::RouterData<F, T, types::PaymentsResponseData>
|
for types::RouterData<F, T, types::PaymentsResponseData>
|
||||||
{
|
{
|
||||||
type Error = error_stack::Report<errors::ConnectorError>;
|
type Error = Error;
|
||||||
fn try_from(
|
fn try_from(
|
||||||
item: types::ResponseRouterData<
|
item: types::ResponseRouterData<
|
||||||
F,
|
F,
|
||||||
@ -276,7 +278,7 @@ impl<F, T>
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<F> TryFrom<&types::RefundsRouterData<F>> for requests::GlobalpayRefundRequest {
|
impl<F> TryFrom<&types::RefundsRouterData<F>> for requests::GlobalpayRefundRequest {
|
||||||
type Error = error_stack::Report<errors::ConnectorError>;
|
type Error = Error;
|
||||||
fn try_from(item: &types::RefundsRouterData<F>) -> Result<Self, Self::Error> {
|
fn try_from(item: &types::RefundsRouterData<F>) -> Result<Self, Self::Error> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
amount: item.request.refund_amount.to_string(),
|
amount: item.request.refund_amount.to_string(),
|
||||||
@ -287,7 +289,7 @@ impl<F> TryFrom<&types::RefundsRouterData<F>> for requests::GlobalpayRefundReque
|
|||||||
impl TryFrom<types::RefundsResponseRouterData<api::Execute, GlobalpayPaymentsResponse>>
|
impl TryFrom<types::RefundsResponseRouterData<api::Execute, GlobalpayPaymentsResponse>>
|
||||||
for types::RefundExecuteRouterData
|
for types::RefundExecuteRouterData
|
||||||
{
|
{
|
||||||
type Error = error_stack::Report<errors::ConnectorError>;
|
type Error = Error;
|
||||||
fn try_from(
|
fn try_from(
|
||||||
item: types::RefundsResponseRouterData<api::Execute, GlobalpayPaymentsResponse>,
|
item: types::RefundsResponseRouterData<api::Execute, GlobalpayPaymentsResponse>,
|
||||||
) -> Result<Self, Self::Error> {
|
) -> Result<Self, Self::Error> {
|
||||||
@ -304,7 +306,7 @@ impl TryFrom<types::RefundsResponseRouterData<api::Execute, GlobalpayPaymentsRes
|
|||||||
impl TryFrom<types::RefundsResponseRouterData<api::RSync, GlobalpayPaymentsResponse>>
|
impl TryFrom<types::RefundsResponseRouterData<api::RSync, GlobalpayPaymentsResponse>>
|
||||||
for types::RefundsRouterData<api::RSync>
|
for types::RefundsRouterData<api::RSync>
|
||||||
{
|
{
|
||||||
type Error = error_stack::Report<errors::ConnectorError>;
|
type Error = Error;
|
||||||
fn try_from(
|
fn try_from(
|
||||||
item: types::RefundsResponseRouterData<api::RSync, GlobalpayPaymentsResponse>,
|
item: types::RefundsResponseRouterData<api::RSync, GlobalpayPaymentsResponse>,
|
||||||
) -> Result<Self, Self::Error> {
|
) -> Result<Self, Self::Error> {
|
||||||
@ -328,7 +330,7 @@ pub struct GlobalpayErrorResponse {
|
|||||||
fn get_payment_method_data(
|
fn get_payment_method_data(
|
||||||
item: &types::PaymentsAuthorizeRouterData,
|
item: &types::PaymentsAuthorizeRouterData,
|
||||||
brand_reference: Option<String>,
|
brand_reference: Option<String>,
|
||||||
) -> Result<PaymentMethodData, error_stack::Report<errors::ConnectorError>> {
|
) -> Result<PaymentMethodData, Error> {
|
||||||
match &item.request.payment_method_data {
|
match &item.request.payment_method_data {
|
||||||
api::PaymentMethodData::Card(ccard) => Ok(PaymentMethodData::Card(requests::Card {
|
api::PaymentMethodData::Card(ccard) => Ok(PaymentMethodData::Card(requests::Card {
|
||||||
number: ccard.card_number.clone(),
|
number: ccard.card_number.clone(),
|
||||||
@ -348,7 +350,7 @@ fn get_payment_method_data(
|
|||||||
})),
|
})),
|
||||||
api::PaymentMethodData::Wallet(wallet_data) => get_wallet_data(wallet_data),
|
api::PaymentMethodData::Wallet(wallet_data) => get_wallet_data(wallet_data),
|
||||||
api::PaymentMethodData::BankRedirect(bank_redirect) => {
|
api::PaymentMethodData::BankRedirect(bank_redirect) => {
|
||||||
get_bank_redirect_data(bank_redirect)
|
PaymentMethodData::try_from(bank_redirect)
|
||||||
}
|
}
|
||||||
_ => Err(errors::ConnectorError::NotImplemented(
|
_ => Err(errors::ConnectorError::NotImplemented(
|
||||||
"Payment methods".to_string(),
|
"Payment methods".to_string(),
|
||||||
@ -366,9 +368,7 @@ fn get_return_url(item: &types::PaymentsAuthorizeRouterData) -> Option<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type MandateDetails = (Option<Initiator>, Option<StoredCredential>, Option<String>);
|
type MandateDetails = (Option<Initiator>, Option<StoredCredential>, Option<String>);
|
||||||
fn get_mandate_details(
|
fn get_mandate_details(item: &types::PaymentsAuthorizeRouterData) -> Result<MandateDetails, Error> {
|
||||||
item: &types::PaymentsAuthorizeRouterData,
|
|
||||||
) -> Result<MandateDetails, error_stack::Report<errors::ConnectorError>> {
|
|
||||||
Ok(if item.request.is_mandate_payment() {
|
Ok(if item.request.is_mandate_payment() {
|
||||||
let connector_mandate_id = item
|
let connector_mandate_id = item
|
||||||
.request
|
.request
|
||||||
@ -396,7 +396,7 @@ fn get_mandate_details(
|
|||||||
|
|
||||||
fn get_wallet_data(
|
fn get_wallet_data(
|
||||||
wallet_data: &api_models::payments::WalletData,
|
wallet_data: &api_models::payments::WalletData,
|
||||||
) -> Result<PaymentMethodData, error_stack::Report<errors::ConnectorError>> {
|
) -> Result<PaymentMethodData, Error> {
|
||||||
match wallet_data {
|
match wallet_data {
|
||||||
api_models::payments::WalletData::PaypalRedirect(_) => {
|
api_models::payments::WalletData::PaypalRedirect(_) => {
|
||||||
Ok(PaymentMethodData::Apm(requests::Apm {
|
Ok(PaymentMethodData::Apm(requests::Apm {
|
||||||
@ -410,34 +410,33 @@ fn get_wallet_data(
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
_ => Err(errors::ConnectorError::NotImplemented(
|
_ => Err(errors::ConnectorError::NotImplemented(
|
||||||
"Payment methods".to_string(),
|
"Payment method".to_string(),
|
||||||
))?,
|
))?,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_bank_redirect_data(
|
impl TryFrom<&api_models::payments::BankRedirectData> for PaymentMethodData {
|
||||||
bank_redirect: &api_models::payments::BankRedirectData,
|
type Error = Error;
|
||||||
) -> Result<PaymentMethodData, error_stack::Report<errors::ConnectorError>> {
|
fn try_from(value: &api_models::payments::BankRedirectData) -> Result<Self, Self::Error> {
|
||||||
match bank_redirect {
|
match value {
|
||||||
api_models::payments::BankRedirectData::Eps { .. } => {
|
api_models::payments::BankRedirectData::Eps { .. } => Ok(Self::Apm(requests::Apm {
|
||||||
Ok(PaymentMethodData::Apm(requests::Apm {
|
|
||||||
provider: Some(ApmProvider::Eps),
|
provider: Some(ApmProvider::Eps),
|
||||||
}))
|
})),
|
||||||
}
|
|
||||||
api_models::payments::BankRedirectData::Giropay { .. } => {
|
api_models::payments::BankRedirectData::Giropay { .. } => {
|
||||||
Ok(PaymentMethodData::Apm(requests::Apm {
|
Ok(Self::Apm(requests::Apm {
|
||||||
provider: Some(ApmProvider::Giropay),
|
provider: Some(ApmProvider::Giropay),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
api_models::payments::BankRedirectData::Ideal { .. } => {
|
api_models::payments::BankRedirectData::Ideal { .. } => Ok(Self::Apm(requests::Apm {
|
||||||
Ok(PaymentMethodData::Apm(requests::Apm {
|
|
||||||
provider: Some(ApmProvider::Ideal),
|
provider: Some(ApmProvider::Ideal),
|
||||||
}))
|
})),
|
||||||
}
|
api_models::payments::BankRedirectData::Sofort { .. } => Ok(Self::Apm(requests::Apm {
|
||||||
api_models::payments::BankRedirectData::Sofort { .. } => {
|
|
||||||
Ok(PaymentMethodData::Apm(requests::Apm {
|
|
||||||
provider: Some(ApmProvider::Sofort),
|
provider: Some(ApmProvider::Sofort),
|
||||||
}))
|
})),
|
||||||
|
_ => Err(errors::ConnectorError::NotImplemented(
|
||||||
|
"Payment method".to_string(),
|
||||||
|
))
|
||||||
|
.into_report(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,7 +98,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for MolliePaymentsRequest {
|
|||||||
let payment_method_data = match item.request.capture_method.unwrap_or_default() {
|
let payment_method_data = match item.request.capture_method.unwrap_or_default() {
|
||||||
enums::CaptureMethod::Automatic => match item.request.payment_method_data {
|
enums::CaptureMethod::Automatic => match item.request.payment_method_data {
|
||||||
api_models::payments::PaymentMethodData::BankRedirect(ref redirect_data) => {
|
api_models::payments::PaymentMethodData::BankRedirect(ref redirect_data) => {
|
||||||
get_payment_method_for_bank_redirect(item, redirect_data)
|
PaymentMethodData::try_from(redirect_data)
|
||||||
}
|
}
|
||||||
api_models::payments::PaymentMethodData::Wallet(ref wallet_data) => {
|
api_models::payments::PaymentMethodData::Wallet(ref wallet_data) => {
|
||||||
get_payment_method_for_wallet(item, wallet_data)
|
get_payment_method_for_wallet(item, wallet_data)
|
||||||
@ -135,22 +135,22 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for MolliePaymentsRequest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_payment_method_for_bank_redirect(
|
impl TryFrom<&api_models::payments::BankRedirectData> for PaymentMethodData {
|
||||||
_item: &types::PaymentsAuthorizeRouterData,
|
type Error = Error;
|
||||||
redirect_data: &api_models::payments::BankRedirectData,
|
fn try_from(value: &api_models::payments::BankRedirectData) -> Result<Self, Self::Error> {
|
||||||
) -> Result<PaymentMethodData, Error> {
|
match value {
|
||||||
let payment_method_data = match redirect_data {
|
api_models::payments::BankRedirectData::Eps { .. } => Ok(Self::Eps),
|
||||||
api_models::payments::BankRedirectData::Eps { .. } => PaymentMethodData::Eps,
|
api_models::payments::BankRedirectData::Giropay { .. } => Ok(Self::Giropay),
|
||||||
api_models::payments::BankRedirectData::Giropay { .. } => PaymentMethodData::Giropay,
|
|
||||||
api_models::payments::BankRedirectData::Ideal { .. } => {
|
api_models::payments::BankRedirectData::Ideal { .. } => {
|
||||||
PaymentMethodData::Ideal(Box::new(IdealMethodData {
|
Ok(Self::Ideal(Box::new(IdealMethodData {
|
||||||
// To do if possible this should be from the payment request
|
// To do if possible this should be from the payment request
|
||||||
issuer: None,
|
issuer: None,
|
||||||
}))
|
})))
|
||||||
|
}
|
||||||
|
api_models::payments::BankRedirectData::Sofort { .. } => Ok(Self::Sofort),
|
||||||
|
_ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
api_models::payments::BankRedirectData::Sofort { .. } => PaymentMethodData::Sofort,
|
|
||||||
};
|
|
||||||
Ok(payment_method_data)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_payment_method_for_wallet(
|
fn get_payment_method_for_wallet(
|
||||||
|
|||||||
@ -198,7 +198,7 @@ fn get_bank_redirect_request<T>(
|
|||||||
redirect_data: &payments::BankRedirectData,
|
redirect_data: &payments::BankRedirectData,
|
||||||
) -> Result<Shift4PaymentsRequest, Error> {
|
) -> Result<Shift4PaymentsRequest, Error> {
|
||||||
let submit_for_settlement = item.request.is_auto_capture()?;
|
let submit_for_settlement = item.request.is_auto_capture()?;
|
||||||
let method_type = PaymentMethodType::from(redirect_data);
|
let method_type = PaymentMethodType::try_from(redirect_data)?;
|
||||||
let billing = get_billing(item)?;
|
let billing = get_billing(item)?;
|
||||||
let payment_method = Some(PaymentMethod {
|
let payment_method = Some(PaymentMethod {
|
||||||
method_type,
|
method_type,
|
||||||
@ -218,13 +218,15 @@ fn get_bank_redirect_request<T>(
|
|||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&payments::BankRedirectData> for PaymentMethodType {
|
impl TryFrom<&payments::BankRedirectData> for PaymentMethodType {
|
||||||
fn from(value: &payments::BankRedirectData) -> Self {
|
type Error = Error;
|
||||||
|
fn try_from(value: &payments::BankRedirectData) -> Result<Self, Self::Error> {
|
||||||
match value {
|
match value {
|
||||||
payments::BankRedirectData::Eps { .. } => Self::Eps,
|
payments::BankRedirectData::Eps { .. } => Ok(Self::Eps),
|
||||||
payments::BankRedirectData::Giropay { .. } => Self::Giropay,
|
payments::BankRedirectData::Giropay { .. } => Ok(Self::Giropay),
|
||||||
payments::BankRedirectData::Ideal { .. } => Self::Ideal,
|
payments::BankRedirectData::Ideal { .. } => Ok(Self::Ideal),
|
||||||
payments::BankRedirectData::Sofort { .. } => Self::Sofort,
|
payments::BankRedirectData::Sofort { .. } => Ok(Self::Sofort),
|
||||||
|
_ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,8 @@ use crate::{
|
|||||||
types::{self, api, storage::enums, BrowserInformation},
|
types::{self, api, storage::enums, BrowserInformation},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type Error = error_stack::Report<errors::ConnectorError>;
|
||||||
|
|
||||||
pub struct TrustpayAuthType {
|
pub struct TrustpayAuthType {
|
||||||
pub(super) api_key: String,
|
pub(super) api_key: String,
|
||||||
pub(super) project_id: String,
|
pub(super) project_id: String,
|
||||||
@ -25,7 +27,7 @@ pub struct TrustpayAuthType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<&types::ConnectorAuthType> for TrustpayAuthType {
|
impl TryFrom<&types::ConnectorAuthType> for TrustpayAuthType {
|
||||||
type Error = error_stack::Report<errors::ConnectorError>;
|
type Error = Error;
|
||||||
fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {
|
fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {
|
||||||
if let types::ConnectorAuthType::SignatureKey {
|
if let types::ConnectorAuthType::SignatureKey {
|
||||||
api_key,
|
api_key,
|
||||||
@ -181,18 +183,22 @@ pub struct TrustpayMandatoryParams {
|
|||||||
pub billing_postcode: Secret<String>,
|
pub billing_postcode: Secret<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_trustpay_payment_method(bank_redirection_data: &BankRedirectData) -> TrustpayPaymentMethod {
|
impl TryFrom<&BankRedirectData> for TrustpayPaymentMethod {
|
||||||
match bank_redirection_data {
|
type Error = Error;
|
||||||
api_models::payments::BankRedirectData::Giropay { .. } => TrustpayPaymentMethod::Giropay,
|
fn try_from(value: &BankRedirectData) -> Result<Self, Self::Error> {
|
||||||
api_models::payments::BankRedirectData::Eps { .. } => TrustpayPaymentMethod::Eps,
|
match value {
|
||||||
api_models::payments::BankRedirectData::Ideal { .. } => TrustpayPaymentMethod::IDeal,
|
api_models::payments::BankRedirectData::Giropay { .. } => Ok(Self::Giropay),
|
||||||
api_models::payments::BankRedirectData::Sofort { .. } => TrustpayPaymentMethod::Sofort,
|
api_models::payments::BankRedirectData::Eps { .. } => Ok(Self::Eps),
|
||||||
|
api_models::payments::BankRedirectData::Ideal { .. } => Ok(Self::IDeal),
|
||||||
|
api_models::payments::BankRedirectData::Sofort { .. } => Ok(Self::Sofort),
|
||||||
|
_ => Err(errors::ConnectorError::NotImplemented("Payment methods".to_string()).into()),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_mandatory_fields(
|
fn get_mandatory_fields(
|
||||||
item: &types::PaymentsAuthorizeRouterData,
|
item: &types::PaymentsAuthorizeRouterData,
|
||||||
) -> Result<TrustpayMandatoryParams, error_stack::Report<errors::ConnectorError>> {
|
) -> Result<TrustpayMandatoryParams, Error> {
|
||||||
let billing_address = item
|
let billing_address = item
|
||||||
.get_billing()?
|
.get_billing()?
|
||||||
.address
|
.address
|
||||||
@ -248,11 +254,12 @@ fn get_bank_redirection_request_data(
|
|||||||
item: &types::PaymentsAuthorizeRouterData,
|
item: &types::PaymentsAuthorizeRouterData,
|
||||||
bank_redirection_data: &BankRedirectData,
|
bank_redirection_data: &BankRedirectData,
|
||||||
amount: String,
|
amount: String,
|
||||||
return_url: String,
|
|
||||||
auth: TrustpayAuthType,
|
auth: TrustpayAuthType,
|
||||||
) -> TrustpayPaymentsRequest {
|
) -> Result<TrustpayPaymentsRequest, error_stack::Report<errors::ConnectorError>> {
|
||||||
|
let return_url = item.request.get_return_url()?;
|
||||||
|
let payment_request =
|
||||||
TrustpayPaymentsRequest::BankRedirectPaymentRequest(Box::new(PaymentRequestBankRedirect {
|
TrustpayPaymentsRequest::BankRedirectPaymentRequest(Box::new(PaymentRequestBankRedirect {
|
||||||
payment_method: get_trustpay_payment_method(bank_redirection_data),
|
payment_method: TrustpayPaymentMethod::try_from(bank_redirection_data)?,
|
||||||
merchant_identification: MerchantIdentification {
|
merchant_identification: MerchantIdentification {
|
||||||
project_id: auth.project_id,
|
project_id: auth.project_id,
|
||||||
},
|
},
|
||||||
@ -270,11 +277,12 @@ fn get_bank_redirection_request_data(
|
|||||||
cancel: return_url.clone(),
|
cancel: return_url.clone(),
|
||||||
error: return_url,
|
error: return_url,
|
||||||
},
|
},
|
||||||
}))
|
}));
|
||||||
|
Ok(payment_request)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<&types::PaymentsAuthorizeRouterData> for TrustpayPaymentsRequest {
|
impl TryFrom<&types::PaymentsAuthorizeRouterData> for TrustpayPaymentsRequest {
|
||||||
type Error = error_stack::Report<errors::ConnectorError>;
|
type Error = Error;
|
||||||
fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result<Self, Self::Error> {
|
fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result<Self, Self::Error> {
|
||||||
let default_browser_info = BrowserInformation {
|
let default_browser_info = BrowserInformation {
|
||||||
color_depth: 24,
|
color_depth: 24,
|
||||||
@ -303,7 +311,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for TrustpayPaymentsRequest {
|
|||||||
);
|
);
|
||||||
let auth = TrustpayAuthType::try_from(&item.connector_auth_type)
|
let auth = TrustpayAuthType::try_from(&item.connector_auth_type)
|
||||||
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
|
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
|
||||||
Ok(match item.request.payment_method_data {
|
match item.request.payment_method_data {
|
||||||
api::PaymentMethodData::Card(ref ccard) => Ok(get_card_request_data(
|
api::PaymentMethodData::Card(ref ccard) => Ok(get_card_request_data(
|
||||||
item,
|
item,
|
||||||
browser_info,
|
browser_info,
|
||||||
@ -313,19 +321,10 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for TrustpayPaymentsRequest {
|
|||||||
item.request.get_return_url()?,
|
item.request.get_return_url()?,
|
||||||
)),
|
)),
|
||||||
api::PaymentMethodData::BankRedirect(ref bank_redirection_data) => {
|
api::PaymentMethodData::BankRedirect(ref bank_redirection_data) => {
|
||||||
Ok(get_bank_redirection_request_data(
|
get_bank_redirection_request_data(item, bank_redirection_data, amount, auth)
|
||||||
item,
|
}
|
||||||
bank_redirection_data,
|
_ => Err(errors::ConnectorError::NotImplemented("Payment methods".to_string()).into()),
|
||||||
amount,
|
|
||||||
item.request.get_return_url()?,
|
|
||||||
auth,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
_ => Err(errors::ConnectorError::NotImplemented(format!(
|
|
||||||
"Current Payment Method - {:?}",
|
|
||||||
item.request.payment_method_data
|
|
||||||
))),
|
|
||||||
}?)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,7 +523,7 @@ impl<F, T>
|
|||||||
TryFrom<types::ResponseRouterData<F, TrustpayPaymentsResponse, T, types::PaymentsResponseData>>
|
TryFrom<types::ResponseRouterData<F, TrustpayPaymentsResponse, T, types::PaymentsResponseData>>
|
||||||
for types::RouterData<F, T, types::PaymentsResponseData>
|
for types::RouterData<F, T, types::PaymentsResponseData>
|
||||||
{
|
{
|
||||||
type Error = error_stack::Report<errors::ConnectorError>;
|
type Error = Error;
|
||||||
fn try_from(
|
fn try_from(
|
||||||
item: types::ResponseRouterData<
|
item: types::ResponseRouterData<
|
||||||
F,
|
F,
|
||||||
@ -733,7 +732,7 @@ pub struct TrustpayAuthUpdateRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<&types::RefreshTokenRouterData> for TrustpayAuthUpdateRequest {
|
impl TryFrom<&types::RefreshTokenRouterData> for TrustpayAuthUpdateRequest {
|
||||||
type Error = error_stack::Report<errors::ConnectorError>;
|
type Error = Error;
|
||||||
fn try_from(_item: &types::RefreshTokenRouterData) -> Result<Self, Self::Error> {
|
fn try_from(_item: &types::RefreshTokenRouterData) -> Result<Self, Self::Error> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
grant_type: "client_credentials".to_string(),
|
grant_type: "client_credentials".to_string(),
|
||||||
@ -767,7 +766,7 @@ pub struct TrustpayAccessTokenErrorResponse {
|
|||||||
impl<F, T> TryFrom<types::ResponseRouterData<F, TrustpayAuthUpdateResponse, T, types::AccessToken>>
|
impl<F, T> TryFrom<types::ResponseRouterData<F, TrustpayAuthUpdateResponse, T, types::AccessToken>>
|
||||||
for types::RouterData<F, T, types::AccessToken>
|
for types::RouterData<F, T, types::AccessToken>
|
||||||
{
|
{
|
||||||
type Error = error_stack::Report<errors::ConnectorError>;
|
type Error = Error;
|
||||||
fn try_from(
|
fn try_from(
|
||||||
item: types::ResponseRouterData<F, TrustpayAuthUpdateResponse, T, types::AccessToken>,
|
item: types::ResponseRouterData<F, TrustpayAuthUpdateResponse, T, types::AccessToken>,
|
||||||
) -> Result<Self, Self::Error> {
|
) -> Result<Self, Self::Error> {
|
||||||
@ -820,7 +819,7 @@ pub enum TrustpayRefundRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<F> TryFrom<&types::RefundsRouterData<F>> for TrustpayRefundRequest {
|
impl<F> TryFrom<&types::RefundsRouterData<F>> for TrustpayRefundRequest {
|
||||||
type Error = error_stack::Report<errors::ConnectorError>;
|
type Error = Error;
|
||||||
fn try_from(item: &types::RefundsRouterData<F>) -> Result<Self, Self::Error> {
|
fn try_from(item: &types::RefundsRouterData<F>) -> Result<Self, Self::Error> {
|
||||||
let amount = format!(
|
let amount = format!(
|
||||||
"{:.2}",
|
"{:.2}",
|
||||||
@ -1000,7 +999,7 @@ fn handle_bank_redirects_refund_sync_error_response(
|
|||||||
impl<F> TryFrom<types::RefundsResponseRouterData<F, RefundResponse>>
|
impl<F> TryFrom<types::RefundsResponseRouterData<F, RefundResponse>>
|
||||||
for types::RefundsRouterData<F>
|
for types::RefundsRouterData<F>
|
||||||
{
|
{
|
||||||
type Error = error_stack::Report<errors::ConnectorError>;
|
type Error = Error;
|
||||||
fn try_from(
|
fn try_from(
|
||||||
item: types::RefundsResponseRouterData<F, RefundResponse>,
|
item: types::RefundsResponseRouterData<F, RefundResponse>,
|
||||||
) -> Result<Self, Self::Error> {
|
) -> Result<Self, Self::Error> {
|
||||||
|
|||||||
@ -612,19 +612,34 @@ pub enum MandateStatus {
|
|||||||
#[strum(serialize_all = "snake_case")]
|
#[strum(serialize_all = "snake_case")]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum PaymentMethodType {
|
pub enum PaymentMethodType {
|
||||||
Credit,
|
|
||||||
Debit,
|
|
||||||
Giropay,
|
|
||||||
Ideal,
|
|
||||||
Sofort,
|
|
||||||
Eps,
|
|
||||||
Klarna,
|
|
||||||
Affirm,
|
Affirm,
|
||||||
AfterpayClearpay,
|
AfterpayClearpay,
|
||||||
GooglePay,
|
AliPay,
|
||||||
ApplePay,
|
ApplePay,
|
||||||
Paypal,
|
BancontactCard,
|
||||||
|
Blik,
|
||||||
|
Credit,
|
||||||
CryptoCurrency,
|
CryptoCurrency,
|
||||||
|
Debit,
|
||||||
|
Eps,
|
||||||
|
Giropay,
|
||||||
|
GooglePay,
|
||||||
|
Ideal,
|
||||||
|
Klarna,
|
||||||
|
MbWay,
|
||||||
|
MobilePay,
|
||||||
|
OnlineBankingCzechRepublic,
|
||||||
|
OnlineBankingFinland,
|
||||||
|
OnlineBankingPoland,
|
||||||
|
OnlineBankingSlovakia,
|
||||||
|
PayBright,
|
||||||
|
Paypal,
|
||||||
|
Przelewy24,
|
||||||
|
Sofort,
|
||||||
|
Swish,
|
||||||
|
Trustly,
|
||||||
|
Walley,
|
||||||
|
WeChatPay,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
|
|||||||
Reference in New Issue
Block a user