Contents
On this page
Start Payment - Plugixa Car Parking
POST /plugixa-car-parking/v1/payment/start
Start a payment for a booking with one of the site’s payment methods. An online method answers with the address to send the customer to; pay on arrival answers with its instructions.
Anyone may call it, signed in or not, with the public nonce the plugin’s pages print (see Public routes) and the booking’s payment key. It counts against the payment_start rate limit: 20 an hour per visitor address.
Request
POST https://your-site.example/wp-json/plugixa-car-parking/v1/payment/start
Request body
Content type: application/json. Send the nonce as security here or in the X-Plugixa-Carparking-Nonce header.
| Field | Type | Required | Description |
|---|---|---|---|
booking_ref |
string |
Yes | The booking’s reference. |
booking_key |
string |
Yes | The booking’s payment key, from the payment_key that Book a Space returned. |
gateway |
string |
No | The payment method: offline (the default), or stripe, paypal, mollie, adyen or klarna PRO. It must be switched on and set up in the settings. |
pay_type |
string |
No | What to charge. full (the default) charges everything still owed. deposit PRO charges the booking’s deposit. installment or installment_rolling PRO starts a monthly payment plan at Stripe. An unknown value charges in full. |
security |
string |
Yes | The public nonce, unless sent in the header. |
Pay on arrival always charges in full, whatever pay_type says. When part of the booking is already paid, a full payment charges the balance. Nothing is recorded as paid here: the payment is recorded when the provider confirms it.
{
"booking_ref": "PKG-3F9A2C",
"booking_key": "4f0c2a9e1b7d3c5a8e6f0b2d4c6a8e1f",
"gateway": "stripe",
"pay_type": "full"
}
Responses
200 OK. An online method: send the customer to redirect_url.
{
"success": true,
"message": "",
"data": {
"status": "redirect",
"redirect_url": "https://checkout.stripe.com/c/pay/cs_test_a1B2c3D4",
"extra": []
}
}
200 OK. Pay on arrival: show the instructions.
{
"success": true,
"message": "",
"data": {
"status": "pending",
"redirect_url": null,
"extra": {
"instructions": "Pay at the barrier office when you arrive."
}
}
}
| Field | Type | Meaning |
|---|---|---|
data.status |
string |
redirect for an online method, pending for pay on arrival |
data.redirect_url |
string|null |
The provider’s payment page, or null |
data.extra |
object|array |
Method-specific details. Pay on arrival puts its instructions here, from the settings |
After paying, the provider sends the customer back to the site, which records the payment and forwards them to the booking’s return page.
Errors
| Status | Code | When |
|---|---|---|
403 |
rest_error |
The nonce is missing or not valid. |
404 |
rest_error |
“Booking not found.”: no booking has that reference, or booking_key is wrong. The two look the same on purpose. |
400 |
rest_error |
“This booking is already paid.”: nothing is owed. |
409 |
rest_error |
Code attached to the site refused the payment for this booking. |
400 |
rest_error |
“That payment method is unavailable.”: unknown, switched off or not set up. |
400 |
rest_error |
The provider could not start the payment. message gives its reason. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixa-car-parking/v1/payment/start" \
-H "Content-Type: application/json" \
-H "X-Plugixa-Carparking-Nonce: $PCP_NONCE" \
-d '{"booking_ref":"PKG-3F9A2C","booking_key":"4f0c2a9e1b7d3c5a8e6f0b2d4c6a8e1f","gateway":"stripe","pay_type":"full"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-car-parking/v1/payment/start');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-Plugixa-Carparking-Nonce: ' . getenv('PCP_NONCE'),
],
CURLOPT_POSTFIELDS => json_encode([
'booking_ref' => 'PKG-3F9A2C',
'booking_key' => '4f0c2a9e1b7d3c5a8e6f0b2d4c6a8e1f',
'gateway' => 'stripe',
'pay_type' => 'full',
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-car-parking/v1/payment/start', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Plugixa-Carparking-Nonce': PCP_NONCE,
},
body: JSON.stringify({
booking_ref: 'PKG-3F9A2C',
booking_key: '4f0c2a9e1b7d3c5a8e6f0b2d4c6a8e1f',
gateway: 'stripe',
pay_type: 'full',
}),
});
const { data } = await response.json();
if (data.redirect_url) window.location.href = data.redirect_url;
Quick Links
Share