Apply a coupon to a subscription
curl --request POST \
--url https://api.paybridgenp.com/v1/billing/subscriptions/{id}/apply-coupon \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"couponId": "<string>",
"promotionCode": "<string>"
}
'import requests
url = "https://api.paybridgenp.com/v1/billing/subscriptions/{id}/apply-coupon"
payload = {
"couponId": "<string>",
"promotionCode": "<string>"
}
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({couponId: '<string>', promotionCode: '<string>'})
};
fetch('https://api.paybridgenp.com/v1/billing/subscriptions/{id}/apply-coupon', 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.paybridgenp.com/v1/billing/subscriptions/{id}/apply-coupon",
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([
'couponId' => '<string>',
'promotionCode' => '<string>'
]),
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.paybridgenp.com/v1/billing/subscriptions/{id}/apply-coupon"
payload := strings.NewReader("{\n \"couponId\": \"<string>\",\n \"promotionCode\": \"<string>\"\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.paybridgenp.com/v1/billing/subscriptions/{id}/apply-coupon")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"couponId\": \"<string>\",\n \"promotionCode\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.paybridgenp.com/v1/billing/subscriptions/{id}/apply-coupon")
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 \"couponId\": \"<string>\",\n \"promotionCode\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "sdsc_01j9x2k3m4n5p6q7r8s9t0u1v2",
"object": "discount",
"subscription_id": "<string>",
"coupon_id": "<string>",
"promotion_code_id": "<string>",
"started_at": "2023-11-07T05:31:56Z",
"ends_at": "2023-11-07T05:31:56Z",
"cycles_remaining": 123,
"active": true
}{
"error": {
"message": "<string>",
"code": "<string>",
"request_id": "req_2Je91NlWKuXkdXUJOK9gaHNW",
"suspension": {
"suspended_at": "2023-11-07T05:31:56Z",
"reason": "<string>"
},
"pause": {
"paused_at": "2023-11-07T05:31:56Z",
"reason": "<string>"
}
}
}Subscriptions
Apply a coupon to a subscription
Attaches a coupon (directly or via a promotion code) to a subscription. One active discount per subscription.
POST
/
v1
/
billing
/
subscriptions
/
{id}
/
apply-coupon
Apply a coupon to a subscription
curl --request POST \
--url https://api.paybridgenp.com/v1/billing/subscriptions/{id}/apply-coupon \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"couponId": "<string>",
"promotionCode": "<string>"
}
'import requests
url = "https://api.paybridgenp.com/v1/billing/subscriptions/{id}/apply-coupon"
payload = {
"couponId": "<string>",
"promotionCode": "<string>"
}
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({couponId: '<string>', promotionCode: '<string>'})
};
fetch('https://api.paybridgenp.com/v1/billing/subscriptions/{id}/apply-coupon', 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.paybridgenp.com/v1/billing/subscriptions/{id}/apply-coupon",
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([
'couponId' => '<string>',
'promotionCode' => '<string>'
]),
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.paybridgenp.com/v1/billing/subscriptions/{id}/apply-coupon"
payload := strings.NewReader("{\n \"couponId\": \"<string>\",\n \"promotionCode\": \"<string>\"\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.paybridgenp.com/v1/billing/subscriptions/{id}/apply-coupon")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"couponId\": \"<string>\",\n \"promotionCode\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.paybridgenp.com/v1/billing/subscriptions/{id}/apply-coupon")
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 \"couponId\": \"<string>\",\n \"promotionCode\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "sdsc_01j9x2k3m4n5p6q7r8s9t0u1v2",
"object": "discount",
"subscription_id": "<string>",
"coupon_id": "<string>",
"promotion_code_id": "<string>",
"started_at": "2023-11-07T05:31:56Z",
"ends_at": "2023-11-07T05:31:56Z",
"cycles_remaining": 123,
"active": true
}{
"error": {
"message": "<string>",
"code": "<string>",
"request_id": "req_2Je91NlWKuXkdXUJOK9gaHNW",
"suspension": {
"suspended_at": "2023-11-07T05:31:56Z",
"reason": "<string>"
},
"pause": {
"paused_at": "2023-11-07T05:31:56Z",
"reason": "<string>"
}
}
}Authorizations
Your PayBridgeNP API key. Obtain one from the dashboard under Settings → API Keys. Prefix: sk_test_ for testing, sk_live_ for production.
Path Parameters
Response
Discount applied.
Example:
"sdsc_01j9x2k3m4n5p6q7r8s9t0u1v2"
Available options:
discount null for a forever discount.
Remaining billing cycles for a repeating discount.
Was this page helpful?
⌘I