Contents
On this page

Refund Payment - Plugixa Car Rental

POST /plugixa-car-rental/v1/bookings/{id}/refunds

Give money back on a booking, up to what it holds.

Needs the Payments app, which is always on. The user needs the plugixa_car_rental_delete capability.

The amount is taken from the newest payments first. A part that came in through an online payment method that can refund (Stripe or PayPal, with Pro) is refunded at the provider; a desk payment is only recorded as given back, and the money is yours to return. If a provider refuses after some parts have gone through, those stay recorded and the rest comes back in remaining.

Note. This route does not check that the booking exists. An unknown id answers 422 “That is more than the booking holds (0.00)”, not 404.

Request

POST https://your-site.example/wp-json/plugixa-car-rental/v1/bookings/128/refunds

Path parameters

Name Type Description
id integer The booking’s id

Request body

Content type: application/json

Field Type Required Description
amount number Yes More than 0 and at most what the booking holds (paid on List Payments). Rounded to 2 decimals.
note string No Your note, up to 255 characters.
{
  "amount": 50,
  "note": "Returned a day early"
}

Responses

201 Created. data says what was given back.

{
  "success": true,
  "data": {
    "refunded": 50.0,
    "rows": [
      {
        "id": 42,
        "gateway": "desk",
        "gateway_label": "desk",
        "type": "refund",
        "amount": 50.0,
        "currency": "EUR",
        "status": "completed",
        "transaction_id": "",
        "note": "Returned a day early",
        "created_at": "2026-12-03 16:40:00"
      }
    ],
    "remaining": 0.0
  }
}
Field Type Meaning
data.refunded number Amount given back
data.rows object[] One refund row per payment it came from, in the shape of List Payments
data.remaining number Part of the amount not given back, because a provider refused

The booking’s amount_paid and payment_status are brought up to date. A booking whose payments have all been given back is refunded.

Errors

Status Code When
422 plugixa_car_rental_invalid amount is not above 0, or is more than the booking holds. data.field is amount.
503 plugixa_car_rental_busy Another refund for this booking was in progress. Try again in a moment.

When the first refund at a provider fails, that provider’s error comes back as it is.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-car-rental/v1/bookings/128/refunds" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"amount":50,"note":"Returned a day early"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-car-rental/v1/bookings/128/refunds');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'admin:' . getenv('WP_APP_PASSWORD'),
    CURLOPT_HTTPHEADER     => [
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS     => json_encode([
        'amount' => 50,
        'note'   => 'Returned a day early',
    ]),
]);
$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-car-rental/v1/bookings/128/refunds', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${auth}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ amount: 50, note: 'Returned a day early' }),
});
const { data } = await response.json();

Quick Links

Share