Unsubscribe from a plan
How to cancel a customer's subscription.
This API will help you to cancel a customer's subscription to a plan.
A subscription_id is required which is passed as a URL parameter in the request.
Unsubscribe Request
import requests
subscription_id = '<subscription_id>'
url =f`https://sandbox.intasend.com/api/v1/subscriptions/{subscription_id}/unsubscribe/`
headers = {
"accept": "application/json",
"content-type": "application/json",
"Authorization": "Bearer ISSecretKey_test_624...."
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
<?php
require_once('vendor/autoload.php');
$base_url = 'https://sandbox.intasend.com/api/v1/subscriptions/'
$client = new \GuzzleHttp\Client();
$subscription_id = '<subscription_id>'
$url = $base_url . $subscription_id . '/unsubscribe/';
$response = $client->request('POST', $url, [
'headers' => [
'Authorization' => 'Bearer ISSecretKey_test1251...',
'accept' => 'application/json',
'content-type' => 'application/json',
],
]);
$data = json_decode($response->getBody());
Unsubscribe Response
{
"subscription_id": "MRLD7QG",
"reference": null,
"customer": {
"customer_id": "7PQW9QL",
"email": "[email protected]",
"first_name": "FELIX",
"last_name": "CHERUIYOT",
"reference": "REVPORTAL-01",
"address": "30 N GOULD ST STE R",
"city": "Sheridan",
"state": "Wyoming",
"zipcode": "82801",
"country": "KE",
"created_at": "2023-09-18T22:07:10.671126+03:00",
"updated_at": "2023-09-18T22:07:10.671150+03:00"
},
"plan": {
"name": "default",
"plan_id": "9NR58RJ",
"frequency": 1,
"frequency_unit": "M",
"billing_cycles": 11,
"currency": "USD",
"amount": "101.00",
"created_at": "2023-07-17T16:52:19.623919+03:00",
"updated_at": "2023-07-17T16:52:20.397645+03:00"
},
"payment_method": "CARD-PAYMENT",
"status": "CANCELED",
"start_date": "2023-09-24",
"completed_cycles": 1,
"setup_url": "https://sandbox.intasend.com/subscriptions/charge/MRLD7QG:1qpn0v:aRJnLhKMw0oaUQcWJQepqFxv7JyC2Csksf975-p29x0",
"created_at": "2023-09-24T11:36:44.922271+03:00",
"updated_at": "2023-10-09T12:57:25.711987+03:00"
}
Updated about 1 year ago