Purchase new subscription
Flow
![](https://files.readme.io/b55dee0-Billing_Page_Flow30.png)
Purchasing a new subscription is triggered whenever a user intent to purchase a main subscription, an app, SMS or any other add-on in the product.
Plan subscription and app subscription have the same implementation
Step by step
Select product
The purchase process begins when a user initiates a purchase. The platform then manages the flow by guiding the user to the product's pricing page. Upon selecting a specific purchasable, the user is redirected to the billing app's checkout form.
Checkout form
The checkout form is part of the billing app and is responsible for presenting a summary of the purchase, including:
- Product to be purchased
- Amount and price
- Payment terms
- Confirmation Call-to-Action (CTA)
The checkout form should receive the following parameters:
- Cart items (cart_items): A (JSON formatted) list with the products to purchase details:
- name - The name of the product to purchase
- billing_period - monthly/annually or single_charge
- currency - the currency identified for the business (USD, EUR, GPB)
- purchasable_price_uid - the code of the item to purchase
- price - the price of the product
- Brand host (brand_host) - the domain the user came from.
- Cancel URL (cu): A URL to redirect the user in case of cancellation or failure during the purchase flow. The Cancel URL varies from flow to flow. For example, buying an app will typically redirect the user back to the app market; purchasing a subscription from the account page will redirect to the account page. When implementing a billing app, you must enable the user to cancel the process. When that happens, the billing app should redirect the user to the Cancel URL.
- Success URL (su): A URL to redirect the user to upon successful completion of the purchase. The Success URL varies from flow to flow. For example, buying an app will typically redirect the user back to the app info page; purchasing a subscription from the account page will redirect to the account page. After a successful operation, the user must be redirected to the Success URL.
Payment completed
Once the user confirms the purchase, the billing app initiates the billing process. The partner's billing system then handles the business's charging for the newly purchased item, completing the transaction.
Create subscription
Upon confirming the charge, the billing app creates a new subscription using the Create Subscription API.
An example of how to call the Create Subscription API, with the purchasable_price_uid received from the cart item:
curl --location 'https://api.vcita.biz/business/subscriptionsmng/v1/subscriptions' \
--header 'Authorization: Bearer {Business API token}' \
--header 'Content-Type: application/json' \
--data '{
"subscription": {
"purchasable_price_uid": "{Selected purchasable uid}"
}
}'
Return example:
{
"success": true,
"data": {
"subscription": {
"is_active": true,
"uid": "string",
"display_name": "string",
"updated_at": "2024-07-30T15:33:06.779Z",
"created_at": "2024-07-30T15:33:06.779Z",
"purchasable_uid": "string",
"purchase_state": "string",
"cancellation_date": "2024-07-30T15:33:06.779Z",
"expiration_date": "2024-07-30T15:33:06.779Z",
"buyer_uid": "string",
"business_uid": "string",
"purchase_price": 0,
"purchase_currency": "string",
"payment_type": "string",
"pay_per_unit": [
"string"
],
"bundled_from_subscription_uid": "string"
}
}
}
Updated about 1 month ago