mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
api contract change for applepay (#693)
This commit is contained in:
committed by
GitHub
parent
cf71d7aa3b
commit
4f4b9d7f5f
@ -560,35 +560,13 @@ pub struct GpayTokenizationData {
|
|||||||
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||||
pub struct ApplePayWalletData {
|
pub struct ApplePayWalletData {
|
||||||
/// The payment data of Apple pay
|
/// The payment data of Apple pay
|
||||||
pub payment_data: ApplepayPaymentData,
|
pub payment_data: String,
|
||||||
/// The payment method of Apple pay
|
/// The payment method of Apple pay
|
||||||
pub payment_method: ApplepayPaymentMethod,
|
pub payment_method: ApplepayPaymentMethod,
|
||||||
/// The unique identifier for the transaction
|
/// The unique identifier for the transaction
|
||||||
pub transaction_identifier: String,
|
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)]
|
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||||
pub struct ApplepayPaymentMethod {
|
pub struct ApplepayPaymentMethod {
|
||||||
/// The name to be displayed on Apple Pay button
|
/// The name to be displayed on Apple Pay button
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
use api_models::webhooks::IncomingWebhookEvent;
|
use api_models::webhooks::IncomingWebhookEvent;
|
||||||
use base64::Engine;
|
|
||||||
use error_stack::ResultExt;
|
|
||||||
use masking::PeekInterface;
|
use masking::PeekInterface;
|
||||||
use reqwest::Url;
|
use reqwest::Url;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@ -582,15 +580,7 @@ fn get_payment_method_data<'a>(
|
|||||||
api_models::payments::WalletData::ApplePay(data) => {
|
api_models::payments::WalletData::ApplePay(data) => {
|
||||||
let apple_pay_data = AdyenApplePay {
|
let apple_pay_data = AdyenApplePay {
|
||||||
payment_type: PaymentType::Applepay,
|
payment_type: PaymentType::Applepay,
|
||||||
apple_pay_token:
|
apple_pay_token: data.payment_data.to_string(),
|
||||||
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)?,
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(AdyenPaymentMethod::ApplePay(apple_pay_data))
|
Ok(AdyenPaymentMethod::ApplePay(apple_pay_data))
|
||||||
|
|||||||
@ -601,7 +601,7 @@ impl TryFrom<types::RefundsResponseRouterData<api::Execute, NuveiPaymentsRespons
|
|||||||
.transaction_status
|
.transaction_status
|
||||||
.clone()
|
.clone()
|
||||||
.map(|a| a.into())
|
.map(|a| a.into())
|
||||||
.unwrap_or(enums::RefundStatus::Failure);
|
.unwrap_or_else(|| enums::RefundStatus::Failure);
|
||||||
let refund_response = match item.response.status {
|
let refund_response = match item.response.status {
|
||||||
NuveiPaymentStatus::Error => Err(types::ErrorResponse {
|
NuveiPaymentStatus::Error => Err(types::ErrorResponse {
|
||||||
code: item
|
code: item
|
||||||
|
|||||||
@ -93,14 +93,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PayuPaymentsRequest {
|
|||||||
PayuWallet {
|
PayuWallet {
|
||||||
value: PayuWalletCode::Jp,
|
value: PayuWalletCode::Jp,
|
||||||
wallet_type: WALLET_IDENTIFIER.to_string(),
|
wallet_type: WALLET_IDENTIFIER.to_string(),
|
||||||
authorization_code: consts::BASE64_ENGINE.encode(
|
authorization_code: data.payment_data,
|
||||||
common_utils::ext_traits::Encode::<
|
|
||||||
api_models::payments::ApplepayPaymentData,
|
|
||||||
>::encode_to_string_of_json(
|
|
||||||
&data.payment_data
|
|
||||||
)
|
|
||||||
.change_context(errors::ConnectorError::RequestEncodingFailed)?,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
use base64::Engine;
|
|
||||||
use error_stack::{IntoReport, ResultExt};
|
use error_stack::{IntoReport, ResultExt};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
@ -112,16 +111,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for RapydPaymentsRequest {
|
|||||||
}),
|
}),
|
||||||
api_models::payments::WalletData::ApplePay(data) => Some(RapydWallet {
|
api_models::payments::WalletData::ApplePay(data) => Some(RapydWallet {
|
||||||
payment_type: "apple_pay".to_string(),
|
payment_type: "apple_pay".to_string(),
|
||||||
token: Some(
|
token: Some(data.payment_data.to_string()),
|
||||||
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)?,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
}),
|
}),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -46,16 +46,7 @@ fn fetch_payment_instrument(
|
|||||||
api_models::payments::WalletData::ApplePay(data) => {
|
api_models::payments::WalletData::ApplePay(data) => {
|
||||||
Ok(PaymentInstrument::Applepay(WalletPayment {
|
Ok(PaymentInstrument::Applepay(WalletPayment {
|
||||||
payment_type: PaymentType::Applepay,
|
payment_type: PaymentType::Applepay,
|
||||||
|
wallet_token: data.payment_data,
|
||||||
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)?,
|
|
||||||
),
|
|
||||||
..WalletPayment::default()
|
..WalletPayment::default()
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -599,7 +599,7 @@ pub async fn get_customer_from_details<F: Clone>(
|
|||||||
payment_data.email = payment_data
|
payment_data.email = payment_data
|
||||||
.email
|
.email
|
||||||
.clone()
|
.clone()
|
||||||
.or(customer.as_ref().and_then(|inner| inner.email.clone()));
|
.or_else(|| customer.as_ref().and_then(|inner| inner.email.clone()));
|
||||||
Ok(customer)
|
Ok(customer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -670,7 +670,10 @@ pub async fn create_customer_if_not_exist<'a, F: Clone, R>(
|
|||||||
let customer = customer?;
|
let customer = customer?;
|
||||||
|
|
||||||
payment_data.payment_intent.customer_id = Some(customer.customer_id.clone());
|
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)
|
Some(customer)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -192,8 +192,6 @@ Never share your secret api keys. Keep them guarded and secure.
|
|||||||
api_models::payments::GpayTokenizationData,
|
api_models::payments::GpayTokenizationData,
|
||||||
api_models::payments::GpayPaymentMethodInfo,
|
api_models::payments::GpayPaymentMethodInfo,
|
||||||
api_models::payments::ApplePayWalletData,
|
api_models::payments::ApplePayWalletData,
|
||||||
api_models::payments::ApplepayPaymentData,
|
|
||||||
api_models::payments::ApplepayHeader,
|
|
||||||
api_models::payments::ApplepayPaymentMethod,
|
api_models::payments::ApplepayPaymentMethod,
|
||||||
api_models::payments::PaymentsCancelRequest,
|
api_models::payments::PaymentsCancelRequest,
|
||||||
api_models::payments::PaymentListConstraints,
|
api_models::payments::PaymentListConstraints,
|
||||||
|
|||||||
@ -97,16 +97,7 @@ async fn should_authorize_applepay_payment() {
|
|||||||
Some(types::PaymentsAuthorizeData {
|
Some(types::PaymentsAuthorizeData {
|
||||||
payment_method_data: types::api::PaymentMethodData::Wallet(
|
payment_method_data: types::api::PaymentMethodData::Wallet(
|
||||||
api::WalletData::ApplePay(api_models::payments::ApplePayWalletData {
|
api::WalletData::ApplePay(api_models::payments::ApplePayWalletData {
|
||||||
payment_data: api_models::payments::ApplepayPaymentData {
|
payment_data: "someData".to_string(),
|
||||||
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(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
transaction_identifier: "someId".to_string(),
|
transaction_identifier: "someId".to_string(),
|
||||||
payment_method: api_models::payments::ApplepayPaymentMethod {
|
payment_method: api_models::payments::ApplepayPaymentMethod {
|
||||||
display_name: "someName".to_string(),
|
display_name: "someName".to_string(),
|
||||||
|
|||||||
Reference in New Issue
Block a user