1. Overview
The TrustLink Escrow API allows online stores, marketplaces, and social commerce tools to programmatically issue protected payment links for Ghanaian Mobile Money transactions (MTN MoMo, Telecel Cash, and AT Money).
When an escrow is created via API, TrustLink issues a unique payment contract with a hosted checkout URL. Buyers complete Mobile Money payment on the checkout page, locking funds securely in escrow until item delivery is confirmed.
- Server-to-server contract creation with instant hosted payment links.
- Automated WhatsApp invoice delivery to buyer numbers (when provided).
- Integration support for custom web checkout flows and WooCommerce stores.
2. Quickstart
Get up and running with the TrustLink Escrow API in 5 simple steps:
-
Generate your Secret API Key
Navigate to the Vendor Dashboard Settings tab to generate your unique
x-api-keycredential. -
Store key securely in server environment variables
Keep your secret key inside server configuration variables (e.g.
TRUSTLINK_API_KEY). Never expose it in client-side code. -
Send a POST request to create an escrow
Issue an HTTP POST request to
https://www.trustlinkgh.online/api/v1/escrowswith required transaction details. -
Redirect buyer to checkoutUrl
Redirect the buyer to the returned
checkoutUrlor display it in your store UI to complete Mobile Money authorization.
3. Authentication
The API uses custom HTTP header authentication via the x-api-key header. Every request from your application server must include this credential.
x-api-key: YOUR_SECRET_API_KEY
If the x-api-key header is omitted, the server returns an HTTP 401 Unauthorized error. If the key is invalid or revoked, the server returns an HTTP 403 Forbidden response.
5. Create an Escrow
/api/v1/escrows
Developer Preview
Creates a new escrow record in state PENDING_PAYMENT and returns a hosted checkout URL for the buyer.
6. Request Fields
The request body must be a JSON object containing the following parameters:
| Field | Type | Required | Description | Example |
|---|---|---|---|---|
amount |
Number | Required | Transaction amount in Ghana Cedis (GH₵). Must be greater than 0. | 450.00 |
description |
String | Required | Clear item description or order summary for buyer reference. | "Used iPhone 13 Pro" |
buyerPhone |
String | Optional | Buyer's 10-digit Ghanaian phone number (+233 format accepted) for automated WhatsApp invoice delivery. | "+233550000000" |
buyerEmail |
String | Optional | Buyer's email address for receipt notifications. | "buyer@example.com" |
deliveryDate |
String | Optional | Target delivery timeline or date string. | "2026-08-10" |
redirectUrl |
String | Optional | Merchant URL to return the buyer to after payment completion. | "https://merchant.com/success" |
cancelUrl |
String | Optional | Merchant URL to return the buyer to if checkout is cancelled. | "https://merchant.com/cancel" |
customReference |
String | Optional | Merchant's internal order, invoice, or cart ID for reconciliation. | "ORDER-1234" |
Note: All transactions default to Ghana Cedis (GH₵ / GHS). Additional currency fields are not required.
7. Code Examples & Example Response
curl -X POST "https://www.trustlinkgh.online/api/v1/escrows" \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_SECRET_API_KEY" \
-d '{
"amount": 450.00,
"description": "Used iPhone 13 Pro",
"buyerPhone": "+233550000000",
"buyerEmail": "buyer@example.com",
"customReference": "ORDER-1234"
}'
const response = await fetch("https://www.trustlinkgh.online/api/v1/escrows", {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-api-key": process.env.TRUSTLINK_API_KEY // Use server environment variable
},
body: JSON.stringify({
amount: 450.00,
description: "Used iPhone 13 Pro",
buyerPhone: "+233550000000",
buyerEmail: "buyer@example.com",
customReference: "ORDER-1234"
})
});
const data = await response.json();
console.log(data);
import os
import requests
url = "https://www.trustlinkgh.online/api/v1/escrows"
headers = {
"Content-Type": "application/json",
"x-api-key": os.environ.get("TRUSTLINK_API_KEY")
}
payload = {
"amount": 450.00,
"description": "Used iPhone 13 Pro",
"buyerPhone": "+233550000000",
"buyerEmail": "buyer@example.com",
"customReference": "ORDER-1234"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
<?php
$apiKey = getenv('TRUSTLINK_API_KEY');
$url = 'https://www.trustlinkgh.online/api/v1/escrows';
$payload = json_encode([
'amount' => 450.00,
'description' => 'Used iPhone 13 Pro',
'buyerPhone' => '+233550000000',
'buyerEmail' => 'buyer@example.com',
'customReference' => 'ORDER-1234'
]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'x-api-key: ' . $apiKey
]);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
print_r($data);
?>
Example Response (HTTP 201 Created)
{
"id": "escrow_8f9a2b3c4d",
"status": "PENDING_PAYMENT",
"checkoutUrl": "https://www.trustlinkgh.online/checkout.html?id=escrow_8f9a2b3c4d",
"customReference": "ORDER-1234"
}
8. Errors & Status Codes
The TrustLink Escrow API returns standard HTTP status codes to indicate request success or failure:
| Status Code | Cause | Example Response Payload | Recommended Action |
|---|---|---|---|
400 Bad Request |
Missing required fields (amount or description). |
{"error": "Missing required fields: amount, description"} |
Ensure both amount and description are supplied in JSON body. |
401 Unauthorized |
Missing x-api-key HTTP header. |
{"error": "Missing x-api-key header"} |
Include the x-api-key header in your request dispatch. |
403 Forbidden |
Invalid or revoked API key. | {"error": "Invalid API Key"} |
Verify key value in Dashboard Settings or generate a new key. |
500 Server Error |
Internal database or execution error. | {"error": "Failed to create escrow"} |
Retry request with exponential backoff or contact developer support. |
9. Transaction States
Every escrow contract created in TrustLink follows a strictly monitored transaction state machine. UI elements and Firestore listeners map these constants to official status colors:
PENDING_PAYMENTFUNDS_ESCROWEDITEM_SHIPPEDCOMPLETEDExceptions: Escrows under dispute move to DISPUTED and resolve to REFUNDED or authorized completion.
PENDING_PAYMENT
Awaiting payment
Escrow link generated; buyer has not yet completed Mobile Money checkout authorization.
FUNDS_ESCROWED
Ready to ship
Mobile Money payment verified by gateway; funds securely locked in escrow. Seller notified to dispatch order.
ITEM_SHIPPED
In transit
Seller has marked item as shipped or provided tracking waybill. Buyer delivery window active.
COMPLETED
Released
Buyer confirms delivery via PIN or tracking link; escrow funds released to seller's wallet.
DISPUTED
Under review
Buyer or seller raised a formal dispute; funds frozen pending admin arbitration review.
REFUNDED
Returned
Dispute resolved in buyer's favor or contract cancelled; payment refunded back to buyer.
10. Webhooks Notice
Outbound HTTP webhook delivery for transaction state changes (e.g. escrow.status_changed) is currently under active development and not yet documented for live production use. Developers building integrations should poll payment status or contact TrustLink support for custom webhook configuration.
11. WooCommerce Integration
TrustLink Escrow provides an official WordPress payment gateway plugin for WooCommerce stores located in trustlink-woocommerce-plugin/.
- Adds "TrustLink Escrow (Mobile Money)" to your WooCommerce checkout page.
- Configurable API URL and Secret API Key in WordPress Admin settings.
- Automatic order redirection to hosted TrustLink Mobile Money checkout.
To inspect or install the WooCommerce plugin source code, refer to the repository plugin directory.
12. API Key Security Guidelines
Protect your integration credentials by following these security rules:
- Never commit secret keys: Add key configuration files to
.gitignore. - Server-side requests only: Always invoke the API from secure server code or Cloud Functions. Never call
/api/v1/escrowsdirectly from frontend JavaScript in the browser. - Rotate compromised keys: If a key is accidentally leaked in a repository or log, immediately revoke it in your Vendor Dashboard Settings and issue a new key.
13. Developer Support
Need assistance integrating TrustLink Escrow into your platform?
Technical Assistance & Integration Engineering
Our engineering team can assist with sandbox credentials, custom marketplace workflows, and WooCommerce setup.