Endpoint
Keep an overpayment as customer credit
POST
/v1/orders/{id}/keep_overpaymentRecords the excess of an overpaid order as credit on the order's customer (credit_balance). The other choice is a refund with reason: "overpayment". The excess is already in the merchant wallet either way.
- Scope a restricted key needs
orders:write- Publishable key
- Not allowed: secret or restricted key only
- Idempotency-Key
- Recommended. It makes a retry safe.
Parameters
| Parameter | Type and place | Meaning |
|---|---|---|
idrequired | stringpath | The id of the order. |
Orrerie-Version | stringheader | API version date. Default: the version the key was created with. Example 2026-10-11. |
Idempotency-Key | stringheader | Makes a retry safe. Kept 24 hours. 1 to 255 characters. |
Request body
A JSON object. The body may be left out. A field the call does not list is refused with parameter_unknown.
Example request
curl
curl https://api.orrerie.com/v1/orders/ord_0zymngngvf12b8b2cra7tb8e/keep_overpayment \
-H "Authorization: Bearer $ORRERIE_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{}'JavaScript
const response = await fetch("https://api.orrerie.com/v1/orders/ord_0zymngngvf12b8b2cra7tb8e/keep_overpayment", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ORRERIE_SECRET_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({}),
});
const result = await response.json();
if (!response.ok) throw new Error(`${result.error.code}: ${result.error.message}`);
console.log(result);Python
import os
import requests
response = requests.post(
"https://api.orrerie.com/v1/orders/ord_0zymngngvf12b8b2cra7tb8e/keep_overpayment",
headers={"Authorization": f"Bearer {os.environ['ORRERIE_SECRET_KEY']}"},
json={},
timeout=30,
)
result = response.json()
if not response.ok:
raise RuntimeError(f"{result['error']['code']}: {result['error']['message']}")
print(result)PHP
<?php
$request = curl_init('https://api.orrerie.com/v1/orders/ord_0zymngngvf12b8b2cra7tb8e/keep_overpayment');
curl_setopt_array($request, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('ORRERIE_SECRET_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(new stdClass()),
]);
$body = curl_exec($request);
if ($body === false) {
throw new RuntimeException(curl_error($request));
}
$result = json_decode($body, true);
if (curl_getinfo($request, CURLINFO_HTTP_CODE) >= 400) {
throw new RuntimeException($result['error']['code'] . ': ' . $result['error']['message']);
}
print_r($result);Responses
200 OK
The answer is the order object. Headers: Orrerie-Request-Id.
Example response, 200
{
"id": "ord_0zymngngvf12b8b2cra7tb8e",
"object": "order",
"livemode": true,
"created": "2026-10-11T14:03:22.418Z",
"updated": "2026-10-11T14:09:55.764Z",
"status": "overpaid",
"source": "checkout",
"amount": "21.99",
"currency": "USD",
"value": {
"amount": "21.99",
"currency": "USD"
},
"fx": null,
"description": "Order #1042",
"reference": "1042",
"customer": "cus_8ea07c40qsvv19f7rgmeb8ha",
"customer_email": "jane@example.com",
"line_items": [
{
"name": "Ethiopia Yirgacheffe, 1 kg",
"quantity": 1,
"unit_amount": "21.99",
"amount": "21.99",
"price": "price_mbk5s5r45kwheaq89dbmk2gz"
}
],
"settlement": {
"mode": "convert",
"asset": "base:usdc",
"amount_expected": "21.990000",
"amount_received": "21.990000",
"wallet": "wal_bsfw07hymawmda7gg8jsyy3g"
},
"fee_bearer": "payer",
"amount_paid": "25.00",
"amount_due": "0.00",
"amount_refunded": "0.00",
"paid_late": false,
"accepted_short": false,
"refunded": false,
"partially_refunded": false,
"finalized": true,
"has_unconfirmed": false,
"screening_hold": false,
"screening": {
"status": "clear"
},
"provider_refund_received": false,
"overpayment": {
"amount": "3.01",
"currency": "USD",
"asset": "base:usdc",
"asset_amount": "3.010000",
"resolution": "kept_as_credit"
},
"rails_allowed": [
"orrerie_app",
"relay",
"direct"
],
"accept": [],
"app_pay_allowed": true,
"active_instruction": null,
"instructions": [
"pin_h73hkjr8dyp4zymaet5e2gbv"
],
"payments": [
"pay_2pe50hae6w2jk4sp1rcq5pae"
],
"checkout_session": "cs_z7ek5wj68fyz80j7bz1eq4e0",
"payment_link": null,
"invoice": null,
"subscription": null,
"pos_device": null,
"receipt": "rcpt_ppaxx20nbqv0kqgkwcxcc5xh",
"expires_at": "2026-10-11T15:03:22.418Z",
"paid_at": "2026-10-11T14:09:55.764Z",
"cancelled_at": null,
"metadata": {
"cart_id": "c_7781"
}
}Any other status: an error
A status of 400 or above answers with the error object. Branch on its code, never on its message.
Errors
Beside the errors every call can answer with (a bad key, a missing scope, the rate limit), this call answers with:
| Code | HTTP | Meaning |
|---|---|---|
order_not_overpaid | 409 | Only an overpaid order with an unresolved excess has an overpayment to keep. |
customer_required | 409 | The action needs the order to have a customer. |
customer_credit_currency_mismatch | 409 | The customer's credit is held in another currency, so it cannot be used here. |