mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 09:07:09 +08:00
feat(connector): [Adyen] implement PaySafe (#1805)
Co-authored-by: Sangamesh <sangamesh.kulkarni@juspay.in> Co-authored-by: Sk Sakil Mostak <skmahim71@gmail.com> Co-authored-by: Pa1NarK <69745008+pixincreate@users.noreply.github.com>
This commit is contained in:
@ -394,6 +394,8 @@ pub enum AdyenPaymentMethod<'a> {
|
||||
OnlineBankingFpx(Box<OnlineBankingFpxData>),
|
||||
#[serde(rename = "molpay_ebanking_TH")]
|
||||
OnlineBankingThailand(Box<OnlineBankingThailandData>),
|
||||
#[serde(rename = "paysafecard")]
|
||||
PaySafeCard,
|
||||
#[serde(rename = "paybright")]
|
||||
PayBright,
|
||||
#[serde(rename = "doku_permata_lite_atm")]
|
||||
@ -938,6 +940,8 @@ pub enum PaymentType {
|
||||
OnlineBankingFpx,
|
||||
#[serde(rename = "molpay_ebanking_TH")]
|
||||
OnlineBankingThailand,
|
||||
#[serde(rename = "paysafecard")]
|
||||
PaySafeCard,
|
||||
PayBright,
|
||||
Paypal,
|
||||
Scheme,
|
||||
@ -1132,6 +1136,9 @@ impl<'a> TryFrom<&types::PaymentsAuthorizeRouterData> for AdyenPaymentRequest<'a
|
||||
api_models::payments::PaymentMethodData::Voucher(ref voucher_data) => {
|
||||
AdyenPaymentRequest::try_from((item, voucher_data))
|
||||
}
|
||||
api_models::payments::PaymentMethodData::GiftCard(ref gift_card) => {
|
||||
AdyenPaymentRequest::try_from((item, gift_card.as_ref()))
|
||||
}
|
||||
_ => Err(errors::ConnectorError::NotSupported {
|
||||
message: format!("{:?}", item.request.payment_method_type),
|
||||
connector: "Adyen",
|
||||
@ -1418,6 +1425,18 @@ impl<'a> TryFrom<&api_models::payments::VoucherData> for AdyenPaymentMethod<'a>
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TryFrom<&api_models::payments::GiftCardData> for AdyenPaymentMethod<'a> {
|
||||
type Error = Error;
|
||||
fn try_from(gift_card_data: &api_models::payments::GiftCardData) -> Result<Self, Self::Error> {
|
||||
match gift_card_data {
|
||||
payments::GiftCardData::PaySafeCard {} => Ok(AdyenPaymentMethod::PaySafeCard),
|
||||
payments::GiftCardData::BabyGiftCard { .. } => {
|
||||
Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TryFrom<&api::Card> for AdyenPaymentMethod<'a> {
|
||||
type Error = Error;
|
||||
fn try_from(card: &api::Card) -> Result<Self, Self::Error> {
|
||||
@ -2100,6 +2119,53 @@ impl<'a>
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a>
|
||||
TryFrom<(
|
||||
&types::PaymentsAuthorizeRouterData,
|
||||
&api_models::payments::GiftCardData,
|
||||
)> for AdyenPaymentRequest<'a>
|
||||
{
|
||||
type Error = Error;
|
||||
|
||||
fn try_from(
|
||||
value: (
|
||||
&types::PaymentsAuthorizeRouterData,
|
||||
&api_models::payments::GiftCardData,
|
||||
),
|
||||
) -> Result<Self, Self::Error> {
|
||||
let (item, gift_card_data) = value;
|
||||
let amount = get_amount_data(item);
|
||||
let auth_type = AdyenAuthType::try_from(&item.connector_auth_type)?;
|
||||
let shopper_interaction = AdyenShopperInteraction::from(item);
|
||||
let return_url = item.request.get_router_return_url()?;
|
||||
let payment_method = AdyenPaymentMethod::try_from(gift_card_data)?;
|
||||
let request = AdyenPaymentRequest {
|
||||
amount,
|
||||
merchant_account: auth_type.merchant_account,
|
||||
payment_method,
|
||||
reference: item.payment_id.to_string(),
|
||||
return_url,
|
||||
browser_info: None,
|
||||
shopper_interaction,
|
||||
recurring_processing_model: None,
|
||||
additional_data: None,
|
||||
shopper_name: None,
|
||||
shopper_locale: None,
|
||||
shopper_email: item.request.email.clone(),
|
||||
telephone_number: None,
|
||||
billing_address: None,
|
||||
delivery_address: None,
|
||||
country_code: None,
|
||||
line_items: None,
|
||||
shopper_reference: None,
|
||||
store_payment_method: None,
|
||||
channel: None,
|
||||
social_security_number: None,
|
||||
};
|
||||
Ok(request)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a>
|
||||
TryFrom<(
|
||||
&types::PaymentsAuthorizeRouterData,
|
||||
@ -2668,7 +2734,8 @@ pub fn get_wait_screen_metadata(
|
||||
| PaymentType::BriVa
|
||||
| PaymentType::CimbVa
|
||||
| PaymentType::DanamonVa
|
||||
| PaymentType::MandiriVa => Ok(None),
|
||||
| PaymentType::MandiriVa
|
||||
| PaymentType::PaySafeCard => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
@ -2755,7 +2822,8 @@ pub fn get_present_to_shopper_metadata(
|
||||
| PaymentType::Samsungpay
|
||||
| PaymentType::Twint
|
||||
| PaymentType::Vipps
|
||||
| PaymentType::Swish => Ok(None),
|
||||
| PaymentType::Swish
|
||||
| PaymentType::PaySafeCard => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1415,7 +1415,6 @@ pub(crate) fn validate_payment_method_fields_present(
|
||||
})
|
||||
},
|
||||
)?;
|
||||
|
||||
utils::when(
|
||||
req.payment_method.is_some() && req.payment_method_type.is_some(),
|
||||
|| {
|
||||
@ -1571,7 +1570,10 @@ pub fn validate_payment_method_type_against_payment_method(
|
||||
| api_enums::PaymentMethodType::Indomaret
|
||||
| api_enums::PaymentMethodType::Alfamart
|
||||
),
|
||||
api_enums::PaymentMethod::GiftCard => false,
|
||||
api_enums::PaymentMethod::GiftCard => matches!(
|
||||
payment_method_type,
|
||||
api_enums::PaymentMethodType::PaySafeCard
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -236,6 +236,7 @@ impl ForeignFrom<api_enums::PaymentMethodType> for api_enums::PaymentMethod {
|
||||
| api_enums::PaymentMethodType::DanamonVa
|
||||
| api_enums::PaymentMethodType::MandiriVa
|
||||
| api_enums::PaymentMethodType::Pix => Self::BankTransfer,
|
||||
api_enums::PaymentMethodType::PaySafeCard => Self::GiftCard,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user