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
Field | Description |
---|---|
customer_id | This is the customer_id you get while creating a customer |
plan_id | This is the plan_id you get while creating a subscription plan |
reference | This is your reference field for your own internal use. |
start_date | This is the date you want the subscription to begin |
redirect_url | This is the URL your customer will be redirected to after successful payment. |
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",
"redirect_url":"https://example.com/order/1"
}
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"
}
Updated 2 days ago