Developer Guide: Payment Link API
TruBuy App

Developer Guide: Payment Link API

Create a hosted payment link from your server using the source-verified request fields, signature, and response checks.

Main TopicsFor Developers

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.

Keep credentials server-side: Never put the shared secret or API key in browser JavaScript, a public repository, screenshot, mobile bundle, or customer URL. Use an isolated authorized test store, test gateway configuration, and controlled customer details. Test mode alone is not a blanket guarantee against email, record changes, or other side effects.
Developer using a laptop beside a protected server and a payment link displayed on a phone.
Conceptual illustration of server-side payment-link creation; not an app screenshot or confirmation of collected payment.

Start here

  1. From your store homepage, open the account arrow (1), expand Administration (2), then choose Integration Settings (3).
  2. Find Custom API Settings. Only an authorized person should view or configure credentials; never include them in screenshots.
Store Manager menu: 1 account arrow, 2 Administration, 3 Integration Settings.
1 Open the account menu. 2 Expand Administration. 3 Select Integration Settings. Genuine Store Manager screenshot, cropped and annotated.
4 Select Expand beside Custom API Settings. Credential values are not shown.
4 Select Expand beside Custom API Settings. Credential values are not shown. Cropped from the verified manager session.

1. Get the Store-Specific Configuration

  1. Open Gateway and Integration Settings → Custom API Settings.
  2. Copy the displayed endpoint for this store. The host is your storefront/plugin installation, not a universal TruBuy API host.
  3. 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.
  4. 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.
  5. 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

Use the exact field names: Send 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.
FieldRequirementMeaning
merchant_idRequiredThis store’s merchant/settings code.
hashExtendedRequiredBase64-encoded HMAC-SHA256 signature of the request parameters.
chargetotalRequired for a normal payable linkPositive decimal amount. The handler rounds to two decimal places. Validate monetary limits in your integration.
currency_codeProvide explicitlyThe 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_methodRecommendedYour integration’s human-readable name, such as Example Billing System.
product_info / product_descriptionRecommendedCustomer-facing payment title and description.
cname / email / phonenumberAs needed by the checkoutCustomer 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

GroupExact names and notes
Customer/reference IDsclient_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 addressbaddr1, baddr2, bcity, bcountry, bzip.
Shipping addresssaddr1, saddr2, scity, scountry, szip.
Return URLsplatform_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 informationbooking_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 timetxndatetime 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

  1. Build the complete body, including all optional values you will send.
  2. Sort parameter names alphabetically, matching PHP ksort.
  3. Exclude hashExtended and ehash.
  4. Skip values whose string representation is empty. Keep "0"; it is not empty.
  5. Join the remaining values only with a literal |, with no extra spaces or trailing separator.
  6. Compute HMAC-SHA256 using the shared secret, request raw binary output, and Base64-encode those bytes. Put the result in hashExtended.
  7. Send the unchanged body as JSON with the headers below. Do not trim, reformat amounts, or add body fields after signing.
HeaderValue
Content-Typeapplication/json
X-TimestampCurrent Unix time in seconds. Required; the source rejects a clock difference greater than 300 seconds.
X-API-KeyThe 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.

A link is not a payment: Creating a link does not prove funds were collected or that an email/WhatsApp message was delivered. Share it through an explicitly authorized channel. Confirm payment using the supported order/transaction integration for your store; never trust a customer redirect alone.

6. Handle Errors and Uncertain Requests

ResponseWhat to check
400 invalid_requestMerchant/settings lookup, hashExtended, exact signed values, and any optional signed transaction time. A comparison error usually means the server calculated a different signature.
401 unauthorizedX-API-Key does not match the configured key.
401 invalid_requestMissing or expired X-Timestamp. Regenerate it from a synchronized clock when preparing an authorized new request.
403 https_required / forbidden_ipUse HTTPS and verify the server’s actual outbound IP is allowed. Do not weaken the security settings as a shortcut.
413 request_too_largeKeep the JSON request body at or below the source limit of 20,000 bytes.
429 rate_limitedThe route throttles calls per source IP. Back off; do not run a tight retry loop.
400 invalid_email / invalid_phone / invalid_url / invalid_datetimeValidate the supplied optional data against its expected format.
HTTP success with Status = FailedThe 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 failureThe 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

  1. Check the target plugin version and supported merchant currency/payment configuration.
  2. Verify your signature logic offline with synthetic values, including an empty string and the string "0".
  3. 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.
  4. Check missing/invalid credentials, timestamp expiry, validation failures, application failures, and uncertain-response handling without creating duplicate live orders.
  5. 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.

Reviewed 14 October 2026 · Source references: TruBuy server v1.0.0.130 and storefront v1.0.7.466. Available screens and options vary by installed version, setup and permissions.

Get In Touch

Want to know more about the product? Please get in touch with us!