PHP code example of v03413 / bepusdt-php-sdk
1. Go to this page and download the library: Download v03413/bepusdt-php-sdk library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
v03413 / bepusdt-php-sdk example snippets
use V03413\BepusdtPhpSdk\Bepusdt;
// 你已经搭建好的 BEpusdt 系统地址
$token = 'YOUR_API_TOKEN_HERE'; // 在 BEpusdt 系统后台的 API Token
$bep = new Bepusdt($api, $token);
try {
$orderId = 'order_' . time();
$result = $bep->createTransaction(
orderId: $orderId,
amount: 10,
notifyUrl: 'https://b.example.com/example/notify.php',
redirectUrl: 'https://b.example.com/example/redirect.php?order_id=' . $orderId,
tradeType: 'tron.trx',
);
// print_r($result);
echo "交易订单创建成功: $orderId" . PHP_EOL;
// 重定向到收银台
header("Location: " . $result['data']['payment_url']);
} catch (Exception $e) {
echo "交易订单创建失败:" . PHP_EOL;
echo 'Error: ' . $e->getMessage() . PHP_EOL;
}
bash
composer