Before You Start: Scope and Safety
This guide documents POST /wp-json/tba/v1/payment-link/ in the supplied TruBuy App Storefront, Payments and Virtual Terminal v1.0.7.465 source. It is a separate component from the documentation-hosting server plugin v1.0.0.126. Verify the storefront plugin version installed on your target store before integrating.
The contract below was checked against the route handler and its payment-link functions, not by creating a live order. A successful API request can create or update an order/payment link. It is not a read-only connectivity test.

Start here
- From your store homepage, open the account arrow (1), expand Administration (2), then choose Integration Settings (3).
- Find Custom API Settings. Only an authorized person should view or configure credentials; never include them in screenshots.


1. Get the Store-Specific Configuration
- Open Gateway and Integration Settings → Custom API Settings.
- Copy the displayed endpoint for this store. The host is your storefront/plugin installation, not a universal TruBuy API host.
- Obtain this store’s Merchant ID, Shared Secret, and API Key through the approved administrator process. The merchant identifier is the settings code used for signature lookup, not an arbitrary order/customer ID.
- Keep HTTPS Only enabled. If API Allowed IPs is set, allow the integration server’s actual outgoing IP. The handler compares the request’s remote IP; proxy and egress configuration can affect this.
- Synchronize the integration server’s clock and securely store the credentials. Confirm the store’s payment methods and currency before the first authorized request.
POST https://your-store.example/wp-json/tba/v1/payment-link/2. Build the JSON Body
chargetotal and platform_method. The handler itself assigns the internal platform name Custom API. Do not send chargtotal as the amount or substitute platform_name for platform_method. This does not rename legitimate platform fields used by other integrations.| Field | Requirement | Meaning |
|---|---|---|
| merchant_id | Required | This store’s merchant/settings code. |
| hashExtended | Required | Base64-encoded HMAC-SHA256 signature of the request parameters. |
| chargetotal | Required for a normal payable link | Positive decimal amount. The handler rounds to two decimal places. Validate monetary limits in your integration. |
| currency_code | Provide explicitly | The store-configured currency; the example uses numeric ISO 4217 code 840 for USD. A missing value can fall back to merchant settings, and the downstream source may normalize/fall back to a configured currency. Verify the actual checkout currency. |
| platform_method | Recommended | Your integration’s human-readable name, such as Example Billing System. |
| product_info / product_description | Recommended | Customer-facing payment title and description. |
| cname / email / phonenumber | As needed by the checkout | Customer name, email, and phone. A supplied email must validate. A supplied phone must pass phone validation and normalize to 10–15 digits; include the country code. These fields are not all unconditionally required by the route, but checkout configuration may require them. |
Optional fields accepted by this handler
| Group | Exact names and notes |
|---|---|
| Customer/reference IDs | client_id, platform_client_id, platform_transaction_id, platform_checkout_id, order_id. Use stable references and your own request/order tracking. These fields are not a general documented idempotency guarantee. |
| Billing address | baddr1, baddr2, bcity, bcountry, bzip. |
| Shipping address | saddr1, saddr2, scity, scountry, szip. |
| Return URLs | platform_site_url, success_url, error_url, cancel_url. Nonempty values must be valid URLs. Use your own approved HTTPS destinations. A browser redirect is not payment verification. |
| Booking information | booking_name, booking_timezone, start_time, end_time, booking_memo. Nonempty start/end values must exactly match Y-m-d H:i:s. Confirm intended timezone and booking rules before use. |
| Optional signed time | txndatetime with timezone or Timezone is additionally checked by the shared signature validator if supplied. It is not a replacement for the mandatory X-Timestamp header. Omit it unless your integration intentionally implements that extra check. |
Keep body values scalar strings. Do not add unsigned query parameters, arrays, or nested objects: the server signs the complete merged parameter set. hash_algorithm is not needed to select the algorithm; this route’s signature verifier uses HMAC-SHA256.
3. Sign the Exact Values and Add Headers
- Build the complete body, including all optional values you will send.
- Sort parameter names alphabetically, matching PHP
ksort. - Exclude
hashExtendedandehash. - Skip values whose string representation is empty. Keep
"0"; it is not empty. - Join the remaining values only with a literal
|, with no extra spaces or trailing separator. - Compute HMAC-SHA256 using the shared secret, request raw binary output, and Base64-encode those bytes. Put the result in
hashExtended. - Send the unchanged body as JSON with the headers below. Do not trim, reformat amounts, or add body fields after signing.
| Header | Value |
|---|---|
| Content-Type | application/json |
| X-Timestamp | Current Unix time in seconds. Required; the source rejects a clock difference greater than 300 seconds. |
| X-API-Key | The configured API key. The source enforces a match when a nonempty key is configured; keep one configured and send it. |
The timestamp header is validated separately from the body signature. Synchronize clocks and do not treat the five-minute check as a one-use/idempotency mechanism.
4. Server-Side PHP Example
This example is illustrative and is not executed by the tutorial. It requires PHP cURL and JSON support. Environment-variable names are examples; store the actual values using your application’s secret-management process. Replace the sample order/customer data only after you are authorized to submit it.
<?php
// Server-side example. Configure these in your secret store/environment.
$endpoint = getenv('TRUBUY_PAYMENT_LINK_ENDPOINT');
$merchant = getenv('TRUBUY_MERCHANT_ID');
$secret = getenv('TRUBUY_SHARED_SECRET');
$apiKey = getenv('TRUBUY_API_KEY');
if (!$endpoint || !$merchant || !$secret || !$apiKey) {
throw new RuntimeException('Missing TruBuy integration configuration.');
}
if (parse_url($endpoint, PHP_URL_SCHEME) !== 'https') {
throw new RuntimeException('Use the HTTPS endpoint from your store settings.');
}
// Illustrative data only. Authorize the real order/customer before calling.
$params = [
'merchant_id' => $merchant,
'platform_method' => 'Example Billing System',
'product_info' => 'Example service',
'product_description' => 'Example invoice description',
'currency_code' => '840', // USD; use your configured currency.
'chargetotal' => '23.46', // Keep monetary values as decimal strings.
'cname' => 'Example Customer',
'email' => '[email protected]',
'platform_checkout_id' => 'example-checkout-1001',
'platform_transaction_id' => 'example-reference-1001'
];
// Sign the exact scalar body values, excluding the signature fields.
ksort($params);
$values = [];
foreach ($params as $name => $value) {
if ($name !== 'hashExtended' && $name !== 'ehash'
&& (string) $value !== '') {
$values[] = (string) $value;
}
}
$params['hashExtended'] = base64_encode(
hash_hmac('sha256', implode('|', $values), $secret, true)
);
$payload = json_encode($params, JSON_THROW_ON_ERROR);
$ch = curl_init($endpoint);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_CONNECTTIMEOUT => 15,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-Timestamp: ' . time(),
'X-API-Key: ' . $apiKey
]
]);
$raw = curl_exec($ch);
$http = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$transportError = curl_error($ch);
curl_close($ch);
if ($raw === false) {
// Reconcile the order before retrying an uncertain request.
throw new RuntimeException('Transport failure; check order status before retrying.');
}
$data = json_decode($raw, true, 512, JSON_THROW_ON_ERROR);
if ($http < 200 || $http >= 300
|| ($data['Status'] ?? '') !== 'Success'
|| empty($data['link'])) {
// Log a redacted diagnostic server-side, never credentials or signatures.
throw new RuntimeException('Payment link was not confirmed; inspect the response safely.');
}
$paymentLink = $data['link'];
// Store against your order. Show/share only with the intended customer.
5. Check Both HTTP and Application Results
Accept the operation only when the response is valid JSON, the HTTP result is successful, Status is Success, and lowercase link contains the returned payment URL. Do not confuse it with the capitalized Link field, which the shared response initializes separately.
{
"Status": "Success",
"link": "https://your-store.example/our-payment-link/EXAMPLE-ORDER-KEY/"
}This is a minimal illustrative response, not a captured live response. Additional fields depend on the configured payment flow. Use the URL actually returned; do not construct it from an assumed page slug. Store the external references and returned link against your own order.
6. Handle Errors and Uncertain Requests
| Response | What to check |
|---|---|
| 400 invalid_request | Merchant/settings lookup, hashExtended, exact signed values, and any optional signed transaction time. A comparison error usually means the server calculated a different signature. |
| 401 unauthorized | X-API-Key does not match the configured key. |
| 401 invalid_request | Missing or expired X-Timestamp. Regenerate it from a synchronized clock when preparing an authorized new request. |
| 403 https_required / forbidden_ip | Use HTTPS and verify the server’s actual outbound IP is allowed. Do not weaken the security settings as a shortcut. |
| 413 request_too_large | Keep the JSON request body at or below the source limit of 20,000 bytes. |
| 429 rate_limited | The route throttles calls per source IP. Back off; do not run a tight retry loop. |
| 400 invalid_email / invalid_phone / invalid_url / invalid_datetime | Validate the supplied optional data against its expected format. |
| HTTP success with Status = Failed | The downstream checkout/link generator can return an application failure without an HTTP error. Inspect Error and Message safely; verify payment configuration, amount, and currency. |
| Timeout, malformed response, or connection failure | The server may already have created the order. Reconcile by your references and inspect existing orders before retrying. Do not assume repeated requests are harmless. |
Log only the minimum redacted diagnostics needed for support: time, HTTP status, error code, and your internal reference. Never log API keys, shared secrets, full signed bodies, customer addresses, or payment links into public logs.
7. Verify Before Going Live
- Check the target plugin version and supported merchant currency/payment configuration.
- Verify your signature logic offline with synthetic values, including an empty string and the string
"0". - Use an approved isolated test store for the first actual creation. Confirm the amount, currency, description, customer mapping, and return destinations in the generated checkout.
- Check missing/invalid credentials, timestamp expiry, validation failures, application failures, and uncertain-response handling without creating duplicate live orders.
- Obtain approval before enabling production credentials and customer communications. Monitor order creation and payment reconciliation after rollout.
Source reference: storefront plugin ipg-hpp-gateway-nf.php functions tba_payment_permission and route tba/v1/payment-link; IPGProcessorClass.php functions createExtendedHash, GetSettingsFromHash, _create_payment_link, and _create_payment_request.
The separate public API article contains a parameter-table spelling mismatch. This guide follows the supplied handler for the exact amount and integration-name fields.