feat(core): support for gpay session token creation (#152)

This commit is contained in:
Narayan Bhat
2022-12-19 13:38:03 +05:30
committed by GitHub
parent 5a43da6a1a
commit 50706bde77
15 changed files with 262 additions and 62 deletions

View File

@ -691,11 +691,65 @@ pub struct PaymentsSessionRequest {
pub client_secret: String,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct GpayAllowedMethodsParameters {
pub allowed_auth_methods: Vec<String>,
pub allowed_card_networks: Vec<String>,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct GpayTokenParameters {
pub gateway: String,
pub gateway_merchant_id: String,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct GpayTokenizationSpecification {
#[serde(rename = "type")]
pub token_specification_type: String,
pub parameters: GpayTokenParameters,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct GpayAllowedPaymentMethods {
#[serde(rename = "type")]
pub payment_method_type: String,
pub parameters: GpayAllowedMethodsParameters,
pub tokenization_specification: GpayTokenizationSpecification,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct GpayTransactionInfo {
pub country_code: String,
pub currency_code: String,
pub total_price_status: String,
pub total_price: i64,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct GpayMerchantInfo {
pub merchant_name: String,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct GpayMetadata {
pub merchant_info: GpayMerchantInfo,
pub allowed_payment_methods: Vec<GpayAllowedPaymentMethods>,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct GpaySessionTokenData {
pub gpay: GpayMetadata,
}
#[derive(Debug, Clone, serde::Serialize)]
#[serde(tag = "connector_name")]
#[serde(rename_all = "lowercase")]
pub enum SessionToken {
Gpay {},
Gpay {
allowed_payment_methods: Vec<GpayAllowedPaymentMethods>,
transaction_info: GpayTransactionInfo,
},
Klarna {
session_token: String,
session_id: String,