mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
feat(core): add Mobile Payment (Direct Carrier Billing) as a payment method (#6196)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -71,7 +71,7 @@ pub enum Connector {
|
||||
Cybersource,
|
||||
Datatrans,
|
||||
Deutschebank,
|
||||
// Digitalvirgo, template code for future usage
|
||||
Digitalvirgo,
|
||||
Dlocal,
|
||||
Ebanx,
|
||||
Fiserv,
|
||||
@ -212,6 +212,7 @@ impl Connector {
|
||||
| Self::Coinbase
|
||||
| Self::Cryptopay
|
||||
| Self::Deutschebank
|
||||
| Self::Digitalvirgo
|
||||
| Self::Dlocal
|
||||
| Self::Ebanx
|
||||
| Self::Fiserv
|
||||
|
||||
@ -226,6 +226,9 @@ pub enum FieldType {
|
||||
UserIban,
|
||||
BrowserLanguage,
|
||||
BrowserIp,
|
||||
UserMsisdn,
|
||||
UserClientIdentifier,
|
||||
OrderDetailsProductName,
|
||||
}
|
||||
|
||||
impl FieldType {
|
||||
@ -316,6 +319,9 @@ impl PartialEq for FieldType {
|
||||
(Self::UserCpf, Self::UserCpf) => true,
|
||||
(Self::UserCnpj, Self::UserCnpj) => true,
|
||||
(Self::LanguagePreference { .. }, Self::LanguagePreference { .. }) => true,
|
||||
(Self::UserMsisdn, Self::UserMsisdn) => true,
|
||||
(Self::UserClientIdentifier, Self::UserClientIdentifier) => true,
|
||||
(Self::OrderDetailsProductName, Self::OrderDetailsProductName) => true,
|
||||
_unused => false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1990,6 +1990,7 @@ mod payment_method_data_serde {
|
||||
| PaymentMethodData::BankRedirect(_)
|
||||
| PaymentMethodData::BankTransfer(_)
|
||||
| PaymentMethodData::RealTimePayment(_)
|
||||
| PaymentMethodData::MobilePayment(_)
|
||||
| PaymentMethodData::CardToken(_)
|
||||
| PaymentMethodData::Crypto(_)
|
||||
| PaymentMethodData::GiftCard(_)
|
||||
@ -2061,6 +2062,8 @@ pub enum PaymentMethodData {
|
||||
CardToken(CardToken),
|
||||
#[schema(title = "OpenBanking")]
|
||||
OpenBanking(OpenBankingData),
|
||||
#[schema(title = "MobilePayment")]
|
||||
MobilePayment(MobilePaymentData),
|
||||
}
|
||||
|
||||
pub trait GetAddressFromPaymentMethodData {
|
||||
@ -2085,7 +2088,8 @@ impl GetAddressFromPaymentMethodData for PaymentMethodData {
|
||||
| Self::GiftCard(_)
|
||||
| Self::CardToken(_)
|
||||
| Self::OpenBanking(_)
|
||||
| Self::MandatePayment => None,
|
||||
| Self::MandatePayment
|
||||
| Self::MobilePayment(_) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2123,6 +2127,7 @@ impl PaymentMethodData {
|
||||
Self::Voucher(_) => Some(api_enums::PaymentMethod::Voucher),
|
||||
Self::GiftCard(_) => Some(api_enums::PaymentMethod::GiftCard),
|
||||
Self::OpenBanking(_) => Some(api_enums::PaymentMethod::OpenBanking),
|
||||
Self::MobilePayment(_) => Some(api_enums::PaymentMethod::MobilePayment),
|
||||
Self::CardToken(_) | Self::MandatePayment => None,
|
||||
}
|
||||
}
|
||||
@ -2143,6 +2148,14 @@ impl GetPaymentMethodType for CardRedirectData {
|
||||
}
|
||||
}
|
||||
|
||||
impl GetPaymentMethodType for MobilePaymentData {
|
||||
fn get_payment_method_type(&self) -> api_enums::PaymentMethodType {
|
||||
match self {
|
||||
Self::DirectCarrierBilling { .. } => api_enums::PaymentMethodType::DirectCarrierBilling,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl GetPaymentMethodType for WalletData {
|
||||
fn get_payment_method_type(&self) -> api_enums::PaymentMethodType {
|
||||
match self {
|
||||
@ -2432,6 +2445,10 @@ pub enum AdditionalPaymentData {
|
||||
#[serde(flatten)]
|
||||
details: Option<OpenBankingData>,
|
||||
},
|
||||
MobilePayment {
|
||||
#[serde(flatten)]
|
||||
details: Option<MobilePaymentData>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
|
||||
@ -3232,6 +3249,20 @@ pub enum OpenBankingData {
|
||||
#[serde(rename = "open_banking_pis")]
|
||||
OpenBankingPIS {},
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum MobilePaymentData {
|
||||
DirectCarrierBilling {
|
||||
/// The phone number of the user
|
||||
#[schema(value_type = String, example = "1234567890")]
|
||||
msisdn: String,
|
||||
/// Unique user id
|
||||
#[schema(value_type = Option<String>, example = "02iacdYXGI9CnyJdoN8c7")]
|
||||
client_uid: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct GooglePayWalletData {
|
||||
@ -3502,6 +3533,7 @@ where
|
||||
| PaymentMethodDataResponse::GiftCard(_)
|
||||
| PaymentMethodDataResponse::PayLater(_)
|
||||
| PaymentMethodDataResponse::RealTimePayment(_)
|
||||
| PaymentMethodDataResponse::MobilePayment(_)
|
||||
| PaymentMethodDataResponse::Upi(_)
|
||||
| PaymentMethodDataResponse::Wallet(_)
|
||||
| PaymentMethodDataResponse::BankTransfer(_)
|
||||
@ -3538,6 +3570,7 @@ pub enum PaymentMethodDataResponse {
|
||||
CardRedirect(Box<CardRedirectResponse>),
|
||||
CardToken(Box<CardTokenResponse>),
|
||||
OpenBanking(Box<OpenBankingResponse>),
|
||||
MobilePayment(Box<MobilePaymentResponse>),
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
@ -3597,6 +3630,12 @@ pub struct OpenBankingResponse {
|
||||
details: Option<OpenBankingData>,
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
pub struct MobilePaymentResponse {
|
||||
#[serde(flatten)]
|
||||
details: Option<MobilePaymentData>,
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
pub struct RealTimePaymentDataResponse {
|
||||
#[serde(flatten)]
|
||||
@ -3874,6 +3913,7 @@ pub enum NextActionType {
|
||||
TriggerApi,
|
||||
DisplayBankTransferInformation,
|
||||
DisplayWaitScreen,
|
||||
CollectOtp,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
@ -3930,6 +3970,10 @@ pub enum NextActionData {
|
||||
InvokeSdkClient {
|
||||
next_action_data: SdkNextActionData,
|
||||
},
|
||||
/// Contains consent to collect otp for mobile payment
|
||||
CollectOtp {
|
||||
consent_data_required: MobilePaymentConsent,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
@ -4025,6 +4069,20 @@ pub struct VoucherNextStepData {
|
||||
pub instructions_url: Option<Url>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
pub struct MobilePaymentNextStepData {
|
||||
/// is consent details required to be shown by sdk
|
||||
pub consent_data_required: MobilePaymentConsent,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum MobilePaymentConsent {
|
||||
ConsentRequired,
|
||||
ConsentNotRequired,
|
||||
ConsentOptional,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct QrCodeNextStepsInstruction {
|
||||
pub image_data_url: Url,
|
||||
@ -5134,6 +5192,9 @@ impl From<AdditionalPaymentData> for PaymentMethodDataResponse {
|
||||
AdditionalPaymentData::OpenBanking { details } => {
|
||||
Self::OpenBanking(Box::new(OpenBankingResponse { details }))
|
||||
}
|
||||
AdditionalPaymentData::MobilePayment { details } => {
|
||||
Self::MobilePayment(Box::new(MobilePaymentResponse { details }))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user