Accept a payment
Create an online payment, send the shopper to the MPS checkout, and read the outcome when they come back.
You create the payment on your backend, send the shopper to the returned checkoutUrl, and MPS
collects the payment. The shopper comes back to your success or failure URL, and you read the payment to
confirm the outcome.
Two ways to pay on the checkout
The checkout leads with a QR code for ANNA, MPS's pay-by-bank app: the shopper scans it, chooses their bank and confirms in their banking app. Continue with card opens the card form instead. Either way you get the same states, the same webhook and the same read. In test mode ANNA simulates the bank (see Test mode). MPS collects the card details on its own checkout, so card data never touches your systems.
Server only
Warning
successUrl is not proof of payment. Verify the webhook signature, read the payment, and check its state, amount, currency, and reference before marking an order paid.The return and the webhook can arrive in either order. Payment lifecycle draws the detail.
Before you start
- A test key (
mps_test_…) from Online › API keys on the MPS platform. See Authentication. - The scopes
internet:createto create andinternet:readto read. Every key holds them. - A server that can make outbound HTTPS calls. Every call carries your API key as
Authorization: Bearer. - With a partner key: the merchant's wallet, sent as
x-wallet-numberon every call, the read included.
Create a payment
Send the amount in euro cents and your two return URLs. Add an Idempotency-Key, one per checkout
attempt, so a retry never opens a second payment. Pick your language; each example runs as it is with
your test key in MPS_API_KEY, and the choice is kept for the whole page.
POST https://gateway.mps-emi.com/api/payments/internet/create
Authorization: Bearer mps_test_…
Content-Type: application/json
Idempotency-Key: 4f9c2e1a-7b3d-4c8e-9a1f-0d6e5b2c7a91
{
"amount": 1995,
"reference": "order-1234",
"successUrl": "https://shop.example.com/orders/1234/paid",
"failureUrl": "https://shop.example.com/orders/1234/failed"
}The gateway answers 200 with a paymentReference and a checkoutUrl. The fields are in
Request body and Response. Add a callbackUrl to be told when the
payment is received: see Webhooks.
Store the payment reference
Store paymentReference with your order before you redirect. It is the only key the read accepts,
and nothing is appended to your return URLs to tell you which payment came back.
Send the shopper to the checkout
Redirect the shopper's browser to checkoutUrl: an HTTP 303 from your backend, or
window.location.assign. When they finish, they land on your successUrl or failureUrl.
The checkout cannot be framed
The checkout refuses to load inside an iframe (frame-ancestors 'none'). Redirect the top-level
window, with window.top.location.href = checkoutUrl from inside a frame, or open it in a new tab.
This applies to embedded previews, widgets and site builders that render your page in a frame, too.
Open a new tab in the click handler, before any await. A browser allows window.open only
during the click itself, so opening it after creating the payment is blocked, silently in some mobile
app shells. Open about:blank first and point it at checkoutUrl once you have it. If the tab was
blocked anyway, show checkoutUrl as a link the shopper can click.
Read the outcome
When the shopper comes back, or when the webhook arrives, read the payment on your backend. The
examples take the paymentReference from PAYMENT_REFERENCE.
GET https://gateway.mps-emi.com/api/payments/internet/{paymentReference}
Authorization: Bearer mps_test_…The gateway answers 200 with the payment's state and amount. Fulfil the order only when state is
executed and amount equals the order total. See Coming back for what to do while it
is still pending.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
amount | integer | Yes | Amount to collect, in cents, as a JSON number. 1995 = EUR 19.95. At least 1, at most 5000000 (EUR 50,000). A decimal (19.95) or a string ("1995") is refused with 400 naming amount. |
reference | string | No | Your own order reference, shown to the shopper and echoed back. At most 64 characters: letters A-Z, digits, spaces and . _ : / # + -. Never required to be unique, never a lookup key. |
successUrl | string | Yes | Absolute HTTPS URL the shopper returns to after a successful payment. http:// only on localhost, for local development. |
failureUrl | string | Yes | Absolute HTTPS URL the shopper returns to after a failed or cancelled payment. http:// only on localhost. |
cancelUrl | string | No | Absolute HTTPS URL the shopper goes to when they choose Go back on the checkout instead of paying, such as your basket. Without it, Go back leads to failureUrl. http:// only on localhost. |
callbackUrl | string | No | HTTPS URL MPS posts this payment's webhooks to, server to server: payment.received once the payment is received, and the outcome of each of its refunds. At most 2048 characters. See Webhooks. |
locale | string | No | Language the checkout opens in: en, nl or fr. A language tag with a region, such as nl-BE, is accepted and used as its language (nl). Without it, the checkout follows the language of the shopper's browser, and English when the browser asks for none of these. Any other value is refused with 400 naming locale. |
The currency is EUR. Every return URL must be https://, except http:// on localhost.
Pass locale when you know the shopper's language, such as the language of your shop or of the order.
The checkout then opens in that language whatever the shopper's browser asks for.
Response
Create
{
"data": {
"paymentReference": "test-00000000-0000-4000-8000-000000000001",
"checkoutUrl": "https://pay.mps-emi.com/…"
}
}| Field | Type | Required | Description |
|---|---|---|---|
paymentReference | string | Yes | The MPS payment reference. The only key the read endpoint accepts: store it against your order before you redirect. |
checkoutUrl | string | Yes | The checkout to send the shopper to. |
Keep checkoutUrl private
Anyone holding checkoutUrl can pay this payment. Redirect the shopper to it. Do not log it, e-mail
it to anyone else, or put it where it can leak.
Read
{
"data": {
"paymentReference": "test-00000000-0000-4000-8000-000000000001",
"state": "executed",
"amount": 1995,
"currency": "EUR",
"amountRefunded": 0,
"amountRemaining": 1995,
"reference": "order-1234"
}
}| Field | Type | Required | Description |
|---|---|---|---|
paymentReference | string | Yes | As returned by create. |
state | string | Yes | Currently pending, executed, failed or abandoned. See States. |
amount | integer | Yes | In cents. Once executed, the amount actually approved. |
currency | string | Yes | ISO currency code of amount. |
amountRefunded | integer | Yes | In cents: what has been paid back so far, the refunds that are refunded. A pending refund is not in it yet. See Refunds. |
amountRemaining | integer | Yes | In cents: what can still be refunded, the executed amount less every refunded and every pending refund. 0 until executed. |
reference | string | Yes | Your own order reference, echoed back verbatim. Null when you sent none. |
The payment reference is an opaque string
Store and compare paymentReference as a string, exactly as you received it. Today a live reference
is a GUID and a test one is test- followed by a GUID (41 characters). Do not validate it as a UUID
or parse it: a test reference already fails that check. Treat it as opaque: letters, digits, - and
_, and allow up to 64 characters where you store it.
States
pending changes; executed (paid) never does. failed and abandoned (not paid within 24 hours)
are final for the card, with one exception: an ANNA bank payment the shopper completes afterwards still
turns the payment executed, and sends payment.received. Treat a state you do not
recognise as pending: it never means paid. Payment lifecycle explains each one and
what to do with it.
Check the amount on executed
On a partial approval the executed amount is less than you asked for, and this field is the
only signal that a shortfall occurred. Compare it with the order total before shipping.
You can poll the read every few seconds while the shopper is on the page.
Retry safely with Idempotency-Key
Without a key, every create opens a new payment, so two calls for one order open two separately payable
checkouts. To retry safely after a timeout or a dropped connection, send an Idempotency-Key header
(X-Idempotency-Key is accepted too). Generate its value once per checkout attempt, such as a UUID:
POST https://gateway.mps-emi.com/api/payments/internet/create
Authorization: Bearer mps_live_…
Idempotency-Key: 4f9c2e1a-7b3d-4c8e-9a1f-0d6e5b2c7a91- A retry with the same key and the same body returns the payment the first call made: the same
paymentReferenceandcheckoutUrl, and no second payment. - The same key with a different body is a
400namingIdempotency-Key. Use a new key for a new payment. - A retry while the first call is still running is a
409withcodeidempotency_key_in_use. Wait a second and send it again, unchanged. - A request refused as invalid (
400) does not use up its key: fix the body and send it with the same key. - After a
5xxor a network error you cannot tell whether the payment was made. Send the same request with the same key: you get the payment the first call made, or a new one if it made none. - A key belongs to your merchant and its mode: the same key from a test key and a live key, or from two merchants, makes two payments.
- At most 255 characters: letters, digits and punctuation, no spaces.
A key is kept for 24 hours from the moment its payment was created, as long as that payment can be paid. Retries do not extend it.
| You send the key again… | Same body | Different body |
|---|---|---|
| Within 24 hours | The first payment, 200 | 400 naming Idempotency-Key |
| Within 24 hours, but the first payment can no longer be read (rare) | 409 idempotency_key_expired: create a new payment with a new key | 400 naming Idempotency-Key |
| After 24 hours | A new payment | A new payment |
After 24 hours the first payment is abandoned unless it was paid. Before you open a new payment for an
order that already had one, read the first payment: if it is executed, the order is paid. Keep every
paymentReference an order had, so a late payment can still be matched to it.
Coming back
MPS sends the shopper to your URLs exactly as you passed them. Nothing is appended: no payment
reference, no state. To know which payment a return belongs to, keep the paymentReference with the
order (or in the shopper's session) before redirecting. Or put your own order id in the URLs you pass,
such as https://shop.example.com/orders/1234/paid.
| The shopper lands on | When | state when you read it |
|---|---|---|
successUrl | The payment went through | executed |
failureUrl | The payment was declined or failed | failed |
cancelUrl, or failureUrl without one | The shopper chose Go back on the checkout | Still pending: not paid |
failureUrl | The payment expired, 24 hours after it was created, while the checkout was still open | abandoned |
On return, read the payment once on your backend. If it is still pending, poll it every 2 seconds for
up to about 30 seconds. Then show "we are confirming your payment" and let the
webhook or a later read settle the order. Never mark an order paid because
the shopper reached your success URL.
Card attempts are limited
A declined card ends the payment: it is failed, and the shopper is sent to your failure URL. To let
them try another card, create a new payment, with a new Idempotency-Key.
Cards that end in neither an approval nor a decline leave the payment pending: an abandoned 3-D Secure
step, or a card refused before the issuer decided. The shopper may try again on the same checkout, at most
five cards per payment. After the fifth the checkout refuses further cards and tells the shopper so.
Nothing is sent to your return URLs, and the payment stays pending until it is abandoned, 24 hours after
it was created. A payment that has already been paid never takes a second card.
Webhooks
Pass a callbackUrl when you create the payment, and MPS posts a signed payment.received webhook to
it, server to server, once the payment has been received and booked. It arrives even when the shopper
closes the tab before coming back. A payment that does not go through sends none: read it.
Webhooks shows how to verify the signature, what the body carries, and how retries work.
Test mode
A payment created with a test key, an API key starting mps_test_, is a test payment. It works as
it does in live mode: the same endpoints, the same checkout URL, the same states and the same webhook.
But no card is charged, no bank is contacted, and nothing is booked or paid out.
- The
paymentReferencestarts withtest-, such astest-00000000-0000-4000-8000-000000000001; a live one is the GUID alone. It is the same reference everywhere (the checkout URL, the read endpoint and the webhook), so your system can tell a test payment from a live one by its reference alone. - The checkout shows a Test mode banner and lists the test cards below.
- Only the test cards are accepted. Any other card number is refused under the card number field, and uses up one of the payment's five card attempts.
- The card number decides the outcome. Any future expiry date and any security code will do.
| Card number | Scheme | Outcome |
|---|---|---|
4111 1111 1111 1111 | Visa | executed |
5555 5555 5555 4444 | Mastercard | executed |
4000 0000 0000 0002 | Visa | failed |
5200 0000 0000 0007 | Mastercard | failed |
4000 0000 0000 0010 | Visa | stays pending |
The ANNA QR code opens ANNA's test screen, under a Test mode banner. The shopper chooses a bank as in live mode, then chooses how the bank answers instead of confirming in their banking app:
| Choice | Outcome |
|---|---|
| Paid | executed |
| Rejected by the bank | the bank payment fails |
| Cancelled at the bank | the bank payment fails |
| Stays pending | stays pending |
A failed bank payment fails the payment once the card cannot pay it either, as in live mode: while the card
form can still be used, the payment stays pending.
An executed test payment sends the payment.received webhook to your callbackUrl, signed with the
test key's own signing secret. It is shown once, next to the API key, when you generate the key. A test
key has no 3-D Secure step.
End-to-end example
A minimal backend for a shop: the cart posts to /pay, the shopper pays on the MPS checkout, comes
back to /orders/:id/return, and the backend reads the outcome. Run it with a test key and pay
with 4111 1111 1111 1111 (any future expiry, any security code) for a paid order, or
4000 0000 0000 0002 for a declined one. See Test mode.
# Prerequisite: export MPS_API_KEY=mps_test_… (and jq installed)
# 1. Create. Keep paymentReference with your order. One Idempotency-Key per checkout attempt:
# resend the same one to retry, and you get the same payment back.
IDEMPOTENCY_KEY=$(uuidgen)
CREATED=$(curl -sS --fail-with-body -X POST "https://gateway.mps-emi.com/api/payments/internet/create" \
-H "Authorization: Bearer $MPS_API_KEY" -H "Content-Type: application/json" \
-H "Idempotency-Key: $IDEMPOTENCY_KEY" \
-d '{"amount":1995,"reference":"order-1234",
"successUrl":"https://shop.example.com/orders/1234/return",
"failureUrl":"https://shop.example.com/orders/1234/return"}') || { echo "$CREATED"; exit 1; }
PAYMENT_REFERENCE=$(echo "$CREATED" | jq -r '.data.paymentReference')
# 2. Open checkoutUrl in a browser and pay with a test card.
echo "Pay here: $(echo "$CREATED" | jq -r '.data.checkoutUrl')"
read -r -p "Press Enter once you have paid. "
# 3. Read the outcome
curl -sS --fail-with-body "https://gateway.mps-emi.com/api/payments/internet/$PAYMENT_REFERENCE" \
-H "Authorization: Bearer $MPS_API_KEY"The curl version prints the checkout and then the payment with "state": "executed" once you paid with
4111 1111 1111 1111.
In production, also pass a callbackUrl and settle orders from the webhook: a
shopper who closes the tab after paying never reaches your return URL.
Errors
Every status the create and read endpoints answer, with its body, is listed in Errors and rate limits. The ones you meet here:
| Status | Code | Cause | Resolution |
|---|---|---|---|
400 | — | Validation failed: an amount of zero, a non-HTTPS return URL, a callbackUrl that is not an absolute HTTPS URL on a publicly routable host, or an Idempotency-Key reused for a different request. The body names the field. | Fix the named field. See Validation errors. |
401 | — | No API key, or a wrong or revoked one. | Check the key. See API key errors. |
403 | — | The key lacks the scope; a partner key sent no x-wallet-number, or one that is not one of your merchants; or the merchant has no shop name registered yet. | Check the scope and the wallet. With a partner key, send x-wallet-number. For a missing shop name, contact MPS. See Authentication errors. |
404 | — | Read only: no such payment for this merchant, or a partner key sent no x-wallet-number. | Check that the reference reached you unchanged, and read it for the wallet it was created with (with a partner key, the same x-wallet-number). See Not found. |
409 | idempotency_key_in_use | Create only: a payment with this Idempotency-Key is still being created. | Retry after a second with the same key and body. See Conflicts. |
409 | idempotency_key_expired | Create only: the payment this key made can no longer be returned. | Create a new payment with a new key. See Conflicts. |
429 | — | Rate limited. | Wait Retry-After seconds. See Rate limits. |
Related
Need help? Contact MPS at contact@mps-emi.com or +32 55 89 09 77, or the MPS partner you work with. What to include.
Building with an AI assistant? Give it llms.txt, every page in llms-full.txt, this page as Markdown, or the OpenAPI document. See Build with AI.
Last updated on