Contents
On this page
Check Coupon - Plugixa Stream
POST /plugixa-stream/v1/coupons/check
Preview a promo code so the app can show the new prices. It is a preview, never a promise: Start Checkout checks the code again.
Any signed-in user (an Application Password, or the login cookie with an X-WP-Nonce header). Signed out, it answers 401 plugixa_stream_login_required. It always acts on the caller’s own account. Rate-limited with the other coupon requests: 60 a minute per account. Codes are not meant to be guessed.
Request
POST https://your-site.example/wp-json/plugixa-stream/v1/coupons/check
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
code |
string |
Yes | The code. Letters are not case-sensitive. |
{
"code": "spring20"
}
Responses
200 OK. The code can be used.
{
"success": true,
"data": {
"code": "SPRING20",
"type": "percent",
"value": 20,
"applies": "all"
}
}
| Field | Type | Meaning |
|---|---|---|
data.code |
string |
The code, in capitals |
data.type |
string |
percent or fixed |
data.value |
integer |
A percentage, or an amount in minor units |
data.applies |
string |
pack, vip or all |
Errors
| Status | Code | When |
|---|---|---|
401 |
plugixa_stream_login_required |
Signed out. |
403 |
plugixa_stream_kids_profile |
The account’s active profile is a kids profile, which may not spend. |
422 |
plugixa_stream_coupon |
The code is not valid, has expired, is used up, or this account already used it. message says which. |
429 |
plugixa_stream_rate_limited |
More than 60 requests of this kind in the current minute. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixa-stream/v1/coupons/check" \
-u "$WP_USER:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"code":"spring20"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-stream/v1/coupons/check');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'code' => 'spring20',
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-stream/v1/coupons/check', {
method: 'POST',
headers: {
'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ code: 'spring20' }),
});
const { data } = await response.json();
Quick Links
Share