mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 11:24:45 +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 billing: Option<Address>,
|
||||||
pub payment_method: PaymentMethod,
|
pub payment_method: PaymentMethod,
|
||||||
pub payment_method_type: Option<PaymentMethodType>,
|
pub payment_method_type: Option<PaymentMethodType>,
|
||||||
pub payment_method_data: PaymentMethodDataRequest,
|
pub payment_method_data: Option<PaymentMethodDataRequest>,
|
||||||
pub customer_acceptance: Option<CustomerAcceptance>,
|
pub customer_acceptance: Option<CustomerAcceptance>,
|
||||||
pub payment_type: Option<PaymentType>,
|
pub payment_type: Option<PaymentType>,
|
||||||
|
pub payment_token: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
|
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||||
@ -261,6 +262,7 @@ pub struct PaymentDetails {
|
|||||||
pub capture_method: Option<CaptureMethod>,
|
pub capture_method: Option<CaptureMethod>,
|
||||||
pub authentication_type: Option<AuthenticationType>,
|
pub authentication_type: Option<AuthenticationType>,
|
||||||
pub payment_type: Option<PaymentType>,
|
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
|
// 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 profile_id: Option<ProfileId>,
|
||||||
pub payment_method: PaymentMethod,
|
pub payment_method: PaymentMethod,
|
||||||
pub payment_method_type: Option<PaymentMethodType>,
|
pub payment_method_type: Option<PaymentMethodType>,
|
||||||
pub payment_method_data: PaymentMethodDataRequest,
|
pub payment_method_data: Option<PaymentMethodDataRequest>,
|
||||||
pub customer_acceptance: Option<CustomerAcceptance>,
|
pub customer_acceptance: Option<CustomerAcceptance>,
|
||||||
pub payment_type: Option<PaymentType>,
|
pub payment_type: Option<PaymentType>,
|
||||||
|
pub payment_token: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, serde::Serialize, ToSchema)]
|
#[derive(Debug, Clone, serde::Serialize, ToSchema)]
|
||||||
@ -313,6 +316,7 @@ pub struct CreateAndConfirmPaymentsRequestData {
|
|||||||
pub payment_method_data: Option<PaymentMethodDataRequest>,
|
pub payment_method_data: Option<PaymentMethodDataRequest>,
|
||||||
pub customer_acceptance: Option<CustomerAcceptance>,
|
pub customer_acceptance: Option<CustomerAcceptance>,
|
||||||
pub payment_type: Option<PaymentType>,
|
pub payment_type: Option<PaymentType>,
|
||||||
|
pub payment_token: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
|
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||||
@ -340,6 +344,7 @@ pub struct PaymentResponseData {
|
|||||||
pub billing: Option<Address>,
|
pub billing: Option<Address>,
|
||||||
pub shipping: Option<Address>,
|
pub shipping: Option<Address>,
|
||||||
pub payment_type: Option<PaymentType>,
|
pub payment_type: Option<PaymentType>,
|
||||||
|
pub payment_token: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
|
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||||
@ -367,10 +372,9 @@ impl ConfirmSubscriptionRequest {
|
|||||||
pub fn get_billing_address(&self) -> Option<Address> {
|
pub fn get_billing_address(&self) -> Option<Address> {
|
||||||
self.payment_details
|
self.payment_details
|
||||||
.payment_method_data
|
.payment_method_data
|
||||||
.billing
|
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.or(self.payment_details.billing.as_ref())
|
.and_then(|data| data.billing.clone())
|
||||||
.cloned()
|
.or(self.payment_details.billing.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -368,8 +368,8 @@ pub async fn confirm_subscription(
|
|||||||
request
|
request
|
||||||
.payment_details
|
.payment_details
|
||||||
.payment_method_data
|
.payment_method_data
|
||||||
.payment_method_data
|
.as_ref()
|
||||||
.clone(),
|
.and_then(|data| data.payment_method_data.clone()),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
let _customer_updated_response = SubscriptionHandler::update_connector_customer_id_in_customer(
|
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(),
|
payment_method_data: payment_details.payment_method_data.clone(),
|
||||||
customer_acceptance: payment_details.customer_acceptance.clone(),
|
customer_acceptance: payment_details.customer_acceptance.clone(),
|
||||||
payment_type: payment_details.payment_type,
|
payment_type: payment_details.payment_type,
|
||||||
|
payment_token: payment_details.payment_token.clone(),
|
||||||
};
|
};
|
||||||
payments_api_client::PaymentsApiClient::create_and_confirm_payment(
|
payments_api_client::PaymentsApiClient::create_and_confirm_payment(
|
||||||
state,
|
state,
|
||||||
@ -208,6 +209,7 @@ impl InvoiceHandler {
|
|||||||
payment_method_data: payment_details.payment_method_data.clone(),
|
payment_method_data: payment_details.payment_method_data.clone(),
|
||||||
customer_acceptance: payment_details.customer_acceptance.clone(),
|
customer_acceptance: payment_details.customer_acceptance.clone(),
|
||||||
payment_type: payment_details.payment_type,
|
payment_type: payment_details.payment_type,
|
||||||
|
payment_token: payment_details.payment_token.clone(),
|
||||||
};
|
};
|
||||||
payments_api_client::PaymentsApiClient::confirm_payment(
|
payments_api_client::PaymentsApiClient::confirm_payment(
|
||||||
state,
|
state,
|
||||||
|
|||||||
Reference in New Issue
Block a user