Track the fulfillment of an order
Overview
A payment tells you that the money arrived. Fulfillment tells your customer how the service is going, such as a delivery or a ticket booking. You send each update from your server, and it never changes the payment status.
Before you begin
Your key needs the fulfillment:write scope, and you use your secret key, shown below as sk_test_YOUR_SECRET_KEY. The example also creates and pays an invoice, so the key needs payments:write too. Use a sandbox key while you build.
Steps
Create the invoice
Create an invoice as in the QR payments guide. Fulfillment opens only when the invoice is paid, so there is nothing to update yet. The response has the invoiceId and the intentId that you use next.
curl -sS -X POST "https://api.tappay.mn/api/v1/invoices" \
-H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
-H "TapPay-Version: 2026-09-27" \
-H "Idempotency-Key: $(openssl rand -hex 16)" \
-H "Content-Type: application/json" \
-d '{"terminalId":"YOUR_TERMINAL_ID","amount":1000,"description":"Order 1","orderId":"order-'"$(uuidgen)"'"}'import { TapPay } from '@tappay-mn/node';
const tappay = new TapPay({ apiKey: 'sk_test_YOUR_SECRET_KEY' });
const invoice = await tappay.invoices.create({
body: {
terminalId: 'YOUR_TERMINAL_ID',
amount: 1000,
description: 'Order 1',
orderId: `order-${crypto.randomUUID()}`,
},
});
console.log(JSON.stringify(invoice));<?php
require 'vendor/autoload.php';
use TapPay\TapPay;
$tappay = new TapPay(['apiKey' => 'sk_test_YOUR_SECRET_KEY']);
$invoice = $tappay->invoices->create([
'body' => [
'terminalId' => 'YOUR_TERMINAL_ID',
'amount' => 1000,
'description' => 'Order 1',
'orderId' => 'order-' . vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex(random_bytes(16)), 4)) . '',
],
]);
echo json_encode($invoice);import json
import uuid
import tappay
client = tappay.TapPay("sk_test_YOUR_SECRET_KEY")
invoice = client.invoices.create({
"body": {
"terminalId": "YOUR_TERMINAL_ID",
"amount": 1000,
"description": "Order 1",
"orderId": "order-" + str(uuid.uuid4()) + "",
},
})
print(json.dumps(invoice))Pay in the sandbox
Let the simulator pay the invoice for the customer. This works only with a sandbox key. When the invoice is paid, TapPay opens its fulfillment with the status PENDING.
curl -sS -X POST "https://api.tappay.mn/api/v1/sandbox/intents/INTENT_ID/simulate" \
-H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
-H "TapPay-Version: 2026-09-27" \
-H "Idempotency-Key: $(openssl rand -hex 16)" \
-H "Content-Type: application/json" \
-d '{"channel":"QR","outcome":"SUCCEEDED"}'import { TapPay } from '@tappay-mn/node';
const tappay = new TapPay({ apiKey: 'sk_test_YOUR_SECRET_KEY' });
const result = await tappay.sandbox.simulateIntent({ id: 'INTENT_ID', body: { channel: 'QR', outcome: 'SUCCEEDED' } });
console.log(JSON.stringify(result));<?php
require 'vendor/autoload.php';
use TapPay\TapPay;
$tappay = new TapPay(['apiKey' => 'sk_test_YOUR_SECRET_KEY']);
$result = $tappay->sandbox->simulateIntent(['id' => 'INTENT_ID', 'body' => ['channel' => 'QR', 'outcome' => 'SUCCEEDED']]);
echo json_encode($result);import json
import tappay
client = tappay.TapPay("sk_test_YOUR_SECRET_KEY")
result = client.sandbox.simulate_intent({"id": "INTENT_ID", "body": {"channel": "QR", "outcome": "SUCCEEDED"}})
print(json.dumps(result))Start the fulfillment
Send the status IN_PROGRESS with a stage and a message in your own words. The stage uses capital letters, digits and underscores, up to 64 characters. The message can have up to 500 characters. TapPay does not explain either one to the customer.
curl -sS -X PUT "https://api.tappay.mn/api/v1/invoices/INVOICE_ID/fulfillment" \
-H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
-H "TapPay-Version: 2026-09-27" \
-H "Content-Type: application/json" \
-d '{"status":"IN_PROGRESS","stage":"OUT_FOR_DELIVERY","message":"The order is on its way."}'import { TapPay } from '@tappay-mn/node';
const tappay = new TapPay({ apiKey: 'sk_test_YOUR_SECRET_KEY' });
const invoice = await tappay.invoices.putFulfillment({
id: 'INVOICE_ID',
body: {
status: 'IN_PROGRESS',
stage: 'OUT_FOR_DELIVERY',
message: 'The order is on its way.',
},
});
console.log(JSON.stringify(invoice));<?php
require 'vendor/autoload.php';
use TapPay\TapPay;
$tappay = new TapPay(['apiKey' => 'sk_test_YOUR_SECRET_KEY']);
$invoice = $tappay->invoices->putFulfillment([
'id' => 'INVOICE_ID',
'body' => [
'status' => 'IN_PROGRESS',
'stage' => 'OUT_FOR_DELIVERY',
'message' => 'The order is on its way.',
],
]);
echo json_encode($invoice);import json
import tappay
client = tappay.TapPay("sk_test_YOUR_SECRET_KEY")
invoice = client.invoices.put_fulfillment({
"id": "INVOICE_ID",
"body": {
"status": "IN_PROGRESS",
"stage": "OUT_FOR_DELIVERY",
"message": "The order is on its way.",
},
})
print(json.dumps(invoice))Finish the fulfillment
When you deliver the order, send COMPLETED. If you cannot deliver it, send FAILED or CANCELLED with a message that explains why. These three statuses are final, so you cannot change them later.
curl -sS -X PUT "https://api.tappay.mn/api/v1/invoices/INVOICE_ID/fulfillment" \
-H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
-H "TapPay-Version: 2026-09-27" \
-H "Content-Type: application/json" \
-d '{"status":"COMPLETED","stage":"DELIVERED","message":"The order was delivered."}'import { TapPay } from '@tappay-mn/node';
const tappay = new TapPay({ apiKey: 'sk_test_YOUR_SECRET_KEY' });
const invoice = await tappay.invoices.putFulfillment({
id: 'INVOICE_ID',
body: {
status: 'COMPLETED',
stage: 'DELIVERED',
message: 'The order was delivered.',
},
});
console.log(JSON.stringify(invoice));<?php
require 'vendor/autoload.php';
use TapPay\TapPay;
$tappay = new TapPay(['apiKey' => 'sk_test_YOUR_SECRET_KEY']);
$invoice = $tappay->invoices->putFulfillment([
'id' => 'INVOICE_ID',
'body' => [
'status' => 'COMPLETED',
'stage' => 'DELIVERED',
'message' => 'The order was delivered.',
],
]);
echo json_encode($invoice);import json
import tappay
client = tappay.TapPay("sk_test_YOUR_SECRET_KEY")
invoice = client.invoices.put_fulfillment({
"id": "INVOICE_ID",
"body": {
"status": "COMPLETED",
"stage": "DELIVERED",
"message": "The order was delivered.",
},
})
print(json.dumps(invoice))Read the fulfillment
Read the invoice and check fulfillment. It has the status, your stage and message, and updatedAt. Reading a payment of the invoice returns the same object.
curl -sS "https://api.tappay.mn/api/v1/invoices/INVOICE_ID" \
-H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
-H "TapPay-Version: 2026-09-27"import { TapPay } from '@tappay-mn/node';
const tappay = new TapPay({ apiKey: 'sk_test_YOUR_SECRET_KEY' });
const invoice = await tappay.invoices.retrieve({ id: 'INVOICE_ID' });
console.log(JSON.stringify(invoice));<?php
require 'vendor/autoload.php';
use TapPay\TapPay;
$tappay = new TapPay(['apiKey' => 'sk_test_YOUR_SECRET_KEY']);
$invoice = $tappay->invoices->retrieve(['id' => 'INVOICE_ID']);
echo json_encode($invoice);import json
import tappay
client = tappay.TapPay("sk_test_YOUR_SECRET_KEY")
invoice = client.invoices.retrieve({"id": "INVOICE_ID"})
print(json.dumps(invoice))Verify
Read the invoice with GET and check fulfillment.status. It starts as PENDING, moves to IN_PROGRESS and ends as COMPLETED, FAILED or CANCELLED. The payment status stays SUCCEEDED in every case. TapPay sends the fulfillment.updated event to the wallet of the customer, and it does not send it to your own webhook endpoint.
Common mistakes
- Updating the fulfillment before the invoice is paid. It opens only when the invoice closes, so TapPay rejects the call until then.
- Reading
FAILEDas a failed payment. The payment staysSUCCEEDED. To return the money, make a refund as in the refunds guide. - Changing a final status.
COMPLETED,FAILEDandCANCELLEDcannot move to another status, and TapPay rejects the update. - Sending a
stagewith lowercase letters or spaces. Use capital letters, digits and underscores, such asOUT_FOR_DELIVERY. - Waiting for a webhook about your own update. TapPay sends
fulfillment.updatedonly to the wallet, so read the status withGETinstead.
Next steps
Return money for an order you could not deliver with the refunds guide. See every field in Set invoice fulfillment, Set payment fulfillment and Retrieve an invoice.