mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 03:13:56 +08:00
refactor: Payment token support in subscriptions request
This commit is contained in:
@ -232,9 +232,10 @@ pub struct ConfirmSubscriptionPaymentDetails {
|
||||
pub billing: Option<Address>,
|
||||
pub payment_method: PaymentMethod,
|
||||
pub payment_method_type: Option<PaymentMethodType>,
|
||||
pub payment_method_data: PaymentMethodDataRequest,
|
||||
pub payment_method_data: Option<PaymentMethodDataRequest>,
|
||||
pub customer_acceptance: Option<CustomerAcceptance>,
|
||||
pub payment_type: Option<PaymentType>,
|
||||
pub payment_token: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
@ -261,6 +262,7 @@ pub struct PaymentDetails {
|
||||
pub capture_method: Option<CaptureMethod>,
|
||||
pub authentication_type: Option<AuthenticationType>,
|
||||
pub payment_type: Option<PaymentType>,
|
||||
pub payment_token: Option<String>,
|
||||
}
|
||||
|
||||
// Creating new type for PaymentRequest API call as usage of api_models::PaymentsRequest will result in invalid payment request during serialization
|
||||
@ -288,9 +290,10 @@ pub struct ConfirmPaymentsRequestData {
|
||||
pub profile_id: Option<ProfileId>,
|
||||
pub payment_method: PaymentMethod,
|
||||
pub payment_method_type: Option<PaymentMethodType>,
|
||||
pub payment_method_data: PaymentMethodDataRequest,
|
||||
pub payment_method_data: Option<PaymentMethodDataRequest>,
|
||||
pub customer_acceptance: Option<CustomerAcceptance>,
|
||||
pub payment_type: Option<PaymentType>,
|
||||
pub payment_token: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, ToSchema)]
|
||||
@ -313,6 +316,7 @@ pub struct CreateAndConfirmPaymentsRequestData {
|
||||
pub payment_method_data: Option<PaymentMethodDataRequest>,
|
||||
pub customer_acceptance: Option<CustomerAcceptance>,
|
||||
pub payment_type: Option<PaymentType>,
|
||||
pub payment_token: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
@ -340,6 +344,7 @@ pub struct PaymentResponseData {
|
||||
pub billing: Option<Address>,
|
||||
pub shipping: Option<Address>,
|
||||
pub payment_type: Option<PaymentType>,
|
||||
pub payment_token: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
@ -367,10 +372,9 @@ impl ConfirmSubscriptionRequest {
|
||||
pub fn get_billing_address(&self) -> Option<Address> {
|
||||
self.payment_details
|
||||
.payment_method_data
|
||||
.billing
|
||||
.as_ref()
|
||||
.or(self.payment_details.billing.as_ref())
|
||||
.cloned()
|
||||
.and_then(|data| data.billing.clone())
|
||||
.or(self.payment_details.billing.clone())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -368,8 +368,8 @@ pub async fn confirm_subscription(
|
||||
request
|
||||
.payment_details
|
||||
.payment_method_data
|
||||
.payment_method_data
|
||||
.clone(),
|
||||
.as_ref()
|
||||
.and_then(|data| data.payment_method_data.clone()),
|
||||
)
|
||||
.await?;
|
||||
let _customer_updated_response = SubscriptionHandler::update_connector_customer_id_in_customer(
|
||||
|
||||
@ -182,6 +182,7 @@ impl InvoiceHandler {
|
||||
payment_method_data: payment_details.payment_method_data.clone(),
|
||||
customer_acceptance: payment_details.customer_acceptance.clone(),
|
||||
payment_type: payment_details.payment_type,
|
||||
payment_token: payment_details.payment_token.clone(),
|
||||
};
|
||||
payments_api_client::PaymentsApiClient::create_and_confirm_payment(
|
||||
state,
|
||||
@ -208,6 +209,7 @@ impl InvoiceHandler {
|
||||
payment_method_data: payment_details.payment_method_data.clone(),
|
||||
customer_acceptance: payment_details.customer_acceptance.clone(),
|
||||
payment_type: payment_details.payment_type,
|
||||
payment_token: payment_details.payment_token.clone(),
|
||||
};
|
||||
payments_api_client::PaymentsApiClient::confirm_payment(
|
||||
state,
|
||||
|
||||
Reference in New Issue
Block a user