refactor(payment_methods): add some payment method data to new domain type to be used in connector module (#4234)

Co-authored-by: Narayan Bhat <narayan.bhat@juspay.in>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Swangi Kumari
2024-04-10 14:52:19 +05:30
committed by GitHub
parent a2958c33b5
commit ce1e165cec
11 changed files with 341 additions and 163 deletions

View File

@ -734,9 +734,9 @@ pub enum OnlineBankingCzechRepublicBanks {
C,
}
impl TryFrom<&Box<payments::JCSVoucherData>> for JCSVoucherData {
impl TryFrom<&Box<domain::JCSVoucherData>> for JCSVoucherData {
type Error = Error;
fn try_from(jcs_data: &Box<payments::JCSVoucherData>) -> Result<Self, Self::Error> {
fn try_from(jcs_data: &Box<domain::JCSVoucherData>) -> Result<Self, Self::Error> {
Ok(Self {
first_name: jcs_data.first_name.clone(),
last_name: jcs_data.last_name.clone(),
@ -1593,7 +1593,7 @@ impl<'a> TryFrom<&types::PaymentsPreProcessingRouterData> for AdyenBalanceReques
let payment_method = match &item.request.payment_method_data {
Some(domain::PaymentMethodData::GiftCard(gift_card_data)) => {
match gift_card_data.as_ref() {
payments::GiftCardData::Givex(gift_card_data) => {
domain::GiftCardData::Givex(gift_card_data) => {
let balance_pm = BalancePmData {
payment_type: GiftCardBrand::Givex,
number: gift_card_data.number.clone(),
@ -1603,7 +1603,7 @@ impl<'a> TryFrom<&types::PaymentsPreProcessingRouterData> for AdyenBalanceReques
balance_pm,
)))
}
payments::GiftCardData::PaySafeCard {} => {
domain::GiftCardData::PaySafeCard {} => {
Err(errors::ConnectorError::FlowNotSupported {
flow: "Balance".to_string(),
connector: "adyen".to_string(),
@ -1797,24 +1797,22 @@ fn get_country_code(
address.and_then(|billing| billing.address.as_ref().and_then(|address| address.country))
}
fn get_social_security_number(
voucher_data: &api_models::payments::VoucherData,
) -> Option<Secret<String>> {
fn get_social_security_number(voucher_data: &domain::VoucherData) -> Option<Secret<String>> {
match voucher_data {
payments::VoucherData::Boleto(boleto_data) => boleto_data.social_security_number.clone(),
payments::VoucherData::Alfamart { .. }
| payments::VoucherData::Indomaret { .. }
| payments::VoucherData::Efecty
| payments::VoucherData::PagoEfectivo
| payments::VoucherData::RedCompra
| payments::VoucherData::Oxxo
| payments::VoucherData::RedPagos
| payments::VoucherData::SevenEleven { .. }
| payments::VoucherData::Lawson { .. }
| payments::VoucherData::MiniStop { .. }
| payments::VoucherData::FamilyMart { .. }
| payments::VoucherData::Seicomart { .. }
| payments::VoucherData::PayEasy { .. } => None,
domain::VoucherData::Boleto(boleto_data) => boleto_data.social_security_number.clone(),
domain::VoucherData::Alfamart { .. }
| domain::VoucherData::Indomaret { .. }
| domain::VoucherData::Efecty
| domain::VoucherData::PagoEfectivo
| domain::VoucherData::RedCompra
| domain::VoucherData::Oxxo
| domain::VoucherData::RedPagos
| domain::VoucherData::SevenEleven { .. }
| domain::VoucherData::Lawson { .. }
| domain::VoucherData::MiniStop { .. }
| domain::VoucherData::FamilyMart { .. }
| domain::VoucherData::Seicomart { .. }
| domain::VoucherData::PayEasy { .. } => None,
}
}
@ -1888,48 +1886,48 @@ impl<'a> TryFrom<&api_models::payments::BankDebitData> for AdyenPaymentMethod<'a
}
}
impl<'a> TryFrom<&api_models::payments::VoucherData> for AdyenPaymentMethod<'a> {
impl<'a> TryFrom<&domain::VoucherData> for AdyenPaymentMethod<'a> {
type Error = Error;
fn try_from(voucher_data: &api_models::payments::VoucherData) -> Result<Self, Self::Error> {
fn try_from(voucher_data: &domain::VoucherData) -> Result<Self, Self::Error> {
match voucher_data {
payments::VoucherData::Boleto { .. } => Ok(AdyenPaymentMethod::BoletoBancario),
payments::VoucherData::Alfamart(alfarmart_data) => {
domain::VoucherData::Boleto { .. } => Ok(AdyenPaymentMethod::BoletoBancario),
domain::VoucherData::Alfamart(alfarmart_data) => {
Ok(AdyenPaymentMethod::Alfamart(Box::new(DokuBankData {
first_name: alfarmart_data.first_name.clone(),
last_name: alfarmart_data.last_name.clone(),
shopper_email: alfarmart_data.email.clone(),
})))
}
payments::VoucherData::Indomaret(indomaret_data) => {
domain::VoucherData::Indomaret(indomaret_data) => {
Ok(AdyenPaymentMethod::Indomaret(Box::new(DokuBankData {
first_name: indomaret_data.first_name.clone(),
last_name: indomaret_data.last_name.clone(),
shopper_email: indomaret_data.email.clone(),
})))
}
payments::VoucherData::Oxxo => Ok(AdyenPaymentMethod::Oxxo),
payments::VoucherData::SevenEleven(jcs_data) => Ok(AdyenPaymentMethod::SevenEleven(
domain::VoucherData::Oxxo => Ok(AdyenPaymentMethod::Oxxo),
domain::VoucherData::SevenEleven(jcs_data) => Ok(AdyenPaymentMethod::SevenEleven(
Box::new(JCSVoucherData::try_from(jcs_data)?),
)),
payments::VoucherData::Lawson(jcs_data) => Ok(AdyenPaymentMethod::Lawson(Box::new(
domain::VoucherData::Lawson(jcs_data) => Ok(AdyenPaymentMethod::Lawson(Box::new(
JCSVoucherData::try_from(jcs_data)?,
))),
payments::VoucherData::MiniStop(jcs_data) => Ok(AdyenPaymentMethod::MiniStop(
Box::new(JCSVoucherData::try_from(jcs_data)?),
)),
payments::VoucherData::FamilyMart(jcs_data) => Ok(AdyenPaymentMethod::FamilyMart(
Box::new(JCSVoucherData::try_from(jcs_data)?),
)),
payments::VoucherData::Seicomart(jcs_data) => Ok(AdyenPaymentMethod::Seicomart(
Box::new(JCSVoucherData::try_from(jcs_data)?),
)),
payments::VoucherData::PayEasy(jcs_data) => Ok(AdyenPaymentMethod::PayEasy(Box::new(
domain::VoucherData::MiniStop(jcs_data) => Ok(AdyenPaymentMethod::MiniStop(Box::new(
JCSVoucherData::try_from(jcs_data)?,
))),
payments::VoucherData::Efecty
| payments::VoucherData::PagoEfectivo
| payments::VoucherData::RedCompra
| payments::VoucherData::RedPagos => Err(errors::ConnectorError::NotImplemented(
domain::VoucherData::FamilyMart(jcs_data) => Ok(AdyenPaymentMethod::FamilyMart(
Box::new(JCSVoucherData::try_from(jcs_data)?),
)),
domain::VoucherData::Seicomart(jcs_data) => Ok(AdyenPaymentMethod::Seicomart(
Box::new(JCSVoucherData::try_from(jcs_data)?),
)),
domain::VoucherData::PayEasy(jcs_data) => Ok(AdyenPaymentMethod::PayEasy(Box::new(
JCSVoucherData::try_from(jcs_data)?,
))),
domain::VoucherData::Efecty
| domain::VoucherData::PagoEfectivo
| domain::VoucherData::RedCompra
| domain::VoucherData::RedPagos => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("Adyen"),
)
.into()),
@ -1937,12 +1935,12 @@ impl<'a> TryFrom<&api_models::payments::VoucherData> for AdyenPaymentMethod<'a>
}
}
impl<'a> TryFrom<&api_models::payments::GiftCardData> for AdyenPaymentMethod<'a> {
impl<'a> TryFrom<&domain::GiftCardData> for AdyenPaymentMethod<'a> {
type Error = Error;
fn try_from(gift_card_data: &api_models::payments::GiftCardData) -> Result<Self, Self::Error> {
fn try_from(gift_card_data: &domain::GiftCardData) -> Result<Self, Self::Error> {
match gift_card_data {
payments::GiftCardData::PaySafeCard {} => Ok(AdyenPaymentMethod::PaySafeCard),
payments::GiftCardData::Givex(givex_data) => {
domain::GiftCardData::PaySafeCard {} => Ok(AdyenPaymentMethod::PaySafeCard),
domain::GiftCardData::Givex(givex_data) => {
let gift_card_pm = GiftCardData {
payment_type: PaymentType::Giftcard,
brand: GiftCardBrand::Givex,
@ -2741,7 +2739,7 @@ impl<'a>
impl<'a>
TryFrom<(
&AdyenRouterData<&types::PaymentsAuthorizeRouterData>,
&api_models::payments::VoucherData,
&domain::VoucherData,
)> for AdyenPaymentRequest<'a>
{
type Error = Error;
@ -2749,7 +2747,7 @@ impl<'a>
fn try_from(
value: (
&AdyenRouterData<&types::PaymentsAuthorizeRouterData>,
&api_models::payments::VoucherData,
&domain::VoucherData,
),
) -> Result<Self, Self::Error> {
let (item, voucher_data) = value;
@ -2845,7 +2843,7 @@ impl<'a>
impl<'a>
TryFrom<(
&AdyenRouterData<&types::PaymentsAuthorizeRouterData>,
&api_models::payments::GiftCardData,
&domain::GiftCardData,
)> for AdyenPaymentRequest<'a>
{
type Error = Error;
@ -2853,7 +2851,7 @@ impl<'a>
fn try_from(
value: (
&AdyenRouterData<&types::PaymentsAuthorizeRouterData>,
&api_models::payments::GiftCardData,
&domain::GiftCardData,
),
) -> Result<Self, Self::Error> {
let (item, gift_card_data) = value;

View File

@ -701,39 +701,36 @@ impl TryFrom<&api_models::payments::BankTransferData> for PaypalPaymentsRequest
}
}
impl TryFrom<&api_models::payments::VoucherData> for PaypalPaymentsRequest {
impl TryFrom<&domain::VoucherData> for PaypalPaymentsRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(value: &api_models::payments::VoucherData) -> Result<Self, Self::Error> {
fn try_from(value: &domain::VoucherData) -> Result<Self, Self::Error> {
match value {
api_models::payments::VoucherData::Boleto(_)
| api_models::payments::VoucherData::Efecty
| api_models::payments::VoucherData::PagoEfectivo
| api_models::payments::VoucherData::RedCompra
| api_models::payments::VoucherData::RedPagos
| api_models::payments::VoucherData::Alfamart(_)
| api_models::payments::VoucherData::Indomaret(_)
| api_models::payments::VoucherData::Oxxo
| api_models::payments::VoucherData::SevenEleven(_)
| api_models::payments::VoucherData::Lawson(_)
| api_models::payments::VoucherData::MiniStop(_)
| api_models::payments::VoucherData::FamilyMart(_)
| api_models::payments::VoucherData::Seicomart(_)
| api_models::payments::VoucherData::PayEasy(_) => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("Paypal"),
)
.into())
}
domain::VoucherData::Boleto(_)
| domain::VoucherData::Efecty
| domain::VoucherData::PagoEfectivo
| domain::VoucherData::RedCompra
| domain::VoucherData::RedPagos
| domain::VoucherData::Alfamart(_)
| domain::VoucherData::Indomaret(_)
| domain::VoucherData::Oxxo
| domain::VoucherData::SevenEleven(_)
| domain::VoucherData::Lawson(_)
| domain::VoucherData::MiniStop(_)
| domain::VoucherData::FamilyMart(_)
| domain::VoucherData::Seicomart(_)
| domain::VoucherData::PayEasy(_) => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("Paypal"),
)
.into()),
}
}
}
impl TryFrom<&api_models::payments::GiftCardData> for PaypalPaymentsRequest {
impl TryFrom<&domain::GiftCardData> for PaypalPaymentsRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(value: &api_models::payments::GiftCardData) -> Result<Self, Self::Error> {
fn try_from(value: &domain::GiftCardData) -> Result<Self, Self::Error> {
match value {
api_models::payments::GiftCardData::Givex(_)
| api_models::payments::GiftCardData::PaySafeCard {} => {
domain::GiftCardData::Givex(_) | domain::GiftCardData::PaySafeCard {} => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("Paypal"),
)

View File

@ -243,24 +243,24 @@ impl TryFrom<&api_models::payments::BankTransferData> for Shift4PaymentMethod {
}
}
impl TryFrom<&api_models::payments::VoucherData> for Shift4PaymentMethod {
impl TryFrom<&domain::VoucherData> for Shift4PaymentMethod {
type Error = Error;
fn try_from(voucher_data: &api_models::payments::VoucherData) -> Result<Self, Self::Error> {
fn try_from(voucher_data: &domain::VoucherData) -> Result<Self, Self::Error> {
match voucher_data {
payments::VoucherData::Boleto(_)
| payments::VoucherData::Efecty
| payments::VoucherData::PagoEfectivo
| payments::VoucherData::RedCompra
| payments::VoucherData::RedPagos
| payments::VoucherData::Alfamart(_)
| payments::VoucherData::Indomaret(_)
| payments::VoucherData::Oxxo
| payments::VoucherData::SevenEleven(_)
| payments::VoucherData::Lawson(_)
| payments::VoucherData::MiniStop(_)
| payments::VoucherData::FamilyMart(_)
| payments::VoucherData::Seicomart(_)
| payments::VoucherData::PayEasy(_) => Err(errors::ConnectorError::NotImplemented(
domain::VoucherData::Boleto(_)
| domain::VoucherData::Efecty
| domain::VoucherData::PagoEfectivo
| domain::VoucherData::RedCompra
| domain::VoucherData::RedPagos
| domain::VoucherData::Alfamart(_)
| domain::VoucherData::Indomaret(_)
| domain::VoucherData::Oxxo
| domain::VoucherData::SevenEleven(_)
| domain::VoucherData::Lawson(_)
| domain::VoucherData::MiniStop(_)
| domain::VoucherData::FamilyMart(_)
| domain::VoucherData::Seicomart(_)
| domain::VoucherData::PayEasy(_) => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("Shift4"),
)
.into()),
@ -268,11 +268,11 @@ impl TryFrom<&api_models::payments::VoucherData> for Shift4PaymentMethod {
}
}
impl TryFrom<&api_models::payments::GiftCardData> for Shift4PaymentMethod {
impl TryFrom<&domain::GiftCardData> for Shift4PaymentMethod {
type Error = Error;
fn try_from(gift_card_data: &api_models::payments::GiftCardData) -> Result<Self, Self::Error> {
fn try_from(gift_card_data: &domain::GiftCardData) -> Result<Self, Self::Error> {
match gift_card_data {
payments::GiftCardData::Givex(_) | payments::GiftCardData::PaySafeCard {} => {
domain::GiftCardData::Givex(_) | domain::GiftCardData::PaySafeCard {} => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("Shift4"),
)

View File

@ -1435,7 +1435,7 @@ fn create_stripe_payment_method(
.into()),
domain::PaymentMethodData::GiftCard(giftcard_data) => match giftcard_data.deref() {
payments::GiftCardData::Givex(_) | payments::GiftCardData::PaySafeCard {} => {
domain::GiftCardData::Givex(_) | domain::GiftCardData::PaySafeCard {} => {
Err(errors::ConnectorError::NotImplemented(
connector_util::get_unimplemented_payment_method_error_message("stripe"),
)
@ -1459,24 +1459,24 @@ fn create_stripe_payment_method(
.into()),
domain::PaymentMethodData::Voucher(voucher_data) => match voucher_data {
payments::VoucherData::Boleto(_) | payments::VoucherData::Oxxo => {
domain::VoucherData::Boleto(_) | domain::VoucherData::Oxxo => {
Err(errors::ConnectorError::NotImplemented(
connector_util::get_unimplemented_payment_method_error_message("stripe"),
)
.into())
}
payments::VoucherData::Alfamart(_)
| payments::VoucherData::Efecty
| payments::VoucherData::PagoEfectivo
| payments::VoucherData::RedCompra
| payments::VoucherData::RedPagos
| payments::VoucherData::Indomaret(_)
| payments::VoucherData::SevenEleven(_)
| payments::VoucherData::Lawson(_)
| payments::VoucherData::MiniStop(_)
| payments::VoucherData::FamilyMart(_)
| payments::VoucherData::Seicomart(_)
| payments::VoucherData::PayEasy(_) => Err(errors::ConnectorError::NotImplemented(
domain::VoucherData::Alfamart(_)
| domain::VoucherData::Efecty
| domain::VoucherData::PagoEfectivo
| domain::VoucherData::RedCompra
| domain::VoucherData::RedPagos
| domain::VoucherData::Indomaret(_)
| domain::VoucherData::SevenEleven(_)
| domain::VoucherData::Lawson(_)
| domain::VoucherData::MiniStop(_)
| domain::VoucherData::FamilyMart(_)
| domain::VoucherData::Seicomart(_)
| domain::VoucherData::PayEasy(_) => Err(errors::ConnectorError::NotImplemented(
connector_util::get_unimplemented_payment_method_error_message("stripe"),
)
.into()),

View File

@ -1115,7 +1115,7 @@ pub trait CryptoData {
fn get_pay_currency(&self) -> Result<String, Error>;
}
impl CryptoData for api::CryptoData {
impl CryptoData for domain::CryptoData {
fn get_pay_currency(&self) -> Result<String, Error> {
self.pay_currency
.clone()

View File

@ -257,14 +257,14 @@ impl
impl
TryFrom<(
&ZenRouterData<&types::PaymentsAuthorizeRouterData>,
&api_models::payments::VoucherData,
&domain::VoucherData,
)> for ZenPaymentsRequest
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
value: (
&ZenRouterData<&types::PaymentsAuthorizeRouterData>,
&api_models::payments::VoucherData,
&domain::VoucherData,
),
) -> Result<Self, Self::Error> {
let (item, voucher_data) = value;
@ -278,30 +278,22 @@ impl
return_url: item.router_data.request.get_router_return_url()?,
});
let payment_channel = match voucher_data {
api_models::payments::VoucherData::Boleto { .. } => {
ZenPaymentChannels::PclBoacompraBoleto
}
api_models::payments::VoucherData::Efecty => ZenPaymentChannels::PclBoacompraEfecty,
api_models::payments::VoucherData::PagoEfectivo => {
ZenPaymentChannels::PclBoacompraPagoefectivo
}
api_models::payments::VoucherData::RedCompra => {
ZenPaymentChannels::PclBoacompraRedcompra
}
api_models::payments::VoucherData::RedPagos => ZenPaymentChannels::PclBoacompraRedpagos,
api_models::payments::VoucherData::Oxxo { .. }
| api_models::payments::VoucherData::Alfamart { .. }
| api_models::payments::VoucherData::Indomaret { .. }
| api_models::payments::VoucherData::SevenEleven { .. }
| api_models::payments::VoucherData::Lawson { .. }
| api_models::payments::VoucherData::MiniStop { .. }
| api_models::payments::VoucherData::FamilyMart { .. }
| api_models::payments::VoucherData::Seicomart { .. }
| api_models::payments::VoucherData::PayEasy { .. } => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("Zen"),
))?
}
domain::VoucherData::Boleto { .. } => ZenPaymentChannels::PclBoacompraBoleto,
domain::VoucherData::Efecty => ZenPaymentChannels::PclBoacompraEfecty,
domain::VoucherData::PagoEfectivo => ZenPaymentChannels::PclBoacompraPagoefectivo,
domain::VoucherData::RedCompra => ZenPaymentChannels::PclBoacompraRedcompra,
domain::VoucherData::RedPagos => ZenPaymentChannels::PclBoacompraRedpagos,
domain::VoucherData::Oxxo { .. }
| domain::VoucherData::Alfamart { .. }
| domain::VoucherData::Indomaret { .. }
| domain::VoucherData::SevenEleven { .. }
| domain::VoucherData::Lawson { .. }
| domain::VoucherData::MiniStop { .. }
| domain::VoucherData::FamilyMart { .. }
| domain::VoucherData::Seicomart { .. }
| domain::VoucherData::PayEasy { .. } => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("Zen"),
))?,
};
Ok(Self::ApiRequest(Box::new(ApiRequest {
merchant_transaction_id: item.router_data.connector_request_reference_id.clone(),
@ -810,12 +802,11 @@ impl TryFrom<&domain::payments::CardRedirectData> for ZenPaymentsRequest {
}
}
impl TryFrom<&api_models::payments::GiftCardData> for ZenPaymentsRequest {
impl TryFrom<&domain::GiftCardData> for ZenPaymentsRequest {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(value: &api_models::payments::GiftCardData) -> Result<Self, Self::Error> {
fn try_from(value: &domain::GiftCardData) -> Result<Self, Self::Error> {
match value {
api_models::payments::GiftCardData::PaySafeCard {}
| api_models::payments::GiftCardData::Givex(_) => {
domain::GiftCardData::PaySafeCard {} | domain::GiftCardData::Givex(_) => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("Zen"),
)

View File

@ -1,4 +1,4 @@
use common_utils::pii::Email;
use common_utils::pii::{self, Email};
use masking::Secret;
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
@ -14,13 +14,13 @@ pub enum PaymentMethodData {
BankRedirect(BankRedirectData),
BankDebit(api_models::payments::BankDebitData),
BankTransfer(Box<api_models::payments::BankTransferData>),
Crypto(api_models::payments::CryptoData),
Crypto(CryptoData),
MandatePayment,
Reward,
Upi(api_models::payments::UpiData),
Voucher(api_models::payments::VoucherData),
GiftCard(Box<api_models::payments::GiftCardData>),
CardToken(api_models::payments::CardToken),
Upi(UpiData),
Voucher(VoucherData),
GiftCard(Box<GiftCardData>),
CardToken(CardToken),
}
impl PaymentMethodData {
@ -318,6 +318,117 @@ pub struct BankRedirectBilling {
pub email: Option<Email>,
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
#[serde(rename_all = "snake_case")]
pub struct CryptoData {
pub pay_currency: Option<String>,
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
#[serde(rename_all = "snake_case")]
pub struct UpiData {
#[schema(value_type = Option<String>, example = "successtest@iata")]
pub vpa_id: Option<Secret<String, pii::UpiVpaMaskingStrategy>>,
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
#[serde(rename_all = "snake_case")]
pub enum VoucherData {
Boleto(Box<BoletoVoucherData>),
Efecty,
PagoEfectivo,
RedCompra,
RedPagos,
Alfamart(Box<AlfamartVoucherData>),
Indomaret(Box<IndomaretVoucherData>),
Oxxo,
SevenEleven(Box<JCSVoucherData>),
Lawson(Box<JCSVoucherData>),
MiniStop(Box<JCSVoucherData>),
FamilyMart(Box<JCSVoucherData>),
Seicomart(Box<JCSVoucherData>),
PayEasy(Box<JCSVoucherData>),
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
pub struct BoletoVoucherData {
/// The shopper's social security number
#[schema(value_type = Option<String>)]
pub social_security_number: Option<Secret<String>>,
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
pub struct AlfamartVoucherData {
/// The billing first name for Alfamart
#[schema(value_type = String, example = "Jane")]
pub first_name: Secret<String>,
/// The billing second name for Alfamart
#[schema(value_type = String, example = "Doe")]
pub last_name: Option<Secret<String>>,
/// The Email ID for Alfamart
#[schema(value_type = String, example = "example@me.com")]
pub email: Email,
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
pub struct IndomaretVoucherData {
/// The billing first name for Alfamart
#[schema(value_type = String, example = "Jane")]
pub first_name: Secret<String>,
/// The billing second name for Alfamart
#[schema(value_type = String, example = "Doe")]
pub last_name: Option<Secret<String>>,
/// The Email ID for Alfamart
#[schema(value_type = String, example = "example@me.com")]
pub email: Email,
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
pub struct JCSVoucherData {
/// The billing first name for Japanese convenience stores
#[schema(value_type = String, example = "Jane")]
pub first_name: Secret<String>,
/// The billing second name Japanese convenience stores
#[schema(value_type = String, example = "Doe")]
pub last_name: Option<Secret<String>>,
/// The Email ID for Japanese convenience stores
#[schema(value_type = String, example = "example@me.com")]
pub email: Email,
/// The telephone number for Japanese convenience stores
#[schema(value_type = String, example = "9999999999")]
pub phone_number: String,
}
#[derive(serde::Deserialize, serde::Serialize, Debug, Clone, ToSchema, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum GiftCardData {
Givex(GiftCardDetails),
PaySafeCard {},
}
#[derive(serde::Deserialize, serde::Serialize, Debug, Clone, ToSchema, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub struct GiftCardDetails {
/// The gift card number
#[schema(value_type = String)]
pub number: Secret<String>,
/// The card verification code.
#[schema(value_type = String)]
pub cvc: Secret<String>,
}
#[derive(Eq, PartialEq, Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema, Default)]
#[serde(rename_all = "snake_case")]
pub struct CardToken {
/// The card holder's name
#[schema(value_type = String, example = "John Test")]
pub card_holder_name: Option<Secret<String>>,
/// The CVC number for the card
#[schema(value_type = Option<String>)]
pub card_cvc: Option<Secret<String>>,
}
impl From<api_models::payments::PaymentMethodData> for PaymentMethodData {
fn from(api_model_payment_method_data: api_models::payments::PaymentMethodData) -> Self {
match api_model_payment_method_data {
@ -343,19 +454,21 @@ impl From<api_models::payments::PaymentMethodData> for PaymentMethodData {
Self::BankTransfer(bank_transfer_data)
}
api_models::payments::PaymentMethodData::Crypto(crypto_data) => {
Self::Crypto(crypto_data)
Self::Crypto(From::from(crypto_data))
}
api_models::payments::PaymentMethodData::MandatePayment => Self::MandatePayment,
api_models::payments::PaymentMethodData::Reward => Self::Reward,
api_models::payments::PaymentMethodData::Upi(upi_data) => Self::Upi(upi_data),
api_models::payments::PaymentMethodData::Upi(upi_data) => {
Self::Upi(From::from(upi_data))
}
api_models::payments::PaymentMethodData::Voucher(voucher_data) => {
Self::Voucher(voucher_data)
Self::Voucher(From::from(voucher_data))
}
api_models::payments::PaymentMethodData::GiftCard(gift_card) => {
Self::GiftCard(gift_card)
Self::GiftCard(Box::new(From::from(*gift_card)))
}
api_models::payments::PaymentMethodData::CardToken(card_token) => {
Self::CardToken(card_token)
Self::CardToken(From::from(card_token))
}
}
}
@ -649,3 +762,86 @@ impl From<api_models::payments::BankRedirectBilling> for BankRedirectBilling {
}
}
}
impl From<api_models::payments::CryptoData> for CryptoData {
fn from(value: api_models::payments::CryptoData) -> Self {
let api_models::payments::CryptoData { pay_currency } = value;
Self { pay_currency }
}
}
impl From<api_models::payments::UpiData> for UpiData {
fn from(value: api_models::payments::UpiData) -> Self {
let api_models::payments::UpiData { vpa_id } = value;
Self { vpa_id }
}
}
impl From<api_models::payments::VoucherData> for VoucherData {
fn from(value: api_models::payments::VoucherData) -> Self {
match value {
api_models::payments::VoucherData::Boleto(boleto_data) => {
Self::Boleto(Box::new(BoletoVoucherData {
social_security_number: boleto_data.social_security_number,
}))
}
api_models::payments::VoucherData::Alfamart(alfamart_data) => {
Self::Alfamart(Box::new(AlfamartVoucherData {
first_name: alfamart_data.first_name,
last_name: alfamart_data.last_name,
email: alfamart_data.email,
}))
}
api_models::payments::VoucherData::Indomaret(indomaret_data) => {
Self::Indomaret(Box::new(IndomaretVoucherData {
first_name: indomaret_data.first_name,
last_name: indomaret_data.last_name,
email: indomaret_data.email,
}))
}
api_models::payments::VoucherData::SevenEleven(jcs_data)
| api_models::payments::VoucherData::Lawson(jcs_data)
| api_models::payments::VoucherData::MiniStop(jcs_data)
| api_models::payments::VoucherData::FamilyMart(jcs_data)
| api_models::payments::VoucherData::Seicomart(jcs_data)
| api_models::payments::VoucherData::PayEasy(jcs_data) => {
Self::SevenEleven(Box::new(JCSVoucherData {
first_name: jcs_data.first_name,
last_name: jcs_data.last_name,
email: jcs_data.email,
phone_number: jcs_data.phone_number,
}))
}
api_models::payments::VoucherData::Efecty => Self::Efecty,
api_models::payments::VoucherData::PagoEfectivo => Self::PagoEfectivo,
api_models::payments::VoucherData::RedCompra => Self::RedCompra,
api_models::payments::VoucherData::RedPagos => Self::RedPagos,
api_models::payments::VoucherData::Oxxo => Self::Oxxo,
}
}
}
impl From<api_models::payments::GiftCardData> for GiftCardData {
fn from(value: api_models::payments::GiftCardData) -> Self {
match value {
api_models::payments::GiftCardData::Givex(details) => Self::Givex(GiftCardDetails {
number: details.number,
cvc: details.cvc,
}),
api_models::payments::GiftCardData::PaySafeCard {} => Self::PaySafeCard {},
}
}
}
impl From<api_models::payments::CardToken> for CardToken {
fn from(value: api_models::payments::CardToken) -> Self {
let api_models::payments::CardToken {
card_holder_name,
card_cvc,
} = value;
Self {
card_holder_name,
card_cvc,
}
}
}

View File

@ -1,6 +1,5 @@
use api_models::payments::CryptoData;
use masking::Secret;
use router::types::{self, api, storage::enums, PaymentAddress};
use router::types::{self, api, domain, storage::enums, PaymentAddress};
use crate::{
connector_auth,
@ -68,7 +67,7 @@ fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
Some(types::PaymentsAuthorizeData {
amount: 1,
currency: enums::Currency::USD,
payment_method_data: types::domain::PaymentMethodData::Crypto(CryptoData {
payment_method_data: types::domain::PaymentMethodData::Crypto(domain::CryptoData {
pay_currency: None,
}),
confirm: true,

View File

@ -1,6 +1,5 @@
use api_models::payments::CryptoData;
use masking::Secret;
use router::types::{self, api, storage::enums, PaymentAddress};
use router::types::{self, api, domain, storage::enums, PaymentAddress};
use serde_json::json;
use crate::{
@ -70,7 +69,7 @@ fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
Some(types::PaymentsAuthorizeData {
amount: 1,
currency: enums::Currency::USD,
payment_method_data: types::domain::PaymentMethodData::Crypto(CryptoData {
payment_method_data: types::domain::PaymentMethodData::Crypto(domain::CryptoData {
pay_currency: None,
}),
confirm: true,

View File

@ -1,6 +1,5 @@
use api_models::payments::CryptoData;
use masking::Secret;
use router::types::{self, api, storage::enums, PaymentAddress};
use router::types::{self, api, domain, storage::enums, PaymentAddress};
use crate::{
connector_auth,
@ -69,7 +68,7 @@ fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
Some(types::PaymentsAuthorizeData {
amount: 1,
currency: enums::Currency::USD,
payment_method_data: types::domain::PaymentMethodData::Crypto(CryptoData {
payment_method_data: types::domain::PaymentMethodData::Crypto(domain::CryptoData {
pay_currency: Some("XRP".to_string()),
}),
confirm: true,

View File

@ -1,6 +1,5 @@
use api_models::payments::CryptoData;
use masking::Secret;
use router::types::{self, api, storage::enums};
use router::types::{self, api, domain, storage::enums};
use crate::{
connector_auth,
@ -69,7 +68,7 @@ fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
Some(types::PaymentsAuthorizeData {
amount: 1,
currency: enums::Currency::USD,
payment_method_data: types::domain::PaymentMethodData::Crypto(CryptoData {
payment_method_data: types::domain::PaymentMethodData::Crypto(domain::CryptoData {
pay_currency: None,
}),
confirm: true,