Appearance
Versioning
How the API is versioned today
The version is in the path: every route is under /v1/ (/v1/payments/merchant/…, /v1/payments/public/…). There is no version header, no version query parameter and no per-key version setting. Every key on a deployment talks to the same v1.
There is no v2. MOOKHPay has not published a policy for how long a version is kept, or how much notice a breaking change gets. This page describes what the code does and how to write a client that survives the changes that do happen.
Changes you should expect within v1
These are additive. Write your client so that each one is harmless.
| Change | How to be ready for it |
|---|---|
| A new field in a response object or webhook payload | Ignore fields you do not know. Do not fail on them, and do not use strict schemas that reject them |
A new value in an enum: a status, a type, a failure.code, a payment_method.type, a rail | Treat an unknown value as "not one I handle": log it and fall back. A charge's failure.code falls back to declined on MOOKHPay's side; do the same on yours |
A new error code | Branch on the HTTP status first, then the codes you know, and treat any other code by its status. See Errors |
| A new webhook event type | Endpoints receive only the types they subscribed to, so a new type reaches you only after you add it. Still, answer 2xx to any event you do not handle |
| A new route, or a route switched on for a deployment | Nothing to do |
| A new optional request field | Nothing to do. Requests that leave it out behave as before |
| A tighter rate limit or a new limit | Handle 429 with Retry-After everywhere |
What is not additive, and would be a breaking change: removing or renaming a field, changing a field's type (for example a string amount becoming a number), making an optional request field required, changing what a status means, or changing the signature schemes for webhooks or payouts.
Request bodies are strict: unknown fields are refused with 400 and code 1701. So a field that is added to a request is safe for old clients, but a new client must not send a field to a deployment that does not know it yet.
Rules for a tolerant client
- Parse responses into a type that keeps unknown fields or drops them silently.
- Never match on
description. It is prose and changes. - Treat ids as opaque strings. Their prefixes (
cs_ke_,ch_ke_,acct_ke_,po_ke_) are stable today, but do not parse lengths or characters beyond what you need to route by country. - Treat cursors as opaque. Their format can change between releases.
- Read amounts as the type each route sends. Checkout amounts and webhook amounts are strings; charge, account and payout amounts are numbers. Do not assume one becomes the other.
- Do not depend on the order of keys in JSON, or on the order of webhook deliveries.
How changes are announced
Changes are listed in the Changelog, newest first, with the date and what a developer has to do, if anything.
A deployment can switch features on and off (platform payouts, login links, account links, direct charges, card charges). A route that is switched off answers 404. That is a deployment setting, not a version change.
The card element script
mookhpay.js is published at two kinds of address.
| Address | What it is | Use |
|---|---|---|
https://mookhpay.co/js/v1/1.0.0/mookhpay.js | One release. The file at this address never changes, so it can carry a Subresource Integrity hash | Recommended. Pin the version and its integrity |
https://mookhpay.co/js/v1/mookhpay.js | Always the latest 1.x release. Its bytes change with each release | Only without integrity, and only if you accept new versions unchecked |
The pinned tag for 1.0.0:
html
<script
src="https://mookhpay.co/js/v1/1.0.0/mookhpay.js"
integrity="sha384-lXNEMbizKZy3oUHYBsnoCIHU7nuqqgM/pJqPIY+2qeZm+dMAHI6aQJ3dedUIozUk"
crossorigin="anonymous"
></script>Keep crossorigin="anonymous": the browser checks the hash of a script from another origin only when it was fetched with CORS. Do not put an integrity hash on the latest address: the next release would fail the check and card payments on your page would stop.
When a new release is published, change both the version in src and the hash together. The v1 in the path holds 1.x releases only: the latest address is always the latest 1.x. See Card payments.