Skip to content

Commit

Permalink
feat: support gpay and applepay session response for all connectors (#…
Browse files Browse the repository at this point in the history
…839)

Co-authored-by: Arun Raj M <[email protected]>
  • Loading branch information
Sangamesh26 and jarnura authored Apr 20, 2023
1 parent 465933b commit d23e14c
Show file tree
Hide file tree
Showing 11 changed files with 296 additions and 651 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions crates/api_models/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,16 +668,6 @@ pub enum RoutableConnectors {
Worldpay,
}

/// Wallets which support obtaining session object
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
#[serde(rename_all = "snake_case")]
pub enum SupportedWallets {
Paypal,
ApplePay,
Klarna,
Gpay,
}

/// Name of banks supported by Hyperswitch
#[derive(
Clone,
Expand Down
53 changes: 51 additions & 2 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1339,8 +1339,8 @@ pub struct PaymentsSessionRequest {
/// This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDK
pub client_secret: String,
/// The list of the supported wallets
#[schema(value_type = Vec<SupportedWallets>)]
pub wallets: Vec<api_enums::SupportedWallets>,
#[schema(value_type = Vec<PaymentMethodType>)]
pub wallets: Vec<api_enums::PaymentMethodType>,
/// Merchant connector details used to make payments.
pub merchant_connector_details: Option<admin::MerchantConnectorDetailsWrap>,
}
Expand Down Expand Up @@ -1412,6 +1412,44 @@ pub struct GpaySessionTokenData {
pub data: GpayMetaData,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ApplepaySessionRequest {
pub merchant_identifier: String,
pub display_name: String,
pub initiative: String,
pub initiative_context: String,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct ApplepaySessionTokenData {
#[serde(rename = "apple_pay")]
pub data: ApplePayMetadata,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct ApplePayMetadata {
pub payment_request_data: PaymentRequestMetadata,
pub session_token_data: SessionTokenInfo,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct PaymentRequestMetadata {
pub supported_networks: Vec<String>,
pub merchant_capabilities: Vec<String>,
pub label: String,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct SessionTokenInfo {
pub certificate: String,
pub certificate_keys: String,
pub merchant_identifier: String,
pub display_name: String,
pub initiative: String,
pub initiative_context: String,
}

#[derive(Debug, Clone, serde::Serialize, ToSchema)]
#[serde(tag = "wallet_name")]
#[serde(rename_all = "snake_case")]
Expand All @@ -1435,6 +1473,7 @@ pub struct GpaySessionTokenResponse {
pub allowed_payment_methods: Vec<GpayAllowedPaymentMethods>,
/// The transaction info Google Pay requires
pub transaction_info: GpayTransactionInfo,
pub connector: String,
}

#[derive(Debug, Clone, serde::Serialize, ToSchema)]
Expand All @@ -1460,9 +1499,11 @@ pub struct ApplepaySessionTokenResponse {
pub session_token_data: ApplePaySessionResponse,
/// Payment request object for Apple Pay
pub payment_request_data: ApplePayPaymentRequest,
pub connector: String,
}

#[derive(Debug, Clone, serde::Serialize, ToSchema, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ApplePaySessionResponse {
/// Timestamp at which session is requested
pub epoch_timestamp: u64,
Expand Down Expand Up @@ -1501,6 +1542,7 @@ pub struct ApplePayPaymentRequest {
pub merchant_capabilities: Vec<String>,
/// The list of supported networks
pub supported_networks: Vec<String>,
pub merchant_identifier: String,
}

#[derive(Debug, Clone, serde::Serialize, ToSchema, serde::Deserialize)]
Expand All @@ -1514,6 +1556,13 @@ pub struct AmountInfo {
pub amount: String,
}

#[derive(Debug, Clone, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ApplepayErrorResponse {
pub status_code: String,
pub status_message: String,
}

#[derive(Default, Debug, serde::Serialize, Clone, ToSchema)]
pub struct PaymentsSessionResponse {
/// The identifier for the payment
Expand Down
15 changes: 7 additions & 8 deletions crates/router/src/connector.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pub mod aci;
pub mod adyen;
pub mod airwallex;
pub mod applepay;
pub mod authorizedotnet;
pub mod bambora;
pub mod bluesnap;
Expand Down Expand Up @@ -32,11 +31,11 @@ pub mod worldpay;
pub mod mollie;

pub use self::{
aci::Aci, adyen::Adyen, airwallex::Airwallex, applepay::Applepay,
authorizedotnet::Authorizedotnet, bambora::Bambora, bluesnap::Bluesnap, braintree::Braintree,
checkout::Checkout, coinbase::Coinbase, cybersource::Cybersource, dlocal::Dlocal,
fiserv::Fiserv, forte::Forte, globalpay::Globalpay, klarna::Klarna, mollie::Mollie,
multisafepay::Multisafepay, nexinets::Nexinets, nuvei::Nuvei, opennode::Opennode,
payeezy::Payeezy, paypal::Paypal, payu::Payu, rapyd::Rapyd, shift4::Shift4, stripe::Stripe,
trustpay::Trustpay, worldline::Worldline, worldpay::Worldpay,
aci::Aci, adyen::Adyen, airwallex::Airwallex, authorizedotnet::Authorizedotnet,
bambora::Bambora, bluesnap::Bluesnap, braintree::Braintree, checkout::Checkout,
coinbase::Coinbase, cybersource::Cybersource, dlocal::Dlocal, fiserv::Fiserv, forte::Forte,
globalpay::Globalpay, klarna::Klarna, mollie::Mollie, multisafepay::Multisafepay,
nexinets::Nexinets, nuvei::Nuvei, opennode::Opennode, payeezy::Payeezy, paypal::Paypal,
payu::Payu, rapyd::Rapyd, shift4::Shift4, stripe::Stripe, trustpay::Trustpay,
worldline::Worldline, worldpay::Worldpay,
};
Loading

0 comments on commit d23e14c

Please sign in to comment.