Create a Subscription

How to subscribe a customer to a subscription plan

This API will help you to subscribe a customer to a subscription plan.

Plan Fields

FieldDescription
customer_idThis is the customer_id you get while creating a customer
plan_idThis is the plan_id you get while creating a subscription plan
referenceThis is your reference field for your own internal use.
start_dateThis is the date you want the subscription to begin

Subscribe Request

import requests

url = "https://sandbox.intasend.com/api/v1/subscriptions/"

payload = {
    "customer_id": "<customer_id>",
    "reference": "string",
    "plan_id": "<plan_id>",
    "start_date": "2023-10-09"
}
headers = {
    "accept": "application/json",
    "content-type": "application/json",
    "Authorization": "Bearer ISSecretKey_test_......"
}

response = requests.post(url, json=payload, headers=headers)

print(response.get("setup_url"))
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://sandbox.intasend.com/api/v1/subscriptions/', [
  'body' => '{"customer_id":"<customer_id>","reference":"string","plan_id":"<plan_id>","start_date":"2023-10-11"}',
  'headers' => [
    'Authorization' => 'Bearer ISSecretKey_test1251...',
    'accept' => 'application/json',
    'content-type' => 'application/json',
  ],
]);

$data = json_decode($response->getBody());
echo $data->setup_url;

Subscribe Response

A secure link is generated which you can share with your customer to complete payment. The link is available as "setup_url" field in the JSON response.

Once the customer clicks on the link, IntaSend provides a guide on how to complete payment and notify both you and the customers on the status of the payment. On successful payment, the subscription is active.

{
  "subscription_id": "string",
  "customer_id": "string",
  "reference": "string",
  "plan_id": "string",
  "status": "string",
  "start_date": "2023-10-09",
  "setup_url": "string",
  "created_at": "2023-10-09T06:57:02.018Z",
  "updated_at": "2023-10-09T06:57:02.018Z"
}

What’s Next

Unsubscribe from a plan