mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
feat(subscription): add support to create subscription with trial plans (#9721)
Co-authored-by: Ankit Kumar Gupta <ankit.gupta.001@juspay.in> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: Gaurav Rawat <104276743+GauravRawat369@users.noreply.github.com>
This commit is contained in:
@ -5025,7 +5025,7 @@ pub enum NextActionType {
|
||||
RedirectInsidePopup,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
#[serde(tag = "type", rename_all = "snake_case")]
|
||||
pub enum NextActionData {
|
||||
/// Contains the url for redirection flow
|
||||
@ -5097,7 +5097,7 @@ pub enum NextActionData {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
#[serde(tag = "method_key")]
|
||||
pub enum IframeData {
|
||||
#[serde(rename = "threeDSMethodData")]
|
||||
@ -5115,7 +5115,7 @@ pub enum IframeData {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
pub struct ThreeDsData {
|
||||
/// ThreeDS authentication url - to initiate authentication
|
||||
pub three_ds_authentication_url: String,
|
||||
@ -5131,7 +5131,7 @@ pub struct ThreeDsData {
|
||||
pub directory_server_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
#[serde(untagged)]
|
||||
pub enum ThreeDsMethodData {
|
||||
AcsThreeDsMethodData {
|
||||
@ -5148,7 +5148,7 @@ pub enum ThreeDsMethodData {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
pub enum ThreeDsMethodKey {
|
||||
#[serde(rename = "threeDSMethodData")]
|
||||
ThreeDsMethodData,
|
||||
@ -5156,7 +5156,7 @@ pub enum ThreeDsMethodKey {
|
||||
JWT,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
pub struct PollConfigResponse {
|
||||
/// Poll Id
|
||||
pub poll_id: String,
|
||||
@ -7761,7 +7761,7 @@ pub struct GooglePayTokenizationParameters {
|
||||
pub stripe_version: Option<Secret<String>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
#[serde(tag = "wallet_name")]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum SessionToken {
|
||||
@ -7819,7 +7819,7 @@ pub struct HyperswitchVaultSessionDetails {
|
||||
pub profile_id: Secret<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub struct PazeSessionTokenResponse {
|
||||
/// Paze Client ID
|
||||
@ -7839,7 +7839,7 @@ pub struct PazeSessionTokenResponse {
|
||||
pub email_address: Option<Email>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
#[serde(untagged)]
|
||||
pub enum GpaySessionTokenResponse {
|
||||
/// Google pay response involving third party sdk
|
||||
@ -7848,7 +7848,7 @@ pub enum GpaySessionTokenResponse {
|
||||
GooglePaySession(GooglePaySessionResponse),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub struct GooglePayThirdPartySdk {
|
||||
/// Identifier for the delayed session response
|
||||
@ -7859,7 +7859,7 @@ pub struct GooglePayThirdPartySdk {
|
||||
pub sdk_next_action: SdkNextAction,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub struct GooglePaySessionResponse {
|
||||
/// The merchant info
|
||||
@ -7884,7 +7884,7 @@ pub struct GooglePaySessionResponse {
|
||||
pub secrets: Option<SecretInfoToInitiateSdk>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub struct SamsungPaySessionTokenResponse {
|
||||
/// Samsung Pay API version
|
||||
@ -7908,13 +7908,13 @@ pub struct SamsungPaySessionTokenResponse {
|
||||
pub shipping_address_required: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
pub enum SamsungPayProtocolType {
|
||||
Protocol3ds,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub struct SamsungPayMerchantPaymentInformation {
|
||||
/// Merchant name, this will be displayed on the Samsung Pay screen
|
||||
@ -7926,7 +7926,7 @@ pub struct SamsungPayMerchantPaymentInformation {
|
||||
pub country_code: api_enums::CountryAlpha2,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub struct SamsungPayAmountDetails {
|
||||
#[serde(rename = "option")]
|
||||
@ -7941,7 +7941,7 @@ pub struct SamsungPayAmountDetails {
|
||||
pub total_amount: StringMajorUnit,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
pub enum SamsungPayAmountFormat {
|
||||
/// Display the total amount only
|
||||
@ -7950,14 +7950,14 @@ pub enum SamsungPayAmountFormat {
|
||||
FormatTotalEstimatedAmount,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub struct GpayShippingAddressParameters {
|
||||
/// Is shipping phone number required
|
||||
pub phone_number_required: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub struct KlarnaSessionTokenResponse {
|
||||
/// The session token for Klarna
|
||||
@ -7985,7 +7985,7 @@ pub struct PaypalTransactionInfo {
|
||||
pub total_price: StringMajorUnit,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub struct PaypalSessionTokenResponse {
|
||||
/// Name of the connector
|
||||
@ -8000,14 +8000,14 @@ pub struct PaypalSessionTokenResponse {
|
||||
pub transaction_info: Option<PaypalTransactionInfo>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub struct OpenBankingSessionToken {
|
||||
/// The session token for OpenBanking Connectors
|
||||
pub open_banking_session_token: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub struct ApplepaySessionTokenResponse {
|
||||
/// Session object for Apple Pay
|
||||
@ -8030,7 +8030,7 @@ pub struct ApplepaySessionTokenResponse {
|
||||
pub connector_merchant_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, serde::Serialize, Clone, ToSchema)]
|
||||
#[derive(Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, Clone, ToSchema)]
|
||||
pub struct SdkNextAction {
|
||||
/// The type of next action
|
||||
pub next_action: NextActionCall,
|
||||
@ -8051,7 +8051,7 @@ pub enum NextActionCall {
|
||||
AwaitMerchantCallback,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
#[serde(untagged)]
|
||||
pub enum ApplePaySessionResponse {
|
||||
/// We get this session response, when third party sdk is involved
|
||||
@ -8090,7 +8090,7 @@ pub struct NoThirdPartySdkSessionResponse {
|
||||
pub psp_id: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
pub struct ThirdPartySdkSessionResponse {
|
||||
pub secrets: SecretInfoToInitiateSdk,
|
||||
}
|
||||
@ -8211,7 +8211,7 @@ pub struct ApplepayErrorResponse {
|
||||
pub status_message: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
pub struct AmazonPaySessionTokenResponse {
|
||||
/// Amazon Pay merchant account identifier
|
||||
pub merchant_id: String,
|
||||
@ -8235,7 +8235,7 @@ pub struct AmazonPaySessionTokenResponse {
|
||||
pub delivery_options: Vec<AmazonPayDeliveryOptions>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
pub enum AmazonPayPaymentIntent {
|
||||
/// Create a Charge Permission to authorize and capture funds at a later time
|
||||
Confirm,
|
||||
@ -9291,7 +9291,7 @@ pub struct ExtendedCardInfoResponse {
|
||||
pub payload: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
pub struct ClickToPaySessionResponse {
|
||||
pub dpa_id: String,
|
||||
pub dpa_name: String,
|
||||
@ -9951,7 +9951,7 @@ pub struct RecordAttemptErrorDetails {
|
||||
pub network_error_message: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, ToSchema)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, ToSchema)]
|
||||
pub struct NullObject;
|
||||
|
||||
impl Serialize for NullObject {
|
||||
|
||||
@ -6,7 +6,7 @@ use utoipa::ToSchema;
|
||||
use crate::{
|
||||
enums as api_enums,
|
||||
mandates::RecurringDetails,
|
||||
payments::{Address, PaymentMethodDataRequest},
|
||||
payments::{Address, NextActionData, PaymentMethodDataRequest},
|
||||
};
|
||||
|
||||
/// Request payload for creating a subscription.
|
||||
@ -216,6 +216,7 @@ pub struct ConfirmSubscriptionPaymentDetails {
|
||||
pub payment_method_type: Option<api_enums::PaymentMethodType>,
|
||||
pub payment_method_data: PaymentMethodDataRequest,
|
||||
pub customer_acceptance: Option<CustomerAcceptance>,
|
||||
pub payment_type: Option<api_enums::PaymentType>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
@ -224,6 +225,7 @@ pub struct CreateSubscriptionPaymentDetails {
|
||||
pub setup_future_usage: Option<api_enums::FutureUsage>,
|
||||
pub capture_method: Option<api_enums::CaptureMethod>,
|
||||
pub authentication_type: Option<api_enums::AuthenticationType>,
|
||||
pub payment_type: Option<api_enums::PaymentType>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
@ -236,6 +238,7 @@ pub struct PaymentDetails {
|
||||
pub return_url: Option<common_utils::types::Url>,
|
||||
pub capture_method: Option<api_enums::CaptureMethod>,
|
||||
pub authentication_type: Option<api_enums::AuthenticationType>,
|
||||
pub payment_type: Option<api_enums::PaymentType>,
|
||||
}
|
||||
|
||||
// Creating new type for PaymentRequest API call as usage of api_models::PaymentsRequest will result in invalid payment request during serialization
|
||||
@ -247,6 +250,7 @@ pub struct CreatePaymentsRequestData {
|
||||
pub customer_id: Option<common_utils::id_type::CustomerId>,
|
||||
pub billing: Option<Address>,
|
||||
pub shipping: Option<Address>,
|
||||
pub profile_id: Option<common_utils::id_type::ProfileId>,
|
||||
pub setup_future_usage: Option<api_enums::FutureUsage>,
|
||||
pub return_url: Option<common_utils::types::Url>,
|
||||
pub capture_method: Option<api_enums::CaptureMethod>,
|
||||
@ -257,10 +261,12 @@ pub struct CreatePaymentsRequestData {
|
||||
pub struct ConfirmPaymentsRequestData {
|
||||
pub billing: Option<Address>,
|
||||
pub shipping: Option<Address>,
|
||||
pub profile_id: Option<common_utils::id_type::ProfileId>,
|
||||
pub payment_method: api_enums::PaymentMethod,
|
||||
pub payment_method_type: Option<api_enums::PaymentMethodType>,
|
||||
pub payment_method_data: PaymentMethodDataRequest,
|
||||
pub customer_acceptance: Option<CustomerAcceptance>,
|
||||
pub payment_type: Option<api_enums::PaymentType>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, ToSchema)]
|
||||
@ -271,6 +277,7 @@ pub struct CreateAndConfirmPaymentsRequestData {
|
||||
pub confirm: bool,
|
||||
pub billing: Option<Address>,
|
||||
pub shipping: Option<Address>,
|
||||
pub profile_id: Option<common_utils::id_type::ProfileId>,
|
||||
pub setup_future_usage: Option<api_enums::FutureUsage>,
|
||||
pub return_url: Option<common_utils::types::Url>,
|
||||
pub capture_method: Option<api_enums::CaptureMethod>,
|
||||
@ -279,6 +286,7 @@ pub struct CreateAndConfirmPaymentsRequestData {
|
||||
pub payment_method_type: Option<api_enums::PaymentMethodType>,
|
||||
pub payment_method_data: Option<PaymentMethodDataRequest>,
|
||||
pub customer_acceptance: Option<CustomerAcceptance>,
|
||||
pub payment_type: Option<api_enums::PaymentType>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
@ -287,13 +295,17 @@ pub struct PaymentResponseData {
|
||||
pub status: api_enums::IntentStatus,
|
||||
pub amount: MinorUnit,
|
||||
pub currency: api_enums::Currency,
|
||||
pub profile_id: Option<common_utils::id_type::ProfileId>,
|
||||
pub connector: Option<String>,
|
||||
pub payment_method_id: Option<Secret<String>>,
|
||||
pub return_url: Option<common_utils::types::Url>,
|
||||
pub next_action: Option<NextActionData>,
|
||||
pub payment_experience: Option<api_enums::PaymentExperience>,
|
||||
pub error_code: Option<String>,
|
||||
pub error_message: Option<String>,
|
||||
pub payment_method_type: Option<api_enums::PaymentMethodType>,
|
||||
pub client_secret: Option<Secret<String>>,
|
||||
pub payment_type: Option<api_enums::PaymentType>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
@ -304,6 +316,7 @@ pub struct CreateMitPaymentRequestData {
|
||||
pub customer_id: Option<common_utils::id_type::CustomerId>,
|
||||
pub recurring_details: Option<RecurringDetails>,
|
||||
pub off_session: Option<bool>,
|
||||
pub profile_id: Option<common_utils::id_type::ProfileId>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
@ -452,7 +465,7 @@ pub struct Invoice {
|
||||
pub currency: api_enums::Currency,
|
||||
|
||||
/// Status of the invoice.
|
||||
pub status: String,
|
||||
pub status: common_enums::connector_enums::InvoiceStatus,
|
||||
}
|
||||
|
||||
impl ApiEventMetric for ConfirmSubscriptionResponse {}
|
||||
|
||||
Reference in New Issue
Block a user