Purchase new subscription

Flow

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:

  1. Cart items (cart_items): A (JSON formatted) list with the products to purchase details:
    1. name - The name of the product to purchase
    2. billing_period - monthly/annually or single_charge
    3. currency - the currency identified for the business (USD, EUR, GPB)
    4. purchasable_price_uid - the code of the item to purchase
    5. price - the price of the product
  2. Brand host (brand_host) - the domain the user came from.
  3. 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.
  4. 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"
    }
  }
}