api contract change for applepay (#693)

This commit is contained in:
Sangamesh Kulkarni
2023-03-01 00:44:16 +05:30
committed by GitHub
parent cf71d7aa3b
commit 4f4b9d7f5f
9 changed files with 12 additions and 78 deletions

View File

@ -560,35 +560,13 @@ pub struct GpayTokenizationData {
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct ApplePayWalletData {
/// The payment data of Apple pay
pub payment_data: ApplepayPaymentData,
pub payment_data: String,
/// 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

View File

@ -1,6 +1,4 @@
use api_models::webhooks::IncomingWebhookEvent;
use base64::Engine;
use error_stack::ResultExt;
use masking::PeekInterface;
use reqwest::Url;
use serde::{Deserialize, Serialize};
@ -582,15 +580,7 @@ fn get_payment_method_data<'a>(
api_models::payments::WalletData::ApplePay(data) => {
let apple_pay_data = AdyenApplePay {
payment_type: PaymentType::Applepay,
apple_pay_token:
consts::BASE64_ENGINE.encode(
common_utils::ext_traits::Encode::<
api_models::payments::ApplepayPaymentData,
>::encode_to_string_of_json(
&data.payment_data
)
.change_context(errors::ConnectorError::RequestEncodingFailed)?,
),
apple_pay_token: data.payment_data.to_string(),
};
Ok(AdyenPaymentMethod::ApplePay(apple_pay_data))

View File

@ -601,7 +601,7 @@ impl TryFrom<types::RefundsResponseRouterData<api::Execute, NuveiPaymentsRespons
.transaction_status
.clone()
.map(|a| a.into())
.unwrap_or(enums::RefundStatus::Failure);
.unwrap_or_else(|| enums::RefundStatus::Failure);
let refund_response = match item.response.status {
NuveiPaymentStatus::Error => Err(types::ErrorResponse {
code: item

View File

@ -93,14 +93,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PayuPaymentsRequest {
PayuWallet {
value: PayuWalletCode::Jp,
wallet_type: WALLET_IDENTIFIER.to_string(),
authorization_code: consts::BASE64_ENGINE.encode(
common_utils::ext_traits::Encode::<
api_models::payments::ApplepayPaymentData,
>::encode_to_string_of_json(
&data.payment_data
)
.change_context(errors::ConnectorError::RequestEncodingFailed)?,
),
authorization_code: data.payment_data,
}
}),
}),

View File

@ -1,4 +1,3 @@
use base64::Engine;
use error_stack::{IntoReport, ResultExt};
use serde::{Deserialize, Serialize};
use url::Url;
@ -112,16 +111,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for RapydPaymentsRequest {
}),
api_models::payments::WalletData::ApplePay(data) => Some(RapydWallet {
payment_type: "apple_pay".to_string(),
token: Some(
consts::BASE64_ENGINE.encode(
common_utils::ext_traits::Encode::<
api_models::payments::ApplepayPaymentData,
>::encode_to_string_of_json(
&data.payment_data
)
.change_context(errors::ConnectorError::RequestEncodingFailed)?,
),
),
token: Some(data.payment_data.to_string()),
}),
_ => None,
};

View File

@ -46,16 +46,7 @@ fn fetch_payment_instrument(
api_models::payments::WalletData::ApplePay(data) => {
Ok(PaymentInstrument::Applepay(WalletPayment {
payment_type: PaymentType::Applepay,
wallet_token:
consts::BASE64_ENGINE.encode(
common_utils::ext_traits::Encode::<
api_models::payments::ApplepayPaymentData,
>::encode_to_string_of_json(
&data.payment_data
)
.change_context(errors::ConnectorError::RequestEncodingFailed)?,
),
wallet_token: data.payment_data,
..WalletPayment::default()
}))
}

View File

@ -599,7 +599,7 @@ pub async fn get_customer_from_details<F: Clone>(
payment_data.email = payment_data
.email
.clone()
.or(customer.as_ref().and_then(|inner| inner.email.clone()));
.or_else(|| customer.as_ref().and_then(|inner| inner.email.clone()));
Ok(customer)
}
}
@ -670,7 +670,10 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R>(
let customer = customer?;
payment_data.payment_intent.customer_id = Some(customer.customer_id.clone());
payment_data.email = payment_data.email.clone().or(customer.email.clone());
payment_data.email = payment_data
.email
.clone()
.or_else(|| customer.email.clone());
Some(customer)
}

View File

@ -192,8 +192,6 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::payments::GpayTokenizationData,
api_models::payments::GpayPaymentMethodInfo,
api_models::payments::ApplePayWalletData,
api_models::payments::ApplepayPaymentData,
api_models::payments::ApplepayHeader,
api_models::payments::ApplepayPaymentMethod,
api_models::payments::PaymentsCancelRequest,
api_models::payments::PaymentListConstraints,

View File

@ -97,16 +97,7 @@ async fn should_authorize_applepay_payment() {
Some(types::PaymentsAuthorizeData {
payment_method_data: types::api::PaymentMethodData::Wallet(
api::WalletData::ApplePay(api_models::payments::ApplePayWalletData {
payment_data: api_models::payments::ApplepayPaymentData {
data: "someData".to_string(),
signature: "someSignature".to_string(),
version: "someVersion".to_string(),
header: api_models::payments::ApplepayHeader {
public_key_hash: "someHash".to_string(),
ephemeral_public_key: "someKey".to_string(),
transaction_id: "someId".to_string(),
},
},
payment_data: "someData".to_string(),
transaction_identifier: "someId".to_string(),
payment_method: api_models::payments::ApplepayPaymentMethod {
display_name: "someName".to_string(),