Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
docs(subscription): add open api specs (#9884)
Jaganb42fbdb50f72
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex 34e8827ec2..5faceaf5ae 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -6866,6 +6866,507 @@}]}+ },+ "/subscriptions": {+ "post": {+ "tags": [+ "Subscriptions"+ ],+ "summary": "Subscription - Create and Confirm",+ "description": "Creates and confirms a subscription in a single request.",+ "operationId": "Create and Confirm Subscription",+ "parameters": [+ {+ "name": "X-Profile-Id",+ "in": "header",+ "description": "Profile ID for authentication",+ "required": true,+ "schema": {+ "type": "string"+ }+ }+ ],+ "requestBody": {+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/CreateAndConfirmSubscriptionRequest"+ },+ "examples": {+ "Create and confirm subscription": {+ "value": {+ "billing_details": {+ "email": "[email protected]",+ "name": "John Doe"+ },+ "customer_id": "cust_123456789",+ "payment_method_id": "pm_1234567890",+ "plan_id": "plan_monthly_basic"+ }+ }+ }+ }+ },+ "required": true+ },+ "responses": {+ "200": {+ "description": "Subscription created and confirmed successfully",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/SubscriptionResponse"+ }+ }+ }+ },+ "400": {+ "description": "Invalid subscription data"+ },+ "404": {+ "description": "Customer or plan not found"+ }+ },+ "security": [+ {+ "api_key": []+ }+ ]+ }+ },+ "/subscriptions/create": {+ "post": {+ "tags": [+ "Subscriptions"+ ],+ "summary": "Subscription - Create",+ "description": "Creates a subscription that requires separate confirmation.",+ "operationId": "Create Subscription",+ "parameters": [+ {+ "name": "X-Profile-Id",+ "in": "header",+ "description": "Profile ID for authentication",+ "required": true,+ "schema": {+ "type": "string"+ }+ }+ ],+ "requestBody": {+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/CreateSubscriptionRequest"+ },+ "examples": {+ "Create subscription": {+ "value": {+ "customer_id": "cust_123456789",+ "metadata": {+ "source": "web_app"+ },+ "plan_id": "plan_monthly_basic",+ "trial_days": 7+ }+ }+ }+ }+ },+ "required": true+ },+ "responses": {+ "200": {+ "description": "Subscription created successfully",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/SubscriptionResponse"+ }+ }+ }+ },+ "400": {+ "description": "Invalid subscription data"+ },+ "404": {+ "description": "Customer or plan not found"+ }+ },+ "security": [+ {+ "api_key": []+ }+ ]+ }+ },+ "/subscriptions/{subscription_id}/confirm": {+ "post": {+ "tags": [+ "Subscriptions"+ ],+ "summary": "Subscription - Confirm",+ "description": "Confirms a previously created subscription.",+ "operationId": "Confirm Subscription",+ "parameters": [+ {+ "name": "subscription_id",+ "in": "path",+ "description": "The unique identifier for the subscription",+ "required": true,+ "schema": {+ "type": "string"+ }+ },+ {+ "name": "X-Profile-Id",+ "in": "header",+ "description": "Profile ID for authentication",+ "required": true,+ "schema": {+ "type": "string"+ }+ }+ ],+ "requestBody": {+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/ConfirmSubscriptionRequest"+ },+ "examples": {+ "Confirm subscription": {+ "value": {+ "client_secret": "seti_1234567890_secret_abcdef",+ "payment_method_id": "pm_1234567890",+ "return_url": "https://example.com/return"+ }+ }+ }+ }+ },+ "required": true+ },+ "responses": {+ "200": {+ "description": "Subscription confirmed successfully",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/SubscriptionResponse"+ }+ }+ }+ },+ "400": {+ "description": "Invalid confirmation data"+ },+ "404": {+ "description": "Subscription not found"+ },+ "409": {+ "description": "Subscription already confirmed"+ }+ },+ "security": [+ {+ "api_key": []+ },+ {+ "client_secret": []+ }+ ]+ }+ },+ "/subscriptions/{subscription_id}": {+ "get": {+ "tags": [+ "Subscriptions"+ ],+ "summary": "Subscription - Retrieve",+ "description": "Retrieves subscription details by ID.",+ "operationId": "Retrieve Subscription",+ "parameters": [+ {+ "name": "subscription_id",+ "in": "path",+ "description": "The unique identifier for the subscription",+ "required": true,+ "schema": {+ "type": "string"+ }+ },+ {+ "name": "X-Profile-Id",+ "in": "header",+ "description": "Profile ID for authentication",+ "required": true,+ "schema": {+ "type": "string"+ }+ }+ ],+ "responses": {+ "200": {+ "description": "Subscription retrieved successfully",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/SubscriptionResponse"+ }+ }+ }+ },+ "404": {+ "description": "Subscription not found"+ }+ },+ "security": [+ {+ "api_key": []+ }+ ]+ }+ },+ "/subscriptions/{subscription_id}/update": {+ "put": {+ "tags": [+ "Subscriptions"+ ],+ "summary": "Subscription - Update",+ "description": "Updates an existing subscription.",+ "operationId": "Update Subscription",+ "parameters": [+ {+ "name": "subscription_id",+ "in": "path",+ "description": "The unique identifier for the subscription",+ "required": true,+ "schema": {+ "type": "string"+ }+ },+ {+ "name": "X-Profile-Id",+ "in": "header",+ "description": "Profile ID for authentication",+ "required": true,+ "schema": {+ "type": "string"+ }+ }+ ],+ "requestBody": {+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/UpdateSubscriptionRequest"+ },+ "examples": {+ "Update subscription": {+ "value": {+ "metadata": {+ "updated_reason": "plan_upgrade"+ },+ "plan_id": "plan_yearly_premium",+ "proration_behavior": "create_prorations"+ }+ }+ }+ }+ },+ "required": true+ },+ "responses": {+ "200": {+ "description": "Subscription updated successfully",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/SubscriptionResponse"+ }+ }+ }+ },+ "400": {+ "description": "Invalid update data"+ },+ "404": {+ "description": "Subscription not found"+ }+ },+ "security": [+ {+ "api_key": []+ }+ ]+ }+ },+ "/subscriptions/plans": {+ "get": {+ "tags": [+ "Subscriptions"+ ],+ "summary": "Subscription - Get Plans",+ "description": "Retrieves available subscription plans.",+ "operationId": "Get Subscription Plans",+ "parameters": [+ {+ "name": "X-Profile-Id",+ "in": "header",+ "description": "Profile ID for authentication",+ "required": true,+ "schema": {+ "type": "string"+ }+ },+ {+ "name": "limit",+ "in": "query",+ "description": "Number of plans to retrieve",+ "required": false,+ "schema": {+ "type": "integer",+ "format": "int32",+ "nullable": true,+ "minimum": 0+ }+ },+ {+ "name": "offset",+ "in": "query",+ "description": "Number of plans to skip",+ "required": false,+ "schema": {+ "type": "integer",+ "format": "int32",+ "nullable": true,+ "minimum": 0+ }+ },+ {+ "name": "product_id",+ "in": "query",+ "description": "Filter by product ID",+ "required": false,+ "schema": {+ "type": "string",+ "nullable": true+ }+ }+ ],+ "responses": {+ "200": {+ "description": "Plans retrieved successfully",+ "content": {+ "application/json": {+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/GetPlansResponse"+ }+ }+ }+ }+ },+ "400": {+ "description": "Invalid query parameters"+ }+ },+ "security": [+ {+ "api_key": []+ },+ {+ "client_secret": []+ }+ ]+ }+ },+ "/subscriptions/estimate": {+ "get": {+ "tags": [+ "Subscriptions"+ ],+ "summary": "Subscription - Get Estimate",+ "description": "Gets pricing estimate for a subscription.",+ "operationId": "Get Subscription Estimate",+ "parameters": [+ {+ "name": "X-Profile-Id",+ "in": "header",+ "description": "Profile ID for authentication",+ "required": true,+ "schema": {+ "type": "string"+ }+ },+ {+ "name": "plan_id",+ "in": "query",+ "description": "Plan ID for estimation",+ "required": true,+ "schema": {+ "type": "string"+ }+ },+ {+ "name": "customer_id",+ "in": "query",+ "description": "Customer ID for personalized pricing",+ "required": false,+ "schema": {+ "type": "string",+ "nullable": true+ }+ },+ {+ "name": "coupon_id",+ "in": "query",+ "description": "Coupon ID to apply discount",+ "required": false,+ "schema": {+ "type": "string",+ "nullable": true+ }+ },+ {+ "name": "trial_days",+ "in": "query",+ "description": "Number of trial days",+ "required": false,+ "schema": {+ "type": "integer",+ "format": "int32",+ "nullable": true,+ "minimum": 0+ }+ }+ ],+ "responses": {+ "200": {+ "description": "Estimate retrieved successfully",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/EstimateSubscriptionResponse"+ }+ }+ }+ },+ "400": {+ "description": "Invalid estimation parameters"+ },+ "404": {+ "description": "Plan not found"+ }+ },+ "security": [+ {+ "api_key": []+ }+ ]+ }}},"components": {@@ -12236,6 +12737,10 @@}}},+ "ClientSecret": {+ "type": "string",+ "description": "For Client based calls, SDK will use the client_secret\\nin order to call /payment_methods\\nClient secret will be generated whenever a new\\npayment method is created"+ },"Comparison": {"type": "object","description": "Represents a single comparison condition.",@@ -12275,6 +12780,77 @@"greater_than_equal"]},+ "ConfirmSubscriptionPaymentDetails": {+ "type": "object",+ "required": [+ "payment_method",+ "payment_method_data"+ ],+ "properties": {+ "shipping": {+ "allOf": [+ {+ "$ref": "#/components/schemas/Address"+ }+ ],+ "nullable": true+ },+ "billing": {+ "allOf": [+ {+ "$ref": "#/components/schemas/Address"+ }+ ],+ "nullable": true+ },+ "payment_method": {+ "$ref": "#/components/schemas/PaymentMethod"+ },+ "payment_method_type": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentMethodType"+ }+ ],+ "nullable": true+ },+ "payment_method_data": {+ "$ref": "#/components/schemas/PaymentMethodDataRequest"+ },+ "customer_acceptance": {+ "allOf": [+ {+ "$ref": "#/components/schemas/CustomerAcceptance"+ }+ ],+ "nullable": true+ },+ "payment_type": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentType"+ }+ ],+ "nullable": true+ }+ }+ },+ "ConfirmSubscriptionRequest": {+ "type": "object",+ "required": [+ "payment_details"+ ],+ "properties": {+ "client_secret": {+ "type": "string",+ "description": "This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDK",+ "nullable": true+ },+ "payment_details": {+ "$ref": "#/components/schemas/ConfirmSubscriptionPaymentDetails"+ }+ }+ },"Connector": {"type": "string","enum": [@@ -13491,6 +14067,57 @@"ZWE"]},+ "CreateAndConfirmSubscriptionRequest": {+ "type": "object",+ "required": [+ "item_price_id",+ "customer_id",+ "payment_details"+ ],+ "properties": {+ "plan_id": {+ "type": "string",+ "description": "Identifier for the associated plan_id.",+ "nullable": true+ },+ "item_price_id": {+ "type": "string",+ "description": "Identifier for the associated item_price_id for the subscription."+ },+ "coupon_code": {+ "type": "string",+ "description": "Identifier for the coupon code for the subscription.",+ "nullable": true+ },+ "customer_id": {+ "$ref": "#/components/schemas/CustomerId"+ },+ "billing": {+ "allOf": [+ {+ "$ref": "#/components/schemas/Address"+ }+ ],+ "nullable": true+ },+ "shipping": {+ "allOf": [+ {+ "$ref": "#/components/schemas/Address"+ }+ ],+ "nullable": true+ },+ "payment_details": {+ "$ref": "#/components/schemas/PaymentDetails"+ },+ "merchant_reference_id": {+ "type": "string",+ "description": "Merchant specific Unique identifier.",+ "nullable": true+ }+ }+ },"CreateApiKeyRequest": {"type": "object","description": "The request body for creating an API Key.",@@ -13522,52 +14149,148 @@"type": "object","description": "The response body for creating an API Key.","required": [- "key_id",- "merchant_id",- "name",- "api_key",- "created",- "expiration"+ "key_id",+ "merchant_id",+ "name",+ "api_key",+ "created",+ "expiration"+ ],+ "properties": {+ "key_id": {+ "type": "string",+ "description": "The identifier for the API Key.",+ "example": "5hEEqkgJUyuxgSKGArHA4mWSnX",+ "maxLength": 64+ },+ "merchant_id": {+ "type": "string",+ "description": "The identifier for the Merchant Account.",+ "example": "y3oqhf46pyzuxjbcn2giaqnb44",+ "maxLength": 64+ },+ "name": {+ "type": "string",+ "description": "The unique name for the API Key to help you identify it.",+ "example": "Sandbox integration key",+ "maxLength": 64+ },+ "description": {+ "type": "string",+ "description": "The description to provide more context about the API Key.",+ "example": "Key used by our developers to integrate with the sandbox environment",+ "nullable": true,+ "maxLength": 256+ },+ "api_key": {+ "type": "string",+ "description": "The plaintext API Key used for server-side API access. Ensure you store the API Key\nsecurely as you will not be able to see it again.",+ "maxLength": 128+ },+ "created": {+ "type": "string",+ "format": "date-time",+ "description": "The time at which the API Key was created.",+ "example": "2022-09-10T10:11:12Z"+ },+ "expiration": {+ "$ref": "#/components/schemas/ApiKeyExpiration"+ }+ }+ },+ "CreateSubscriptionPaymentDetails": {+ "type": "object",+ "required": [+ "return_url"+ ],+ "properties": {+ "return_url": {+ "type": "string",+ "description": "The url to which user must be redirected to after completion of the purchase"+ },+ "setup_future_usage": {+ "allOf": [+ {+ "$ref": "#/components/schemas/FutureUsage"+ }+ ],+ "nullable": true+ },+ "capture_method": {+ "allOf": [+ {+ "$ref": "#/components/schemas/CaptureMethod"+ }+ ],+ "nullable": true+ },+ "authentication_type": {+ "allOf": [+ {+ "$ref": "#/components/schemas/AuthenticationType"+ }+ ],+ "nullable": true+ },+ "payment_type": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentType"+ }+ ],+ "nullable": true+ }+ }+ },+ "CreateSubscriptionRequest": {+ "type": "object",+ "description": "Request payload for creating a subscription.\n\nThis struct captures details required to create a subscription,\nincluding plan, profile, merchant connector, and optional customer info.",+ "required": [+ "item_price_id",+ "customer_id",+ "payment_details"],"properties": {- "key_id": {+ "merchant_reference_id": {"type": "string",- "description": "The identifier for the API Key.",- "example": "5hEEqkgJUyuxgSKGArHA4mWSnX",- "maxLength": 64+ "description": "Merchant specific Unique identifier.",+ "nullable": true},- "merchant_id": {+ "item_price_id": {"type": "string",- "description": "The identifier for the Merchant Account.",- "example": "y3oqhf46pyzuxjbcn2giaqnb44",- "maxLength": 64+ "description": "Identifier for the associated item_price_id for the subscription."},- "name": {+ "plan_id": {"type": "string",- "description": "The unique name for the API Key to help you identify it.",- "example": "Sandbox integration key",- "maxLength": 64+ "description": "Identifier for the subscription plan.",+ "nullable": true},- "description": {+ "coupon_code": {"type": "string",- "description": "The description to provide more context about the API Key.",- "example": "Key used by our developers to integrate with the sandbox environment",- "nullable": true,- "maxLength": 256+ "description": "Optional coupon code applied to the subscription.",+ "nullable": true},- "api_key": {- "type": "string",- "description": "The plaintext API Key used for server-side API access. Ensure you store the API Key\nsecurely as you will not be able to see it again.",- "maxLength": 128+ "customer_id": {+ "$ref": "#/components/schemas/CustomerId"},- "created": {- "type": "string",- "format": "date-time",- "description": "The time at which the API Key was created.",- "example": "2022-09-10T10:11:12Z"+ "payment_details": {+ "$ref": "#/components/schemas/CreateSubscriptionPaymentDetails"},- "expiration": {- "$ref": "#/components/schemas/ApiKeyExpiration"+ "billing": {+ "allOf": [+ {+ "$ref": "#/components/schemas/Address"+ }+ ],+ "nullable": true+ },+ "shipping": {+ "allOf": [+ {+ "$ref": "#/components/schemas/Address"+ }+ ],+ "nullable": true}}},@@ -14079,6 +14802,10 @@"gaming_console"]},+ "CustomerId": {+ "type": "string",+ "description": "A type for customer_id that can be used for customer ids"+ },"CustomerPaymentMethod": {"type": "object","required": [@@ -15156,6 +15883,73 @@"soft_decline"]},+ "EstimateSubscriptionQuery": {+ "type": "object",+ "required": [+ "item_price_id"+ ],+ "properties": {+ "plan_id": {+ "type": "string",+ "description": "Identifier for the associated subscription plan.",+ "nullable": true+ },+ "item_price_id": {+ "type": "string",+ "description": "Identifier for the associated item_price_id for the subscription."+ },+ "coupon_code": {+ "type": "string",+ "description": "Identifier for the coupon code for the subscription.",+ "nullable": true+ }+ }+ },+ "EstimateSubscriptionResponse": {+ "type": "object",+ "required": [+ "amount",+ "currency",+ "line_items"+ ],+ "properties": {+ "amount": {+ "$ref": "#/components/schemas/MinorUnit"+ },+ "currency": {+ "$ref": "#/components/schemas/Currency"+ },+ "plan_id": {+ "type": "string",+ "description": "Identifier for the associated plan_id.",+ "nullable": true+ },+ "item_price_id": {+ "type": "string",+ "description": "Identifier for the associated item_price_id for the subscription.",+ "nullable": true+ },+ "coupon_code": {+ "type": "string",+ "description": "Identifier for the coupon code for the subscription.",+ "nullable": true+ },+ "customer_id": {+ "allOf": [+ {+ "$ref": "#/components/schemas/CustomerId"+ }+ ],+ "nullable": true+ },+ "line_items": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/SubscriptionLineItem"+ }+ }+ }+ },"EventClass": {"type": "string","enum": [@@ -16250,6 +17044,54 @@}}},+ "GetPlansQuery": {+ "type": "object",+ "properties": {+ "client_secret": {+ "type": "string",+ "description": "This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDK",+ "nullable": true+ },+ "limit": {+ "type": "integer",+ "format": "int32",+ "nullable": true,+ "minimum": 0+ },+ "offset": {+ "type": "integer",+ "format": "int32",+ "nullable": true,+ "minimum": 0+ }+ }+ },+ "GetPlansResponse": {+ "type": "object",+ "required": [+ "plan_id",+ "name",+ "price_id"+ ],+ "properties": {+ "plan_id": {+ "type": "string"+ },+ "name": {+ "type": "string"+ },+ "description": {+ "type": "string",+ "nullable": true+ },+ "price_id": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/SubscriptionPlanPrices"+ }+ }+ }+ },"GiftCardAdditionalData": {"oneOf": [{@@ -17380,6 +18222,81 @@}}},+ "Invoice": {+ "type": "object",+ "required": [+ "id",+ "subscription_id",+ "merchant_id",+ "profile_id",+ "merchant_connector_id",+ "customer_id",+ "amount",+ "currency",+ "status"+ ],+ "properties": {+ "id": {+ "$ref": "#/components/schemas/InvoiceId"+ },+ "subscription_id": {+ "$ref": "#/components/schemas/SubscriptionId"+ },+ "merchant_id": {+ "$ref": "#/components/schemas/MerchantId"+ },+ "profile_id": {+ "$ref": "#/components/schemas/ProfileId"+ },+ "merchant_connector_id": {+ "$ref": "#/components/schemas/MerchantConnectorAccountId"+ },+ "payment_intent_id": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentId"+ }+ ],+ "nullable": true+ },+ "payment_method_id": {+ "type": "string",+ "description": "Identifier for Payment Method",+ "example": "pm_01926c58bc6e77c09e809964e72af8c8",+ "nullable": true+ },+ "customer_id": {+ "$ref": "#/components/schemas/CustomerId"+ },+ "amount": {+ "$ref": "#/components/schemas/MinorUnit"+ },+ "currency": {+ "$ref": "#/components/schemas/Currency"+ },+ "status": {+ "$ref": "#/components/schemas/InvoiceStatus"+ }+ }+ },+ "InvoiceId": {+ "type": "string",+ "description": "A type for invoice_id that can be used for invoice ids"+ },+ "InvoiceStatus": {+ "type": "string",+ "enum": [+ "invoice_created",+ "payment_pending",+ "payment_pending_timeout",+ "payment_succeeded",+ "payment_failed",+ "payment_canceled",+ "invoice_paid",+ "manual_review",+ "voided"+ ]+ },"IssuerData": {"type": "object","description": "Represents data about the issuer used in the 3DS decision rule.",@@ -18562,6 +19479,10 @@"5661"]},+ "MerchantConnectorAccountId": {+ "type": "string",+ "description": "A type for merchant_connector_id that can be used for merchant_connector_account ids"+ },"MerchantConnectorCreate": {"type": "object","description": "Create a new Merchant Connector for the merchant account. The connector could be a payment processor / facilitator / acquirer or specialized services like Fraud / Accounting etc.\"",@@ -19350,6 +20271,10 @@},"additionalProperties": false},+ "MerchantId": {+ "type": "string",+ "description": "A type for merchant_id that can be used for merchant ids"+ },"MerchantProductType": {"type": "string","enum": [@@ -21118,8 +22043,82 @@"format": "int64","description": "The amount of the payment in minor units (e.g., cents for USD)."},- "currency": {- "$ref": "#/components/schemas/Currency"+ "currency": {+ "$ref": "#/components/schemas/Currency"+ }+ }+ },+ "PaymentDetails": {+ "type": "object",+ "properties": {+ "payment_method": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentMethod"+ }+ ],+ "nullable": true+ },+ "payment_method_type": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentMethodType"+ }+ ],+ "nullable": true+ },+ "payment_method_data": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentMethodDataRequest"+ }+ ],+ "nullable": true+ },+ "setup_future_usage": {+ "allOf": [+ {+ "$ref": "#/components/schemas/FutureUsage"+ }+ ],+ "nullable": true+ },+ "customer_acceptance": {+ "allOf": [+ {+ "$ref": "#/components/schemas/CustomerAcceptance"+ }+ ],+ "nullable": true+ },+ "return_url": {+ "type": "string",+ "description": "The url to which user must be redirected to after completion of the purchase",+ "nullable": true+ },+ "capture_method": {+ "allOf": [+ {+ "$ref": "#/components/schemas/CaptureMethod"+ }+ ],+ "nullable": true+ },+ "authentication_type": {+ "allOf": [+ {+ "$ref": "#/components/schemas/AuthenticationType"+ }+ ],+ "nullable": true+ },+ "payment_type": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentType"+ }+ ],+ "nullable": true}}},@@ -22901,6 +23900,113 @@"propertyName": "payment_processing_details_at"}},+ "PaymentResponseData": {+ "type": "object",+ "required": [+ "payment_id",+ "status",+ "amount",+ "currency"+ ],+ "properties": {+ "payment_id": {+ "$ref": "#/components/schemas/PaymentId"+ },+ "status": {+ "$ref": "#/components/schemas/IntentStatus"+ },+ "amount": {+ "$ref": "#/components/schemas/MinorUnit"+ },+ "currency": {+ "$ref": "#/components/schemas/Currency"+ },+ "profile_id": {+ "allOf": [+ {+ "$ref": "#/components/schemas/ProfileId"+ }+ ],+ "nullable": true+ },+ "connector": {+ "type": "string",+ "nullable": true+ },+ "payment_method_id": {+ "type": "string",+ "description": "Identifier for Payment Method",+ "example": "pm_01926c58bc6e77c09e809964e72af8c8",+ "nullable": true+ },+ "return_url": {+ "type": "string",+ "description": "The url to which user must be redirected to after completion of the purchase",+ "nullable": true+ },+ "next_action": {+ "allOf": [+ {+ "$ref": "#/components/schemas/NextActionData"+ }+ ],+ "nullable": true+ },+ "payment_experience": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentExperience"+ }+ ],+ "nullable": true+ },+ "error_code": {+ "type": "string",+ "nullable": true+ },+ "error_message": {+ "type": "string",+ "nullable": true+ },+ "payment_method_type": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentMethodType"+ }+ ],+ "nullable": true+ },+ "client_secret": {+ "type": "string",+ "description": "This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDK",+ "nullable": true+ },+ "billing": {+ "allOf": [+ {+ "$ref": "#/components/schemas/Address"+ }+ ],+ "nullable": true+ },+ "shipping": {+ "allOf": [+ {+ "$ref": "#/components/schemas/Address"+ }+ ],+ "nullable": true+ },+ "payment_type": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentType"+ }+ ],+ "nullable": true+ }+ }+ },"PaymentRetrieveBody": {"type": "object","properties": {@@ -28554,6 +29660,15 @@}}},+ "PeriodUnit": {+ "type": "string",+ "enum": [+ "Day",+ "Week",+ "Month",+ "Year"+ ]+ },"PhoneDetails": {"type": "object","properties": {@@ -32338,6 +33453,176 @@},"additionalProperties": false},+ "SubscriptionId": {+ "type": "string",+ "description": "A type for subscription_id that can be used for subscription ids"+ },+ "SubscriptionLineItem": {+ "type": "object",+ "required": [+ "item_id",+ "item_type",+ "description",+ "amount",+ "currency",+ "quantity"+ ],+ "properties": {+ "item_id": {+ "type": "string",+ "description": "Unique identifier for the line item."+ },+ "item_type": {+ "type": "string",+ "description": "Type of the line item."+ },+ "description": {+ "type": "string",+ "description": "Description of the line item."+ },+ "amount": {+ "$ref": "#/components/schemas/MinorUnit"+ },+ "currency": {+ "$ref": "#/components/schemas/Currency"+ },+ "quantity": {+ "type": "integer",+ "format": "int64",+ "description": "Quantity of the line item."+ }+ }+ },+ "SubscriptionPlanPrices": {+ "type": "object",+ "required": [+ "price_id",+ "amount",+ "currency",+ "interval",+ "interval_count"+ ],+ "properties": {+ "price_id": {+ "type": "string"+ },+ "plan_id": {+ "type": "string",+ "nullable": true+ },+ "amount": {+ "$ref": "#/components/schemas/MinorUnit"+ },+ "currency": {+ "$ref": "#/components/schemas/Currency"+ },+ "interval": {+ "$ref": "#/components/schemas/PeriodUnit"+ },+ "interval_count": {+ "type": "integer",+ "format": "int64"+ },+ "trial_period": {+ "type": "integer",+ "format": "int64",+ "nullable": true+ },+ "trial_period_unit": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PeriodUnit"+ }+ ],+ "nullable": true+ }+ }+ },+ "SubscriptionResponse": {+ "type": "object",+ "description": "Response payload returned after successfully creating a subscription.\n\nIncludes details such as subscription ID, status, plan, merchant, and customer info.",+ "required": [+ "id",+ "status",+ "profile_id",+ "merchant_id",+ "customer_id"+ ],+ "properties": {+ "id": {+ "$ref": "#/components/schemas/SubscriptionId"+ },+ "merchant_reference_id": {+ "type": "string",+ "description": "Merchant specific Unique identifier.",+ "nullable": true+ },+ "status": {+ "$ref": "#/components/schemas/SubscriptionStatus"+ },+ "plan_id": {+ "type": "string",+ "description": "Identifier for the associated subscription plan.",+ "nullable": true+ },+ "item_price_id": {+ "type": "string",+ "description": "Identifier for the associated item_price_id for the subscription.",+ "nullable": true+ },+ "profile_id": {+ "$ref": "#/components/schemas/ProfileId"+ },+ "client_secret": {+ "type": "string",+ "description": "This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDK",+ "nullable": true+ },+ "merchant_id": {+ "$ref": "#/components/schemas/MerchantId"+ },+ "coupon_code": {+ "type": "string",+ "description": "Optional coupon code applied to this subscription.",+ "nullable": true+ },+ "customer_id": {+ "$ref": "#/components/schemas/CustomerId"+ },+ "payment": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PaymentResponseData"+ }+ ],+ "nullable": true+ },+ "invoice": {+ "allOf": [+ {+ "$ref": "#/components/schemas/Invoice"+ }+ ],+ "nullable": true+ }+ }+ },+ "SubscriptionStatus": {+ "type": "string",+ "description": "Possible states of a subscription lifecycle.\n\n- `Created`: Subscription was created but not yet activated.\n- `Active`: Subscription is currently active.\n- `InActive`: Subscription is inactive.\n- `Pending`: Subscription is pending activation.\n- `Trial`: Subscription is in a trial period.\n- `Paused`: Subscription is paused.\n- `Unpaid`: Subscription is unpaid.\n- `Onetime`: Subscription is a one-time payment.\n- `Cancelled`: Subscription has been cancelled.\n- `Failed`: Subscription has failed.",+ "enum": [+ "active",+ "created",+ "in_active",+ "pending",+ "trial",+ "paused",+ "unpaid",+ "onetime",+ "cancelled",+ "failed"+ ]+ },"SuccessBasedRoutingConfig": {"type": "object","required": [@@ -33157,6 +34442,23 @@}}},+ "UpdateSubscriptionRequest": {+ "type": "object",+ "required": [+ "plan_id",+ "item_price_id"+ ],+ "properties": {+ "plan_id": {+ "type": "string",+ "description": "Identifier for the associated plan_id."+ },+ "item_price_id": {+ "type": "string",+ "description": "Identifier for the associated item_price_id for the subscription."+ }+ }+ },"UpiAdditionalData": {"oneOf": [{@@ -34542,6 +35844,10 @@{"name": "Authentication","description": "Create and manage authentication"+ },+ {+ "name": "Subscriptions",+ "description": "Subscription management and billing endpoints"}]}\ No newline at end of filediff --git a/crates/api_models/src/subscription.rs b/crates/api_models/src/subscription.rsindex d4ca7fd4e4..9bde18ef04 100644--- a/crates/api_models/src/subscription.rs+++ b/crates/api_models/src/subscription.rs@@ -1,10 +1,21 @@+use common_enums::connector_enums::InvoiceStatus;use common_types::payments::CustomerAcceptance;-use common_utils::{events::ApiEventMetric, types::MinorUnit};+use common_utils::{+ events::ApiEventMetric,+ id_type::{+ CustomerId, InvoiceId, MerchantConnectorAccountId, MerchantId, PaymentId, ProfileId,+ SubscriptionId,+ },+ types::{MinorUnit, Url},+};use masking::Secret;use utoipa::ToSchema;use crate::{- enums as api_enums,+ enums::{+ AuthenticationType, CaptureMethod, Currency, FutureUsage, IntentStatus, PaymentExperience,+ PaymentMethod, PaymentMethodType, PaymentType,+ },mandates::RecurringDetails,payments::{Address, NextActionData, PaymentMethodDataRequest},};@@ -28,7 +39,7 @@ pub struct CreateSubscriptionRequest {pub coupon_code: Option<String>,/// customer ID associated with this subscription.- pub customer_id: common_utils::id_type::CustomerId,+ pub customer_id: CustomerId,/// payment details for the subscription.pub payment_details: CreateSubscriptionPaymentDetails,@@ -46,7 +57,7 @@ pub struct CreateSubscriptionRequest {#[derive(Debug, Clone, serde::Serialize, ToSchema)]pub struct SubscriptionResponse {/// Unique identifier for the subscription.- pub id: common_utils::id_type::SubscriptionId,+ pub id: SubscriptionId,/// Merchant specific Unique identifier.pub merchant_reference_id: Option<String>,@@ -61,19 +72,20 @@ pub struct SubscriptionResponse {pub item_price_id: Option<String>,/// Associated profile ID.- pub profile_id: common_utils::id_type::ProfileId,+ pub profile_id: ProfileId,- /// Optional client secret used for secure client-side interactions.+ #[schema(value_type = Option<String>)]+ /// This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDKpub client_secret: Option<Secret<String>>,/// Merchant identifier owning this subscription.- pub merchant_id: common_utils::id_type::MerchantId,+ pub merchant_id: MerchantId,/// Optional coupon code applied to this subscription.pub coupon_code: Option<String>,/// Optional customer ID associated with this subscription.- pub customer_id: common_utils::id_type::CustomerId,+ pub customer_id: CustomerId,/// Payment details for the invoice.pub payment: Option<PaymentResponseData>,@@ -125,15 +137,15 @@ impl SubscriptionResponse {/// By default, `client_secret`, `coupon_code`, and `customer` fields are `None`.#[allow(clippy::too_many_arguments)]pub fn new(- id: common_utils::id_type::SubscriptionId,+ id: SubscriptionId,merchant_reference_id: Option<String>,status: SubscriptionStatus,plan_id: Option<String>,item_price_id: Option<String>,- profile_id: common_utils::id_type::ProfileId,- merchant_id: common_utils::id_type::MerchantId,+ profile_id: ProfileId,+ merchant_id: MerchantId,client_secret: Option<Secret<String>>,- customer_id: common_utils::id_type::CustomerId,+ customer_id: CustomerId,payment: Option<PaymentResponseData>,invoice: Option<Invoice>,) -> Self {@@ -154,7 +166,7 @@ impl SubscriptionResponse {}}-#[derive(Debug, Clone, serde::Serialize)]+#[derive(Debug, Clone, serde::Serialize, ToSchema)]pub struct GetPlansResponse {pub plan_id: String,pub name: String,@@ -162,19 +174,19 @@ pub struct GetPlansResponse {pub price_id: Vec<SubscriptionPlanPrices>,}-#[derive(Debug, Clone, serde::Serialize)]+#[derive(Debug, Clone, serde::Serialize, ToSchema)]pub struct SubscriptionPlanPrices {pub price_id: String,pub plan_id: Option<String>,pub amount: MinorUnit,- pub currency: api_enums::Currency,+ pub currency: Currency,pub interval: PeriodUnit,pub interval_count: i64,pub trial_period: Option<i64>,pub trial_period_unit: Option<PeriodUnit>,}-#[derive(Debug, Clone, serde::Serialize)]+#[derive(Debug, Clone, serde::Serialize, ToSchema)]pub enum PeriodUnit {Day,Week,@@ -182,7 +194,8 @@ pub enum PeriodUnit {Year,}-#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]+/// For Client based calls, SDK will use the client_secret\nin order to call /payment_methods\nClient secret will be generated whenever a new\npayment method is created+#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, ToSchema)]pub struct ClientSecret(String);impl ClientSecret {@@ -199,8 +212,10 @@ impl ClientSecret {}}-#[derive(serde::Deserialize, serde::Serialize, Debug)]+#[derive(serde::Deserialize, serde::Serialize, Debug, ToSchema)]pub struct GetPlansQuery {+ #[schema(value_type = Option<String>)]+ /// This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDKpub client_secret: Option<ClientSecret>,pub limit: Option<u32>,pub offset: Option<u32>,@@ -215,33 +230,37 @@ impl ApiEventMetric for GetPlansResponse {}pub struct ConfirmSubscriptionPaymentDetails {pub shipping: Option<Address>,pub billing: Option<Address>,- pub payment_method: api_enums::PaymentMethod,- pub payment_method_type: Option<api_enums::PaymentMethodType>,+ pub payment_method: PaymentMethod,+ pub payment_method_type: Option<PaymentMethodType>,pub payment_method_data: PaymentMethodDataRequest,pub customer_acceptance: Option<CustomerAcceptance>,- pub payment_type: Option<api_enums::PaymentType>,+ pub payment_type: Option<PaymentType>,}#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]pub struct CreateSubscriptionPaymentDetails {- pub return_url: common_utils::types::Url,- 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>,+ /// The url to which user must be redirected to after completion of the purchase+ #[schema(value_type = String)]+ pub return_url: Url,+ pub setup_future_usage: Option<FutureUsage>,+ pub capture_method: Option<CaptureMethod>,+ pub authentication_type: Option<AuthenticationType>,+ pub payment_type: Option<PaymentType>,}#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]pub struct PaymentDetails {- pub payment_method: Option<api_enums::PaymentMethod>,- pub payment_method_type: Option<api_enums::PaymentMethodType>,+ pub payment_method: Option<PaymentMethod>,+ pub payment_method_type: Option<PaymentMethodType>,pub payment_method_data: Option<PaymentMethodDataRequest>,- pub setup_future_usage: Option<api_enums::FutureUsage>,+ pub setup_future_usage: Option<FutureUsage>,pub customer_acceptance: Option<CustomerAcceptance>,- 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>,+ /// The url to which user must be redirected to after completion of the purchase+ #[schema(value_type = Option<String>)]+ pub return_url: Option<Url>,+ pub capture_method: Option<CaptureMethod>,+ pub authentication_type: Option<AuthenticationType>,+ pub payment_type: Option<PaymentType>,}// Creating new type for PaymentRequest API call as usage of api_models::PaymentsRequest will result in invalid payment request during serialization@@ -249,84 +268,95 @@ pub struct PaymentDetails {#[derive(Debug, Clone, serde::Serialize, ToSchema)]pub struct CreatePaymentsRequestData {pub amount: MinorUnit,- pub currency: api_enums::Currency,- pub customer_id: Option<common_utils::id_type::CustomerId>,+ pub currency: Currency,+ pub customer_id: Option<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>,- pub authentication_type: Option<api_enums::AuthenticationType>,+ pub profile_id: Option<ProfileId>,+ pub setup_future_usage: Option<FutureUsage>,+ /// The url to which user must be redirected to after completion of the purchase+ #[schema(value_type = Option<String>)]+ pub return_url: Option<Url>,+ pub capture_method: Option<CaptureMethod>,+ pub authentication_type: Option<AuthenticationType>,}#[derive(Debug, Clone, serde::Serialize, ToSchema)]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 profile_id: Option<ProfileId>,+ pub payment_method: PaymentMethod,+ pub payment_method_type: Option<PaymentMethodType>,pub payment_method_data: PaymentMethodDataRequest,pub customer_acceptance: Option<CustomerAcceptance>,- pub payment_type: Option<api_enums::PaymentType>,+ pub payment_type: Option<PaymentType>,}#[derive(Debug, Clone, serde::Serialize, ToSchema)]pub struct CreateAndConfirmPaymentsRequestData {pub amount: MinorUnit,- pub currency: api_enums::Currency,- pub customer_id: Option<common_utils::id_type::CustomerId>,+ pub currency: Currency,+ pub customer_id: Option<CustomerId>,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>,- pub authentication_type: Option<api_enums::AuthenticationType>,- pub payment_method: Option<api_enums::PaymentMethod>,- pub payment_method_type: Option<api_enums::PaymentMethodType>,+ pub profile_id: Option<ProfileId>,+ pub setup_future_usage: Option<FutureUsage>,+ /// The url to which user must be redirected to after completion of the purchase+ #[schema(value_type = Option<String>)]+ pub return_url: Option<Url>,+ pub capture_method: Option<CaptureMethod>,+ pub authentication_type: Option<AuthenticationType>,+ pub payment_method: Option<PaymentMethod>,+ pub payment_method_type: Option<PaymentMethodType>,pub payment_method_data: Option<PaymentMethodDataRequest>,pub customer_acceptance: Option<CustomerAcceptance>,- pub payment_type: Option<api_enums::PaymentType>,+ pub payment_type: Option<PaymentType>,}#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]pub struct PaymentResponseData {- pub payment_id: common_utils::id_type::PaymentId,- pub status: api_enums::IntentStatus,+ pub payment_id: PaymentId,+ pub status: IntentStatus,pub amount: MinorUnit,- pub currency: api_enums::Currency,- pub profile_id: Option<common_utils::id_type::ProfileId>,+ pub currency: Currency,+ pub profile_id: Option<ProfileId>,pub connector: Option<String>,+ /// Identifier for Payment Method+ #[schema(value_type = Option<String>, example = "pm_01926c58bc6e77c09e809964e72af8c8")]pub payment_method_id: Option<Secret<String>>,- pub return_url: Option<common_utils::types::Url>,+ /// The url to which user must be redirected to after completion of the purchase+ #[schema(value_type = Option<String>)]+ pub return_url: Option<Url>,pub next_action: Option<NextActionData>,- pub payment_experience: Option<api_enums::PaymentExperience>,+ pub payment_experience: Option<PaymentExperience>,pub error_code: Option<String>,pub error_message: Option<String>,- pub payment_method_type: Option<api_enums::PaymentMethodType>,+ pub payment_method_type: Option<PaymentMethodType>,+ #[schema(value_type = Option<String>)]+ /// This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDKpub client_secret: Option<Secret<String>>,pub billing: Option<Address>,pub shipping: Option<Address>,- pub payment_type: Option<api_enums::PaymentType>,+ pub payment_type: Option<PaymentType>,}#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]pub struct CreateMitPaymentRequestData {pub amount: MinorUnit,- pub currency: api_enums::Currency,+ pub currency: Currency,pub confirm: bool,- pub customer_id: Option<common_utils::id_type::CustomerId>,+ pub customer_id: Option<CustomerId>,pub recurring_details: Option<RecurringDetails>,pub off_session: Option<bool>,- pub profile_id: Option<common_utils::id_type::ProfileId>,+ pub profile_id: Option<ProfileId>,}#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]pub struct ConfirmSubscriptionRequest {- /// Client secret for SDK based interaction.+ #[schema(value_type = Option<String>)]+ /// This is a token which expires after 15 minutes, used from the client to authenticate and create sessions from the SDKpub client_secret: Option<ClientSecret>,/// Payment details for the invoice.@@ -354,11 +384,11 @@ pub struct CreateAndConfirmSubscriptionRequest {/// Identifier for the associated item_price_id for the subscription.pub item_price_id: String,- /// Idenctifier for the coupon code for the subscription.+ /// Identifier for the coupon code for the subscription.pub coupon_code: Option<String>,/// Identifier for customer.- pub customer_id: common_utils::id_type::CustomerId,+ pub customer_id: CustomerId,/// Billing address for the subscription.pub billing: Option<Address>,@@ -388,7 +418,7 @@ impl ApiEventMetric for CreateAndConfirmSubscriptionRequest {}#[derive(Debug, Clone, serde::Serialize, ToSchema)]pub struct ConfirmSubscriptionResponse {/// Unique identifier for the subscription.- pub id: common_utils::id_type::SubscriptionId,+ pub id: SubscriptionId,/// Merchant specific Unique identifier.pub merchant_reference_id: Option<String>,@@ -406,13 +436,13 @@ pub struct ConfirmSubscriptionResponse {pub coupon: Option<String>,/// Associated profile ID.- pub profile_id: common_utils::id_type::ProfileId,+ pub profile_id: ProfileId,/// Payment details for the invoice.pub payment: Option<PaymentResponseData>,/// Customer ID associated with this subscription.- pub customer_id: Option<common_utils::id_type::CustomerId>,+ pub customer_id: Option<CustomerId>,/// Invoice Details for the subscription.pub invoice: Option<Invoice>,@@ -424,37 +454,38 @@ pub struct ConfirmSubscriptionResponse {#[derive(Debug, Clone, serde::Serialize, ToSchema)]pub struct Invoice {/// Unique identifier for the invoice.- pub id: common_utils::id_type::InvoiceId,+ pub id: InvoiceId,/// Unique identifier for the subscription.- pub subscription_id: common_utils::id_type::SubscriptionId,+ pub subscription_id: SubscriptionId,/// Identifier for the merchant.- pub merchant_id: common_utils::id_type::MerchantId,+ pub merchant_id: MerchantId,/// Identifier for the profile.- pub profile_id: common_utils::id_type::ProfileId,+ pub profile_id: ProfileId,/// Identifier for the merchant connector account.- pub merchant_connector_id: common_utils::id_type::MerchantConnectorAccountId,+ pub merchant_connector_id: MerchantConnectorAccountId,/// Identifier for the Payment.- pub payment_intent_id: Option<common_utils::id_type::PaymentId>,+ pub payment_intent_id: Option<PaymentId>,- /// Identifier for the Payment method.+ /// Identifier for Payment Method+ #[schema(value_type = Option<String>, example = "pm_01926c58bc6e77c09e809964e72af8c8")]pub payment_method_id: Option<String>,/// Identifier for the Customer.- pub customer_id: common_utils::id_type::CustomerId,+ pub customer_id: CustomerId,/// Invoice amount.pub amount: MinorUnit,/// Currency for the invoice payment.- pub currency: api_enums::Currency,+ pub currency: Currency,/// Status of the invoice.- pub status: common_enums::connector_enums::InvoiceStatus,+ pub status: InvoiceStatus,}impl ApiEventMetric for ConfirmSubscriptionResponse {}@@ -477,7 +508,7 @@ pub struct EstimateSubscriptionQuery {/// Identifier for the associated item_price_id for the subscription.pub item_price_id: String,- /// Idenctifier for the coupon code for the subscription.+ /// Identifier for the coupon code for the subscription.pub coupon_code: Option<String>,}@@ -488,15 +519,15 @@ pub struct EstimateSubscriptionResponse {/// Estimated amount to be charged for the invoice.pub amount: MinorUnit,/// Currency for the amount.- pub currency: api_enums::Currency,+ pub currency: Currency,/// Identifier for the associated plan_id.pub plan_id: Option<String>,/// Identifier for the associated item_price_id for the subscription.pub item_price_id: Option<String>,- /// Idenctifier for the coupon code for the subscription.+ /// Identifier for the coupon code for the subscription.pub coupon_code: Option<String>,/// Identifier for customer.- pub customer_id: Option<common_utils::id_type::CustomerId>,+ pub customer_id: Option<CustomerId>,pub line_items: Vec<SubscriptionLineItem>,}@@ -511,7 +542,7 @@ pub struct SubscriptionLineItem {/// Amount for the line item.pub amount: MinorUnit,/// Currency for the line item- pub currency: common_enums::Currency,+ pub currency: Currency,/// Quantity of the line item.pub quantity: i64,}diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rsindex 8d736e56b6..7253d5be1b 100644--- a/crates/openapi/src/openapi.rs+++ b/crates/openapi/src/openapi.rs@@ -66,7 +66,8 @@ Never share your secret api keys. Keep them guarded and secure.(name = "payment link", description = "Create payment link"),(name = "Routing", description = "Create and manage routing configurations"),(name = "Event", description = "Manage events"),- (name = "Authentication", description = "Create and manage authentication")+ (name = "Authentication", description = "Create and manage authentication"),+ (name = "Subscriptions", description = "Subscription management and billing endpoints")),// The paths will be displayed in the same order as they are registered herepaths(@@ -222,6 +223,15 @@ Never share your secret api keys. Keep them guarded and secure.// Routes for platform accountroutes::platform::create_platform_account,++ //Routes for subscriptions+ routes::subscriptions::create_and_confirm_subscription,+ routes::subscriptions::create_subscription,+ routes::subscriptions::confirm_subscription,+ routes::subscriptions::get_subscription,+ routes::subscriptions::update_subscription,+ routes::subscriptions::get_subscription_plans,+ routes::subscriptions::get_estimate,),components(schemas(common_utils::types::MinorUnit,@@ -876,6 +886,31 @@ Never share your secret api keys. Keep them guarded and secure.api_models::open_router::PriorityLogicData,api_models::user::PlatformAccountCreateRequest,api_models::user::PlatformAccountCreateResponse,+ common_utils::id_type::CustomerId,+ common_utils::id_type::SubscriptionId,+ common_utils::id_type::MerchantId,+ common_utils::id_type::InvoiceId,+ common_utils::id_type::MerchantConnectorAccountId,+ api_models::enums::connector_enums::InvoiceStatus,+ api_models::subscription::ClientSecret,+ api_models::subscription::CreateAndConfirmSubscriptionRequest,+ api_models::subscription::CreateSubscriptionRequest,+ api_models::subscription::ConfirmSubscriptionRequest,+ api_models::subscription::UpdateSubscriptionRequest,+ api_models::subscription::SubscriptionResponse,+ api_models::subscription::GetPlansResponse,+ api_models::subscription::EstimateSubscriptionResponse,+ api_models::subscription::GetPlansQuery,+ api_models::subscription::EstimateSubscriptionQuery,+ api_models::subscription::ConfirmSubscriptionPaymentDetails,+ api_models::subscription::PaymentDetails,+ api_models::subscription::CreateSubscriptionPaymentDetails,+ api_models::subscription::SubscriptionLineItem,+ api_models::subscription::SubscriptionPlanPrices,+ api_models::subscription::PaymentResponseData,+ api_models::subscription::Invoice,+ api_models::subscription::SubscriptionStatus,+ api_models::subscription::PeriodUnit,)),modifiers(&SecurityAddon))]diff --git a/crates/openapi/src/routes.rs b/crates/openapi/src/routes.rsindex 7dcdf60571..07a979984d 100644--- a/crates/openapi/src/routes.rs+++ b/crates/openapi/src/routes.rs@@ -23,6 +23,7 @@ pub mod refunds;pub mod relay;pub mod revenue_recovery;pub mod routing;+pub mod subscriptions;pub mod three_ds_decision_rule;pub mod tokenization;pub mod webhook_events;diff --git a/crates/openapi/src/routes/subscriptions.rs b/crates/openapi/src/routes/subscriptions.rsnew file mode 100644index 0000000000..881e1196e8--- /dev/null+++ b/crates/openapi/src/routes/subscriptions.rs@@ -0,0 +1,208 @@+use serde_json::json;+use utoipa;++/// Subscription - Create and Confirm+///+/// Creates and confirms a subscription in a single request.+#[utoipa::path(+ post,+ path = "/subscriptions",+ request_body(+ content = CreateAndConfirmSubscriptionRequest,+ examples((+ "Create and confirm subscription" = (+ value = json!({+ "customer_id": "cust_123456789",+ "plan_id": "plan_monthly_basic",+ "payment_method_id": "pm_1234567890",+ "billing_details": {+ "name": "John Doe",+ "email": "[email protected]"+ }+ })+ )+ ))+ ),+ responses(+ (status = 200, description = "Subscription created and confirmed successfully", body = SubscriptionResponse),+ (status = 400, description = "Invalid subscription data"),+ (status = 404, description = "Customer or plan not found")+ ),+ params(+ ("X-Profile-Id" = String, Header, description = "Profile ID for authentication")+ ),+ tag = "Subscriptions",+ operation_id = "Create and Confirm Subscription",+ security(("api_key" = []))+)]+pub async fn create_and_confirm_subscription() {}++/// Subscription - Create+///+/// Creates a subscription that requires separate confirmation.+#[utoipa::path(+ post,+ path = "/subscriptions/create",+ request_body(+ content = CreateSubscriptionRequest,+ examples((+ "Create subscription" = (+ value = json!({+ "customer_id": "cust_123456789",+ "plan_id": "plan_monthly_basic",+ "trial_days": 7,+ "metadata": {+ "source": "web_app"+ }+ })+ )+ ))+ ),+ responses(+ (status = 200, description = "Subscription created successfully", body = SubscriptionResponse),+ (status = 400, description = "Invalid subscription data"),+ (status = 404, description = "Customer or plan not found")+ ),+ params(+ ("X-Profile-Id" = String, Header, description = "Profile ID for authentication")+ ),+ tag = "Subscriptions",+ operation_id = "Create Subscription",+ security(("api_key" = []))+)]+pub async fn create_subscription() {}++/// Subscription - Confirm+///+/// Confirms a previously created subscription.+#[utoipa::path(+ post,+ path = "/subscriptions/{subscription_id}/confirm",+ params(+ ("subscription_id" = String, Path, description = "The unique identifier for the subscription"),+ ("X-Profile-Id" = String, Header, description = "Profile ID for authentication")+ ),+ request_body(+ content = ConfirmSubscriptionRequest,+ examples((+ "Confirm subscription" = (+ value = json!({+ "payment_method_id": "pm_1234567890",+ "client_secret": "seti_1234567890_secret_abcdef",+ "return_url": "https://example.com/return"+ })+ )+ ))+ ),+ responses(+ (status = 200, description = "Subscription confirmed successfully", body = SubscriptionResponse),+ (status = 400, description = "Invalid confirmation data"),+ (status = 404, description = "Subscription not found"),+ (status = 409, description = "Subscription already confirmed")+ ),+ tag = "Subscriptions",+ operation_id = "Confirm Subscription",+ security(("api_key" = []), ("client_secret" = []))+)]+pub async fn confirm_subscription() {}++/// Subscription - Retrieve+///+/// Retrieves subscription details by ID.+#[utoipa::path(+ get,+ path = "/subscriptions/{subscription_id}",+ params(+ ("subscription_id" = String, Path, description = "The unique identifier for the subscription"),+ ("X-Profile-Id" = String, Header, description = "Profile ID for authentication")+ ),+ responses(+ (status = 200, description = "Subscription retrieved successfully", body = SubscriptionResponse),+ (status = 404, description = "Subscription not found")+ ),+ tag = "Subscriptions",+ operation_id = "Retrieve Subscription",+ security(("api_key" = []))+)]+pub async fn get_subscription() {}++/// Subscription - Update+///+/// Updates an existing subscription.+#[utoipa::path(+ put,+ path = "/subscriptions/{subscription_id}/update",+ params(+ ("subscription_id" = String, Path, description = "The unique identifier for the subscription"),+ ("X-Profile-Id" = String, Header, description = "Profile ID for authentication")+ ),+ request_body(+ content = UpdateSubscriptionRequest,+ examples((+ "Update subscription" = (+ value = json!({+ "plan_id": "plan_yearly_premium",+ "proration_behavior": "create_prorations",+ "metadata": {+ "updated_reason": "plan_upgrade"+ }+ })+ )+ ))+ ),+ responses(+ (status = 200, description = "Subscription updated successfully", body = SubscriptionResponse),+ (status = 400, description = "Invalid update data"),+ (status = 404, description = "Subscription not found")+ ),+ tag = "Subscriptions",+ operation_id = "Update Subscription",+ security(("api_key" = []))+)]+pub async fn update_subscription() {}++/// Subscription - Get Plans+///+/// Retrieves available subscription plans.+#[utoipa::path(+ get,+ path = "/subscriptions/plans",+ params(+ ("X-Profile-Id" = String, Header, description = "Profile ID for authentication"),+ ("limit" = Option<u32>, Query, description = "Number of plans to retrieve"),+ ("offset" = Option<u32>, Query, description = "Number of plans to skip"),+ ("product_id" = Option<String>, Query, description = "Filter by product ID")+ ),+ responses(+ (status = 200, description = "Plans retrieved successfully", body = Vec<GetPlansResponse>),+ (status = 400, description = "Invalid query parameters")+ ),+ tag = "Subscriptions",+ operation_id = "Get Subscription Plans",+ security(("api_key" = []), ("client_secret" = []))+)]+pub async fn get_subscription_plans() {}++/// Subscription - Get Estimate+///+/// Gets pricing estimate for a subscription.+#[utoipa::path(+ get,+ path = "/subscriptions/estimate",+ params(+ ("X-Profile-Id" = String, Header, description = "Profile ID for authentication"),+ ("plan_id" = String, Query, description = "Plan ID for estimation"),+ ("customer_id" = Option<String>, Query, description = "Customer ID for personalized pricing"),+ ("coupon_id" = Option<String>, Query, description = "Coupon ID to apply discount"),+ ("trial_days" = Option<u32>, Query, description = "Number of trial days")+ ),+ responses(+ (status = 200, description = "Estimate retrieved successfully", body = EstimateSubscriptionResponse),+ (status = 400, description = "Invalid estimation parameters"),+ (status = 404, description = "Plan not found")+ ),+ tag = "Subscriptions",+ operation_id = "Get Subscription Estimate",+ security(("api_key" = []))+)]+pub async fn get_estimate() {}