curl --request POST \
--url https://{subdomain}.truust.io/2.0/subscriptions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"buyer_id": 7485,
"seller_id": 7485,
"name": "Subscription Test",
"value": 10,
"type": "ADDON"
}
'import requests
url = "https://{subdomain}.truust.io/2.0/subscriptions"
payload = {
"buyer_id": 7485,
"seller_id": 7485,
"name": "Subscription Test",
"value": 10,
"type": "ADDON"
}
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({
buyer_id: 7485,
seller_id: 7485,
name: 'Subscription Test',
value: 10,
type: 'ADDON'
})
};
fetch('https://{subdomain}.truust.io/2.0/subscriptions', 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://{subdomain}.truust.io/2.0/subscriptions",
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([
'buyer_id' => 7485,
'seller_id' => 7485,
'name' => 'Subscription Test',
'value' => 10,
'type' => 'ADDON'
]),
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://{subdomain}.truust.io/2.0/subscriptions"
payload := strings.NewReader("{\n \"buyer_id\": 7485,\n \"seller_id\": 7485,\n \"name\": \"Subscription Test\",\n \"value\": 10,\n \"type\": \"ADDON\"\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://{subdomain}.truust.io/2.0/subscriptions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"buyer_id\": 7485,\n \"seller_id\": 7485,\n \"name\": \"Subscription Test\",\n \"value\": 10,\n \"type\": \"ADDON\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{subdomain}.truust.io/2.0/subscriptions")
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 \"buyer_id\": 7485,\n \"seller_id\": 7485,\n \"name\": \"Subscription Test\",\n \"value\": 10,\n \"type\": \"ADDON\"\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"self": "<string>",
"reference_id": "<string>",
"name": "<string>",
"amount": 123,
"currency": "EUR",
"type": "<string>",
"status": "CREATED",
"metadata": {},
"published_at": "2023-11-07T05:31:56Z",
"cancelled_at": "2023-11-07T05:31:56Z",
"connections": {}
}{
"message": "The given data was invalid.",
"errors": {
"name": [
"The name field is required."
]
}
}Create Subscription
Creates a recurring payment subscription. The first order is created immediately; subsequent orders are triggered on the defined schedule.
curl --request POST \
--url https://{subdomain}.truust.io/2.0/subscriptions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"buyer_id": 7485,
"seller_id": 7485,
"name": "Subscription Test",
"value": 10,
"type": "ADDON"
}
'import requests
url = "https://{subdomain}.truust.io/2.0/subscriptions"
payload = {
"buyer_id": 7485,
"seller_id": 7485,
"name": "Subscription Test",
"value": 10,
"type": "ADDON"
}
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({
buyer_id: 7485,
seller_id: 7485,
name: 'Subscription Test',
value: 10,
type: 'ADDON'
})
};
fetch('https://{subdomain}.truust.io/2.0/subscriptions', 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://{subdomain}.truust.io/2.0/subscriptions",
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([
'buyer_id' => 7485,
'seller_id' => 7485,
'name' => 'Subscription Test',
'value' => 10,
'type' => 'ADDON'
]),
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://{subdomain}.truust.io/2.0/subscriptions"
payload := strings.NewReader("{\n \"buyer_id\": 7485,\n \"seller_id\": 7485,\n \"name\": \"Subscription Test\",\n \"value\": 10,\n \"type\": \"ADDON\"\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://{subdomain}.truust.io/2.0/subscriptions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"buyer_id\": 7485,\n \"seller_id\": 7485,\n \"name\": \"Subscription Test\",\n \"value\": 10,\n \"type\": \"ADDON\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{subdomain}.truust.io/2.0/subscriptions")
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 \"buyer_id\": 7485,\n \"seller_id\": 7485,\n \"name\": \"Subscription Test\",\n \"value\": 10,\n \"type\": \"ADDON\"\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"self": "<string>",
"reference_id": "<string>",
"name": "<string>",
"amount": 123,
"currency": "EUR",
"type": "<string>",
"status": "CREATED",
"metadata": {},
"published_at": "2023-11-07T05:31:56Z",
"cancelled_at": "2023-11-07T05:31:56Z",
"connections": {}
}{
"message": "The given data was invalid.",
"errors": {
"name": [
"The name field is required."
]
}
}Authorizations
Use your account's Secret Key as the Bearer token.
Body
Customer ID of the subscriber (buyer).
42
Customer ID of the seller.
120"Monthly plan"
Recurring charge amount.
x >= 09.99
Payment method type for the subscription (e.g. CARD).
"CARD"
x >= 00 <= x <= 100Date when the subscription starts. Defaults to creation date if not provided.
Amount for the first payment if different from value.
Number of billing cycles. Leave null for indefinite.
Cron expression or schedule descriptor (e.g. monthly, weekly).
100Metadata applied to each generated order.
Response
Subscription created
"EUR"
Payment method type for this subscription.
CREATED, ACTIVE, CANCELLED, EXPIRED Hypermedia links to related resources.
Show child attributes
Show child attributes
