Preview a plan change
curl --request POST \
--url https://api.useplinth.com/v1/subscriptions/{id}/preview-change \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"plan_id": "pln_01JABC...",
"quantity": 1
}
'import requests
url = "https://api.useplinth.com/v1/subscriptions/{id}/preview-change"
payload = {
"plan_id": "pln_01JABC...",
"quantity": 1
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({plan_id: 'pln_01JABC...', quantity: 1})
};
fetch('https://api.useplinth.com/v1/subscriptions/{id}/preview-change', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.useplinth.com/v1/subscriptions/{id}/preview-change",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'plan_id' => 'pln_01JABC...',
'quantity' => 1
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.useplinth.com/v1/subscriptions/{id}/preview-change"
payload := strings.NewReader("{\n \"plan_id\": \"pln_01JABC...\",\n \"quantity\": 1\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.useplinth.com/v1/subscriptions/{id}/preview-change")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"plan_id\": \"pln_01JABC...\",\n \"quantity\": 1\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.useplinth.com/v1/subscriptions/{id}/preview-change")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"plan_id\": \"pln_01JABC...\",\n \"quantity\": 1\n}"
response = http.request(request)
puts response.read_body{
"object": "preview",
"direction": "upgrade",
"dueNowMinor": "466667",
"creditMinor": "0",
"scheduledFor": null
}Subscriptions
Preview a plan change
Calculates exactly what a plan change would cost without committing it. Always call this before change so the customer sees the exact amount before confirming. Returns proration amounts to the kobo.
POST
/
v1
/
subscriptions
/
{id}
/
preview-change
Preview a plan change
curl --request POST \
--url https://api.useplinth.com/v1/subscriptions/{id}/preview-change \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"plan_id": "pln_01JABC...",
"quantity": 1
}
'import requests
url = "https://api.useplinth.com/v1/subscriptions/{id}/preview-change"
payload = {
"plan_id": "pln_01JABC...",
"quantity": 1
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({plan_id: 'pln_01JABC...', quantity: 1})
};
fetch('https://api.useplinth.com/v1/subscriptions/{id}/preview-change', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.useplinth.com/v1/subscriptions/{id}/preview-change",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'plan_id' => 'pln_01JABC...',
'quantity' => 1
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.useplinth.com/v1/subscriptions/{id}/preview-change"
payload := strings.NewReader("{\n \"plan_id\": \"pln_01JABC...\",\n \"quantity\": 1\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.useplinth.com/v1/subscriptions/{id}/preview-change")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"plan_id\": \"pln_01JABC...\",\n \"quantity\": 1\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.useplinth.com/v1/subscriptions/{id}/preview-change")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"plan_id\": \"pln_01JABC...\",\n \"quantity\": 1\n}"
response = http.request(request)
puts response.read_body{
"object": "preview",
"direction": "upgrade",
"dueNowMinor": "466667",
"creditMinor": "0",
"scheduledFor": null
}Authorizations
Use sk_test_ keys for sandbox. Use sk_live_ keys for production. Obtain your key from the dashboard.
Path Parameters
Response
200 - application/json
Proration preview
Available options:
preview Available options:
upgrade, downgrade, lateral Example:
"upgrade"
Kobo to charge immediately (upgrade). Zero if deferred.
Example:
"466667"
Kobo to credit to balance (downgrade). Zero if deferred.
Example:
"0"
Set when the change is deferred to period end. Null if immediate.