Contents
On this page
Redeem Loyalty Reward - Plugixa Car Wash
POST /plugixa-carwash/v1/customers/{id}/loyalty/redeem
Spend one reward’s worth of a customer’s points on a single-use coupon for the reward value, and e-mail the code to them.
Needs Plugixa Car Wash Pro with the Loyalty points app on, and the plugixa_carwash_edit capability. A refusal here uses WordPress’s own rest_forbidden code.
Note. The coupon is the customer’s own: used by another customer, it is refused in the booking summary. It needs the Coupons app on.
Request
POST https://your-site.example/wp-json/plugixa-carwash/v1/customers/25/loyalty/redeem
Path parameters
| Name | Type | Description |
|---|---|---|
id |
integer |
The customer’s id |
Request body
Content type: application/json
No body.
Responses
200 OK.
{
"success": true,
"data": {
"code": "REWARD-Q8MX2K",
"value": 10.0,
"balance": 130
}
}
| Field | Type | Meaning |
|---|---|---|
data.code |
string |
The new coupon code |
data.value |
number |
Its fixed value |
data.balance |
integer |
Points left |
Errors
| Status | Code | When |
|---|---|---|
404 |
plugixa_carwash_not_found |
No such customer, or the customer is in the trash. |
422 |
plugixa_carwash_no_reward |
The reward value in Settings -> Loyalty is 0. |
422 |
plugixa_carwash_not_enough_points |
The balance is below one reward. |
503 |
plugixa_carwash_busy |
The balance was being changed by another request. Try again. |
401 |
rest_forbidden |
Not signed in. |
403 |
rest_forbidden |
Signed in without the capability. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixa-carwash/v1/customers/25/loyalty/redeem" \
-u "admin:$WP_APP_PASSWORD"
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-carwash/v1/customers/25/loyalty/redeem');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => 'admin:' . getenv('WP_APP_PASSWORD'),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const auth = Buffer.from(`admin:${process.env.WP_APP_PASSWORD}`).toString('base64');
const response = await fetch('https://your-site.example/wp-json/plugixa-carwash/v1/customers/25/loyalty/redeem', {
method: 'POST',
headers: {
'Authorization': `Basic ${auth}`,
},
});
const { data } = await response.json();
Quick Links
Share