feat(connector): [Zen] add Cards 3DS, Non-3DS, GooglePay, ApplePay and Webhooks support (#962)

Co-authored-by: Jagan Elavarasan <jaganelavarasan@gmail.com>
This commit is contained in:
SamraatBansal
2023-04-25 20:14:29 +05:30
committed by GitHub
parent 2f378345aa
commit 71c39bdaa3
16 changed files with 1590 additions and 11 deletions

View File

@ -1,6 +1,6 @@
use std::collections::HashMap;
use api_models::payments;
use api_models::payments::{self, OrderDetails};
use base64::Engine;
use common_utils::{
date_time,
@ -151,11 +151,13 @@ pub trait PaymentsAuthorizeRequestData {
fn is_auto_capture(&self) -> Result<bool, Error>;
fn get_email(&self) -> Result<Secret<String, Email>, Error>;
fn get_browser_info(&self) -> Result<types::BrowserInformation, Error>;
fn get_order_details(&self) -> Result<OrderDetails, Error>;
fn get_card(&self) -> Result<api::Card, Error>;
fn get_return_url(&self) -> Result<String, Error>;
fn connector_mandate_id(&self) -> Option<String>;
fn is_mandate_payment(&self) -> bool;
fn get_webhook_url(&self) -> Result<String, Error>;
fn get_router_return_url(&self) -> Result<String, Error>;
}
impl PaymentsAuthorizeRequestData for types::PaymentsAuthorizeData {
@ -174,6 +176,12 @@ impl PaymentsAuthorizeRequestData for types::PaymentsAuthorizeData {
.clone()
.ok_or_else(missing_field_err("browser_info"))
}
fn get_order_details(&self) -> Result<OrderDetails, Error> {
self.order_details
.clone()
.ok_or_else(missing_field_err("order_details"))
}
fn get_card(&self) -> Result<api::Card, Error> {
match self.payment_method_data.clone() {
api::PaymentMethodData::Card(card) => Ok(card),
@ -199,12 +207,27 @@ impl PaymentsAuthorizeRequestData for types::PaymentsAuthorizeData {
.is_some()
}
fn get_webhook_url(&self) -> Result<String, Error> {
self.webhook_url
.clone()
.ok_or_else(missing_field_err("webhook_url"))
}
fn get_router_return_url(&self) -> Result<String, Error> {
self.router_return_url
.clone()
.ok_or_else(missing_field_err("webhook_url"))
}
}
pub trait BrowserInformationData {
fn get_ip_address(&self) -> Result<std::net::IpAddr, Error>;
}
impl BrowserInformationData for types::BrowserInformation {
fn get_ip_address(&self) -> Result<std::net::IpAddr, Error> {
self.ip_address.ok_or_else(missing_field_err("ip_address"))
}
}
pub trait PaymentsCompleteAuthorizeRequestData {
fn is_auto_capture(&self) -> Result<bool, Error>;
}