Contents
On this page
Start Checkout - Plugixa Stream
POST /plugixa-stream/v1/checkout
Create a pending order and open the gateway’s hosted payment page. Send the viewer’s browser to redirect; the order is paid only when the gateway confirms it, through its webhook or the PayPal return.
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.
Request
POST https://your-site.example/wp-json/plugixa-stream/v1/checkout
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
kind |
string |
Yes | pack or vip. Anything else reads as pack. |
id |
string |
Yes | The pack or plan id, from Get Wallet. |
gateway |
string |
Yes | stripe or paypal, one that is configured. |
coupon |
string |
No | A promo code. Checked again here: see Check Coupon. |
A coupon never brings a price below 50 in minor units (0.50 in most currencies). On a VIP plan, the discounted price is the subscription’s price for as long as it runs. The first VIP plan an account takes may start with free days; then amount is 0 and the first charge comes after the trial.
{
"kind": "pack",
"id": "p300",
"gateway": "stripe",
"coupon": "SPRING20"
}
Responses
201 Created.
{
"success": true,
"data": {
"order_id": 42,
"redirect": "https://checkout.stripe.com/c/pay/cs_test_a1B2c3D4"
}
}
| Field | Type | Meaning |
|---|---|---|
data.order_id |
integer |
The pending order |
data.redirect |
string |
The gateway’s payment page |
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_gateway |
That payment method is not configured. |
404 |
plugixa_stream_not_found |
No pack or plan with that id. |
409 |
plugixa_stream_already |
A VIP plan was asked for and the caller is already VIP. |
422 |
plugixa_stream_coupon |
The coupon is unknown, expired, used up, for the other kind of item, or already used by this account. |
502 |
plugixa_stream_gateway |
The payment page could not be opened. The order is marked failed. |
502 |
plugixa_stream_stripe |
Stripe refused the request; message is Stripe’s. plugixa_stream_paypal for PayPal. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixa-stream/v1/checkout" \
-u "$WP_USER:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"kind":"pack","id":"p300","gateway":"stripe","coupon":"SPRING20"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-stream/v1/checkout');
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([
'kind' => 'pack',
'id' => 'p300',
'gateway' => 'stripe',
'coupon' => 'SPRING20',
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-stream/v1/checkout', {
method: 'POST',
headers: {
'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ kind: 'pack', id: 'p300', gateway: 'stripe', coupon: 'SPRING20' }),
});
const { data } = await response.json();
Quick Links
Share