feat: api contract change for wallet (#628)

This commit is contained in:
Sangamesh Kulkarni
2023-02-27 17:38:40 +05:30
committed by GitHub
parent 060c54193e
commit ff86417eee
20 changed files with 1176 additions and 477 deletions

View File

@ -26,7 +26,7 @@ pub struct CreateMerchantAccount {
pub merchant_details: Option<MerchantDetails>,
/// The URL to redirect after the completion of the operation
#[schema(max_length = 255, example = "https://www.example.com/success")]
#[schema(value_type = Option<String>, max_length = 255, example = "https://www.example.com/success")]
pub return_url: Option<url::Url>,
/// Webhook related details
@ -311,6 +311,7 @@ pub struct AcceptedCurrencies {
#[serde(rename = "type")]
pub accept_type: String,
/// List of currencies of the provided type
#[schema(value_type = Option<Vec<Currency>>)]
pub list: Option<Vec<api_enums::Currency>>,
}

View File

@ -427,7 +427,6 @@ pub enum PaymentMethod {
Card,
PayLater,
Wallet,
BankRedirect,
}
#[derive(
@ -627,6 +626,7 @@ pub enum SupportedWallets {
strum::Display,
strum::EnumString,
frunk::LabelledGeneric,
ToSchema,
)]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]

View File

@ -4,7 +4,7 @@ use common_utils::pii;
use serde::de;
use utoipa::ToSchema;
use crate::{admin, enums as api_enums};
use crate::{admin, enums as api_enums, payments};
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
#[serde(deny_unknown_fields)]
@ -480,7 +480,7 @@ pub struct CustomerPaymentMethod {
pub payment_method: api_enums::PaymentMethod,
/// This is a sub-category of payment method.
#[schema(value_type = Option<PaymentMethodSubType>,example = "credit_card")]
#[schema(value_type = Option<PaymentMethodType>,example = "credit_card")]
pub payment_method_type: Option<api_enums::PaymentMethodType>,
/// The name of the bank/ provider issuing the payment method to the end user
@ -584,8 +584,7 @@ pub struct TokenizedCardValue2 {
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct TokenizedWalletValue1 {
pub issuer: String,
pub token: Option<String>,
pub data: payments::WalletData,
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]

View File

@ -97,7 +97,7 @@ pub struct PaymentsRequest {
pub description: Option<String>,
/// The URL to redirect after the completion of the operation
#[schema(example = "https://hyperswitch.io")]
#[schema(value_type = Option<String>, example = "https://hyperswitch.io")]
pub return_url: Option<url::Url>,
/// Indicates that you intend to make future payments with this Payments payment method. Providing this parameter will attach the payment method to the Customer, if present, after the Payment is confirmed and any required actions from the user are complete.
#[schema(value_type = Option<FutureUsage>, example = "off_session")]
@ -112,7 +112,7 @@ pub struct PaymentsRequest {
pub payment_method_data: Option<PaymentMethodData>,
/// The payment method that is to be used
#[schema(value_type = Option<PaymentMethodType>, example = "bank_transfer")]
#[schema(value_type = Option<PaymentMethod>, example = "card")]
pub payment_method: Option<api_enums::PaymentMethod>,
/// Provide a reference to a stored payment method
@ -170,7 +170,7 @@ pub struct PaymentsRequest {
pub payment_experience: Option<api_enums::PaymentExperience>,
/// Payment Method Type
#[schema(value_type = Option<PaymentMethodSubType>, example = "gpay")]
#[schema(value_type = Option<PaymentMethodType>, example = "google_pay")]
pub payment_method_type: Option<api_enums::PaymentMethodType>,
}
@ -441,6 +441,7 @@ pub enum BankRedirectData {
Eps {
/// The billing details for bank redirection
billing_details: BankRedirectBilling,
#[schema(value_type = BankNames)]
bank_name: api_enums::BankNames,
},
Giropay {
@ -450,6 +451,7 @@ pub enum BankRedirectData {
Ideal {
/// The billing details for bank redirection
billing_details: BankRedirectBilling,
#[schema(value_type = BankNames)]
bank_name: api_enums::BankNames,
},
Sofort {
@ -472,16 +474,103 @@ pub struct BankRedirectionRequest {}
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct BankRedirectBilling {
/// The name for which billing is issued
#[schema(value_type = String)]
pub billing_name: Secret<String>,
}
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct WalletData {
/// The issuer of the wallet
#[schema(value_type = WalletIssuer)]
pub issuer_name: api_enums::WalletIssuer,
#[serde(rename_all = "snake_case")]
pub enum WalletData {
/// The wallet data for Google pay
GooglePay(GpayWalletData),
/// The wallet data for Apple pay
ApplePay(ApplePayWalletData),
/// The wallet data for Paypal
PaypalSdk(PayPalWalletData),
/// This is for paypal redirection
PaypalRedirect(PaypalRedirection),
}
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct GpayWalletData {
/// The type of payment method
#[serde(rename = "type")]
pub pm_type: String,
/// User-facing message to describe the payment method that funds this transaction.
pub description: String,
/// The information of the payment method
pub info: GpayPaymentMethodInfo,
/// The tokenization data of Google pay
pub tokenization_data: GpayTokenizationData,
}
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct PaypalRedirection {}
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct GpayPaymentMethodInfo {
/// The name of the card network
pub card_network: String,
/// The details of the card
pub card_details: String,
}
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct PayPalWalletData {
/// Token generated for the Apple pay
pub token: String,
}
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct GpayTokenizationData {
/// The type of the token
#[serde(rename = "type")]
pub token_type: String,
/// Token generated for the wallet
pub token: Option<String>,
pub token: String,
}
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct ApplePayWalletData {
/// The payment data of Apple pay
pub payment_data: ApplepayPaymentData,
/// The payment method of Apple pay
pub payment_method: ApplepayPaymentMethod,
/// The unique identifier for the transaction
pub transaction_identifier: String,
}
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct ApplepayPaymentData {
/// The data of Apple pay payment
pub data: String,
/// A string which represents the properties of a payment
pub signature: String,
/// The Apple pay header
pub header: ApplepayHeader,
/// The Apple Pay version used
pub version: String,
}
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct ApplepayHeader {
/// The public key hash used
pub public_key_hash: String,
/// The ephemeral public key used
pub ephemeral_public_key: String,
/// The unique identifier for the transaction
pub transaction_id: String,
}
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct ApplepayPaymentMethod {
/// The name to be displayed on Apple Pay button
pub display_name: String,
/// The network of the Apple pay payment method
pub network: String,
/// The type of the payment method
#[serde(rename = "type")]
pub pm_type: String,
}
#[derive(Eq, PartialEq, Clone, Debug, serde::Serialize)]
@ -785,7 +874,7 @@ pub struct PaymentsResponse {
#[schema(value_type = Option<PaymentExperience>, example = "redirect_to_url")]
pub payment_experience: Option<api_enums::PaymentExperience>,
/// Payment Method Type
#[schema(value_type = Option<PaymentMethodSubType>, example = "gpay")]
#[schema(value_type = Option<PaymentMethodType>, example = "gpay")]
pub payment_method_type: Option<api_enums::PaymentMethodType>,
}
@ -1097,16 +1186,16 @@ pub struct GpaySessionTokenData {
#[derive(Debug, Clone, serde::Serialize, ToSchema)]
#[serde(tag = "wallet_name")]
#[serde(rename_all = "lowercase")]
#[serde(rename_all = "snake_case")]
pub enum SessionToken {
/// The session response structure for Google Pay
Gpay(Box<GpaySessionTokenResponse>),
GooglePay(Box<GpaySessionTokenResponse>),
/// The session response structure for Klarna
Klarna(Box<KlarnaSessionTokenResponse>),
/// The session response structure for PayPal
Paypal(Box<PaypalSessionTokenResponse>),
/// The session response structure for Apple Pay
Applepay(Box<ApplepaySessionTokenResponse>),
ApplePay(Box<ApplepaySessionTokenResponse>),
}
#[derive(Debug, Clone, serde::Serialize, ToSchema)]