Skip to content

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

docs(subscriptions): add subscription endpoint in api-ref docs (#9954)

Jaganed57cd0f2e9f
diff --git a/api-reference/docs.json b/api-reference/docs.json
index fa64c38d54..23868956fa 100644
--- a/api-reference/docs.json
+++ b/api-reference/docs.json
@@ -234,6 +234,18 @@
{
"group": "Schemas",
"pages": ["v1/schemas/outgoing--webhook"]
+ },
+ {
+ "group": "Subscriptions",
+ "pages": [
+ "v1/subscriptions/create",
+ "v1/subscriptions/confirm",
+ "v1/subscriptions/create-and-confirm",
+ "v1/subscriptions/update",
+ "v1/subscriptions/get",
+ "v1/subscriptions/get-plans",
+ "v1/subscriptions/estimate"
+ ]
}
]
}
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index 5faceaf5ae..617dea4b44 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -6895,13 +6895,70 @@
"examples": {
"Create and confirm subscription": {
"value": {
- "billing_details": {
- "email": "[email protected]",
- "name": "John Doe"
+ "billing": {
+ "address": {
+ "city": "San Fransico",
+ "country": "US",
+ "first_name": "joseph",
+ "last_name": "Doe",
+ "line1": "1467",
+ "line2": "Harrison Street",
+ "line3": "Harrison Street",
+ "state": "California",
+ "zip": "94122"
+ },
+ "phone": {
+ "country_code": "+1",
+ "number": "123456789"
+ }
},
"customer_id": "cust_123456789",
- "payment_method_id": "pm_1234567890",
- "plan_id": "plan_monthly_basic"
+ "description": "Hello this is description",
+ "item_price_id": "standard-plan-USD-Monthly",
+ "merchant_reference_id": "mer_ref_123456789",
+ "payment_details": {
+ "authentication_type": "no_three_ds",
+ "capture_method": "automatic",
+ "customer_acceptance": {
+ "acceptance_type": "online",
+ "accepted_at": "1963-05-03T04:07:52.723Z",
+ "online": {
+ "ip_address": "127.0.0.1",
+ "user_agent": "amet irure esse"
+ }
+ },
+ "payment_method": "card",
+ "payment_method_data": {
+ "card": {
+ "card_cvc": "737",
+ "card_exp_month": "03",
+ "card_exp_year": "2030",
+ "card_holder_name": "CLBRW dffdg",
+ "card_number": "4000000000000002"
+ }
+ },
+ "payment_method_type": "credit",
+ "payment_type": "setup_mandate",
+ "return_url": "https://google.com",
+ "setup_future_usage": "off_session"
+ },
+ "shipping": {
+ "address": {
+ "city": "Banglore",
+ "country": "US",
+ "first_name": "joseph",
+ "last_name": "doe",
+ "line1": "sdsdfsdf",
+ "line2": "hsgdbhd",
+ "line3": "alsksoe",
+ "state": "zsaasdas",
+ "zip": "571201"
+ },
+ "phone": {
+ "country_code": "+1",
+ "number": "123456789"
+ }
+ }
}
}
}
@@ -6963,11 +7020,13 @@
"Create subscription": {
"value": {
"customer_id": "cust_123456789",
- "metadata": {
- "source": "web_app"
- },
- "plan_id": "plan_monthly_basic",
- "trial_days": 7
+ "item_price_id": "standard-plan-USD-Monthly",
+ "payment_details": {
+ "authentication_type": "no_three_ds",
+ "capture_method": "automatic",
+ "return_url": "https://google.com",
+ "setup_future_usage": "off_session"
+ }
}
}
}
@@ -7037,9 +7096,61 @@
"examples": {
"Confirm subscription": {
"value": {
- "client_secret": "seti_1234567890_secret_abcdef",
- "payment_method_id": "pm_1234567890",
- "return_url": "https://example.com/return"
+ "payment_details": {
+ "billing": {
+ "address": {
+ "city": "San Fransico",
+ "country": "US",
+ "first_name": "joseph",
+ "last_name": "Doe",
+ "line1": "1467",
+ "line2": "Harrison Street",
+ "line3": "Harrison Street",
+ "state": "California",
+ "zip": "94122"
+ },
+ "phone": {
+ "country_code": "+1",
+ "number": "123456789"
+ }
+ },
+ "customer_acceptance": {
+ "acceptance_type": "online",
+ "accepted_at": "1963-05-03T04:07:52.723Z",
+ "online": {
+ "ip_address": "127.0.0.1",
+ "user_agent": "amet irure esse"
+ }
+ },
+ "payment_method": "card",
+ "payment_method_data": {
+ "card": {
+ "card_cvc": "737",
+ "card_exp_month": "03",
+ "card_exp_year": "2030",
+ "card_holder_name": "CLBRW dffdg",
+ "card_number": "4111111111111111"
+ }
+ },
+ "payment_method_type": "credit",
+ "shipping": {
+ "address": {
+ "city": "Banglore",
+ "country": "US",
+ "first_name": "joseph",
+ "last_name": "doe",
+ "line1": "sdsdfsdf",
+ "line2": "hsgdbhd",
+ "line3": "alsksoe",
+ "state": "zsaasdas",
+ "zip": "571201"
+ },
+ "phone": {
+ "country_code": "+1",
+ "number": "123456789"
+ }
+ }
+ }
}
}
}
@@ -7165,11 +7276,8 @@
"examples": {
"Update subscription": {
"value": {
- "metadata": {
- "updated_reason": "plan_upgrade"
- },
- "plan_id": "plan_yearly_premium",
- "proration_behavior": "create_prorations"
+ "item_price_id": "cbdemo_enterprise-suite-monthly",
+ "plan_id": "cbdemo_enterprise-suite"
}
}
}
@@ -7257,7 +7365,7 @@
],
"responses": {
"200": {
- "description": "Plans retrieved successfully",
+ "description": "List of available subscription plans",
"content": {
"application/json": {
"schema": {
@@ -17332,7 +17440,7 @@
"items": {
"$ref": "#/components/schemas/GpayAllowedPaymentMethods"
},
- "description": "List of the allowed payment meythods"
+ "description": "List of the allowed payment methods"
},
"transaction_info": {
"$ref": "#/components/schemas/GpayTransactionInfo"
diff --git a/api-reference/v1/subscriptions/confirm.mdx b/api-reference/v1/subscriptions/confirm.mdx
new file mode 100644
index 0000000000..a7559a633d
--- /dev/null
+++ b/api-reference/v1/subscriptions/confirm.mdx
@@ -0,0 +1,3 @@
+---
+openapi: post /subscriptions/{subscription_id}/confirm
+---
\ No newline at end of file
diff --git a/api-reference/v1/subscriptions/create-and-confirm.mdx b/api-reference/v1/subscriptions/create-and-confirm.mdx
new file mode 100644
index 0000000000..9dedfb8f90
--- /dev/null
+++ b/api-reference/v1/subscriptions/create-and-confirm.mdx
@@ -0,0 +1,3 @@
+---
+openapi: post /subscriptions
+---
\ No newline at end of file
diff --git a/api-reference/v1/subscriptions/create.mdx b/api-reference/v1/subscriptions/create.mdx
new file mode 100644
index 0000000000..3582228797
--- /dev/null
+++ b/api-reference/v1/subscriptions/create.mdx
@@ -0,0 +1,3 @@
+---
+openapi: post /subscriptions/create
+---
\ No newline at end of file
diff --git a/api-reference/v1/subscriptions/estimate.mdx b/api-reference/v1/subscriptions/estimate.mdx
new file mode 100644
index 0000000000..5dda9ba23c
--- /dev/null
+++ b/api-reference/v1/subscriptions/estimate.mdx
@@ -0,0 +1,3 @@
+---
+openapi: get /subscriptions/estimate
+---
\ No newline at end of file
diff --git a/api-reference/v1/subscriptions/get-plans.mdx b/api-reference/v1/subscriptions/get-plans.mdx
new file mode 100644
index 0000000000..cb9b37ecea
--- /dev/null
+++ b/api-reference/v1/subscriptions/get-plans.mdx
@@ -0,0 +1,3 @@
+---
+openapi: get /subscriptions/plans
+---
\ No newline at end of file
diff --git a/api-reference/v1/subscriptions/get.mdx b/api-reference/v1/subscriptions/get.mdx
new file mode 100644
index 0000000000..d3872f5df6
--- /dev/null
+++ b/api-reference/v1/subscriptions/get.mdx
@@ -0,0 +1,3 @@
+---
+openapi: get /subscriptions/{subscription_id}
+---
\ No newline at end of file
diff --git a/api-reference/v1/subscriptions/update.mdx b/api-reference/v1/subscriptions/update.mdx
new file mode 100644
index 0000000000..2dfbbf7720
--- /dev/null
+++ b/api-reference/v1/subscriptions/update.mdx
@@ -0,0 +1,3 @@
+---
+openapi: put /subscriptions/{subscription_id}/update
+---
\ No newline at end of file
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index 08c05a2c85..b9afba40a2 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -12619,7 +12619,7 @@
"items": {
"$ref": "#/components/schemas/GpayAllowedPaymentMethods"
},
- "description": "List of the allowed payment meythods"
+ "description": "List of the allowed payment methods"
},
"transaction_info": {
"$ref": "#/components/schemas/GpayTransactionInfo"
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index dc2e48a314..4390b638f3 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -7908,7 +7908,7 @@ pub struct GooglePaySessionResponse {
pub email_required: bool,
/// Shipping address parameters
pub shipping_address_parameters: GpayShippingAddressParameters,
- /// List of the allowed payment meythods
+ /// List of the allowed payment methods
pub allowed_payment_methods: Vec<GpayAllowedPaymentMethods>,
/// The transaction info Google Pay requires
pub transaction_info: GpayTransactionInfo,
@@ -7939,6 +7939,7 @@ pub struct SamsungPaySessionTokenResponse {
/// Payment protocol type
pub protocol: SamsungPayProtocolType,
/// List of supported card brands
+ #[schema(value_type = Vec<String>)]
pub allowed_brands: Vec<String>,
/// Is billing address required to be collected from wallet
pub billing_address_required: bool,
diff --git a/crates/openapi/src/routes/subscriptions.rs b/crates/openapi/src/routes/subscriptions.rs
index 881e1196e8..4baaf8942e 100644
--- a/crates/openapi/src/routes/subscriptions.rs
+++ b/crates/openapi/src/routes/subscriptions.rs
@@ -12,12 +12,69 @@ use utoipa;
examples((
"Create and confirm subscription" = (
value = json!({
+ "item_price_id": "standard-plan-USD-Monthly",
"customer_id": "cust_123456789",
- "plan_id": "plan_monthly_basic",
- "payment_method_id": "pm_1234567890",
- "billing_details": {
- "name": "John Doe",
- "email": "[email protected]"
+ "description": "Hello this is description",
+ "merchant_reference_id": "mer_ref_123456789",
+ "shipping": {
+ "address": {
+ "state": "zsaasdas",
+ "city": "Banglore",
+ "country": "US",
+ "line1": "sdsdfsdf",
+ "line2": "hsgdbhd",
+ "line3": "alsksoe",
+ "zip": "571201",
+ "first_name": "joseph",
+ "last_name": "doe"
+ },
+ "phone": {
+ "number": "123456789",
+ "country_code": "+1"
+ }
+ },
+ "billing": {
+ "address": {
+ "line1": "1467",
+ "line2": "Harrison Street",
+ "line3": "Harrison Street",
+ "city": "San Fransico",
+ "state": "California",
+ "zip": "94122",
+ "country": "US",
+ "first_name": "joseph",
+ "last_name": "Doe"
+ },
+ "phone": {
+ "number": "123456789",
+ "country_code": "+1"
+ }
+ },
+ "payment_details": {
+ "payment_type": "setup_mandate",
+ "payment_method": "card",
+ "payment_method_type": "credit",
+ "payment_method_data": {
+ "card": {
+ "card_number": "4000000000000002",
+ "card_exp_month": "03",
+ "card_exp_year": "2030",
+ "card_holder_name": "CLBRW dffdg",
+ "card_cvc": "737"
+ }
+ },
+ "authentication_type": "no_three_ds",
+ "setup_future_usage": "off_session",
+ "capture_method": "automatic",
+ "return_url": "https://google.com",
+ "customer_acceptance": {
+ "acceptance_type": "online",
+ "accepted_at": "1963-05-03T04:07:52.723Z",
+ "online": {
+ "ip_address": "127.0.0.1",
+ "user_agent": "amet irure esse"
+ }
+ }
}
})
)
@@ -49,10 +106,12 @@ pub async fn create_and_confirm_subscription() {}
"Create subscription" = (
value = json!({
"customer_id": "cust_123456789",
- "plan_id": "plan_monthly_basic",
- "trial_days": 7,
- "metadata": {
- "source": "web_app"
+ "item_price_id": "standard-plan-USD-Monthly",
+ "payment_details": {
+ "authentication_type": "no_three_ds",
+ "setup_future_usage": "off_session",
+ "capture_method": "automatic",
+ "return_url": "https://google.com"
}
})
)
@@ -87,9 +146,61 @@ pub async fn create_subscription() {}
examples((
"Confirm subscription" = (
value = json!({
- "payment_method_id": "pm_1234567890",
- "client_secret": "seti_1234567890_secret_abcdef",
- "return_url": "https://example.com/return"
+ "payment_details": {
+ "shipping": {
+ "address": {
+ "state": "zsaasdas",
+ "city": "Banglore",
+ "country": "US",
+ "line1": "sdsdfsdf",
+ "line2": "hsgdbhd",
+ "line3": "alsksoe",
+ "zip": "571201",
+ "first_name": "joseph",
+ "last_name": "doe"
+ },
+ "phone": {
+ "number": "123456789",
+ "country_code": "+1"
+ }
+ },
+ "billing": {
+ "address": {
+ "line1": "1467",
+ "line2": "Harrison Street",
+ "line3": "Harrison Street",
+ "city": "San Fransico",
+ "state": "California",
+ "zip": "94122",
+ "country": "US",
+ "first_name": "joseph",
+ "last_name": "Doe"
+ },
+ "phone": {
+ "number": "123456789",
+ "country_code": "+1"
+ }
+ },
+ "payment_method": "card",
+ "payment_method_type": "credit",
+ "payment_method_data": {
+ "card": {
+ "card_number": "4111111111111111",
+ "card_exp_month": "03",
+ "card_exp_year": "2030",
+ "card_holder_name": "CLBRW dffdg",
+ "card_cvc": "737"
+ }
+ },
+ "customer_acceptance": {
+ "acceptance_type": "online",
+ "accepted_at": "1963-05-03T04:07:52.723Z",
+ "online": {
+ "ip_address": "127.0.0.1",
+ "user_agent": "amet irure esse"
+ }
+ }
+ }
})
)
))
@@ -141,11 +252,8 @@ pub async fn get_subscription() {}
examples((
"Update subscription" = (
value = json!({
- "plan_id": "plan_yearly_premium",
- "proration_behavior": "create_prorations",
- "metadata": {
- "updated_reason": "plan_upgrade"
- }
+ "plan_id":"cbdemo_enterprise-suite",
+ "item_price_id":"cbdemo_enterprise-suite-monthly"
})
)
))
@@ -174,7 +282,7 @@ pub async fn update_subscription() {}
("product_id" = Option<String>, Query, description = "Filter by product ID")
),
responses(
- (status = 200, description = "Plans retrieved successfully", body = Vec<GetPlansResponse>),
+ (status = 200, description = "List of available subscription plans", body = Vec<GetPlansResponse>),
(status = 400, description = "Invalid query parameters")
),
tag = "Subscriptions",