Generate, Share, and Get Paid — All Through the API
The TruBuy App Payment Link Generator API allows external systems to programmatically create secure payment links that customers can use to complete payments through the TruBuy payment gateway.
Generate Payment Link using API requires one of the following TruBuy App options:
Payment links can be generated from:
Once generated, the payment link can be sent to a customer via:
The API returns a fully hosted payment page URL where the customer completes the payment securely.
Before using the API, the integration must be configured in the Custom API Settings panel, located in your webstore or website with TruBuy App plugin.

| Field | Description |
|---|---|
| API Allowed IPs | Whitelisted IP addresses allowed to call the API |
| API Key | Authentication key sent in request headers |
| HTTPS Only | Forces API calls over HTTPS |
POST /wp-json/tba/v1/payment-link/
Example:
https://yourdomain.com/wp-json/tba/v1/payment-link/
The request must include:
When a payment link is successfully created, the API returns a response similar to:
1 2 3 4 5 6 7 8 9 10 | {
"Status": "Success",
"FormID": "paymentForm",
"ButtonClass": "button atl",
"originpoint": "https://test.ipg-online.com",
"endpoint": "https://test.ipg-online.com/connect/gateway/processing",
"ButtonLabel": "Make Payment",
"hashExtended": "D/uSHy8o/AxoZ4jRxoomMts8TTnluOiejBsjfMjQ2aQ=",
"link": "https://[your-webstore-domain]/my-payment-link/KYFZGZZ7HP1"
}
|
The link field is the generated payment page.
| Parameter | Description |
|---|---|
| merchant_id | Merchant account ID |
| platform_name | Name of the calling platform |
| chargtotal | Payment amount |
| cname | Customer name |
| Customer email | |
| product_info | Name of the product/service |
| product_description | Description |
| currency_code | ISO currency code |
| platform_transaction_id | External transaction ID |
| platform_checkout_id | External checkout reference |
| hashExtended | Security hash |
To ensure request integrity, TruBuy requires a HMAC SHA256 hash.
The hash is generated by:
|HMAC SHA256Base64This ensures:
value1|value2|value3|value4
HMAC SHA256
Base64
The following PHP function generates a TruBuy App payment link.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | <?php /* This function is used to generate a TruBuy App Payment Link. */ function _generate_payment_link(){ //Replace API credentials below located on the Gateway and Integration Settings page //in Custom API setting section of your webstore $url = "[your domain]/wp-json/tba/v1/payment-link/"; // URL endpoint $merchant_id = "SCD......"; // Merchant Id $shared_secret = "SSC......."; // Shared Secret $api_key = "your-api-key"; // API Key. $error_msg = ""; $arrPosts = []; $arrPosts['merchant_id'] = $merchant_id; $arrPosts['hash_algorithm'] = "HMACSHA256"; //General options $arrPosts['platform_method'] = "My Platform"; //Give the API platform a name. This will be generated on //the client's reciept as the payment platform used to create the link. $arrPosts['cname'] = "John Doe"; //The name of the client $arrPosts['email'] = "[email protected]"; //The client's email address and / or phone number $arrPosts['phonenumber'] = "1555-555-5555"; //The client's email address or phone number $arrPosts['product_info'] = "Name of payment link"; //Product or service information for the client $arrPosts['product_description'] = "Payment link info"; //Information about the payment link $arrPosts['currency_code'] = "840"; //Currency code for the payment link. Example USD $arrPosts['chargetotal'] = "23.46"; //The charge total of the link $arrPosts['platform_checkout_id'] = "2001"; //Optionally identifies or map to the platform's order in the checkout page. //Helps to update an existing order instead of creating a new order $arrPosts['platform_transaction_id'] = "1001"; //Optionally identifies or map to the platform's transaction id $arrPosts['order_id'] = ""; //Blank order number will be generated automatically //Optional billing information for client $arrPosts['baddr1'] = ""; $arrPosts['baddr2'] = ""; $arrPosts['bcity'] = ""; $arrPosts['bcountry'] = ""; $arrPosts['bzip'] = ""; //Optional shipping information for client $arrPosts['saddr1'] = ""; $arrPosts['saddr2'] = ""; $arrPosts['scity'] = ""; $arrPosts['scountry'] = ""; $arrPosts['szip'] = ""; //Optional return url after success, cancel or declined transaction $arrPosts['platform_site_url'] = ""; $arrPosts['success_url'] = ""; $arrPosts['error_url'] = ""; $arrPosts['cancel_url'] = ""; //Optional booking information $arrPosts['booking_name'] = ""; $arrPosts['booking_timezone'] = ""; $arrPosts['start_time'] = ""; $arrPosts['end_time'] = ""; $arrPosts['booking_memo'] = ""; ksort($arrPosts); $stringToHash = ""; foreach($arrPosts as $keyname => $val){ if((string)$val !== ""){ if($stringToHash != ""){ $stringToHash = $stringToHash ."|"; } $stringToHash = $stringToHash . $val; } } $hashSHA = hash_hmac('sha256', $stringToHash, $shared_secret, true); $hashSHA = base64_encode($hashSHA); $arrPosts['hashExtended'] = $hashSHA; $ch = curl_init($url); $headers = [ 'Content-Type: application/json', 'X-Timestamp: '.time(), 'X-API-Key: '.$api_key ]; $payload = json_encode($arrPosts); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $payload, CURLOPT_HTTPHEADER => $headers, CURLOPT_CONNECTTIMEOUT => 15, CURLOPT_TIMEOUT => 30 ]); $response = curl_exec($ch); if ($response === false) { $error_msg = curl_error($ch); } $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if($error_msg !== ""){ $res = ['Status' => 'Error', 'Message' => $error_msg, 'Code' => $http_code]; }else{ $res = json_decode($response, true); //$res['link'] is available once payment link is created } return $res; } ?> |
ModalBodyLabel