){if($setting['response'][0]['favicon'] == )
" alt="Merchant Logo" class="merchant-logo">
$merchantTradeNo]);
$timestamp = round(microtime(true) * 1000);
$nonce = bin2hex(random_bytes(16));
$message = $timestamp . "\n" . $nonce . "\n" . $payload . "\n";
$signature = hash_hmac('SHA512', $message, $apiSecret);
// Step 2: Headers
$headers = [
"Content-Type: application/json",
"BinancePay-Timestamp: $timestamp",
"BinancePay-Nonce: $nonce",
"BinancePay-Certificate-SN: $apiKey",
"BinancePay-Signature: $signature"
];
// Step 3: Send query request
$ch = curl_init("https://bpay.binanceapi.com/binancepay/openapi/order/query");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
// Step 4: Check result
if ($data && $data['status'] === 'SUCCESS') {
$bizStatus = $data['data']['status']; // PAY_SUCCESS or others
if ($bizStatus === 'PAID' || $bizStatus === 'PAY_SUCCESS') {
$referenceGoodsId = $data['data']['goods']['referenceGoodsId'] ?? null;
$transactionId = $data['data']['transactionId'] ?? $merchantTradeNo;
$payerAccount = $data['data']['payerAccount'] ?? 'Unknown';
$check_transactionid = pp_check_transaction_exits($transactionId);
if($check_transactionid['status'] == false){
if(pp_set_transaction_byid($referenceGoodsId, $plugin_slug, $plugin_info['plugin_name'], $payerAccount, $transactionId, 'completed')){
echo '';
}
}else{
?>
Transaction ID already exits
Transaction not completed yet
Transaction not valid or not found.
Transaction
$merchantTradeNo,
'orderAmount' => $transaction_amount, // Amount in USDT
'currency' => $settings['payment_currency'],
'goods' => [
'goodsType' => '01', // virtual
'goodsCategory' => 'D000',
'referenceGoodsId' => $payment_id,
'goodsName' => 'Product'
],
'returnUrl' => getCurrentUrl() . $separator . "status=success&session_id=$merchantTradeNo",
'cancelUrl' => getCurrentUrl() . $separator . "status=cancel"
];
// Convert payload to JSON
$payload = json_encode($orderData);
// Signature Generation
$timestamp = round(microtime(true) * 1000);
$nonce = bin2hex(random_bytes(16));
$message = $timestamp . "\n" . $nonce . "\n" . $payload . "\n";
$signature = hash_hmac('SHA512', $message, $apiSecret);
// Headers
$headers = [
"Content-Type: application/json",
"BinancePay-Timestamp: $timestamp",
"BinancePay-Nonce: $nonce",
"BinancePay-Certificate-SN: $apiKey",
"BinancePay-Signature: $signature"
];
// Send cURL Request
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
// Handle Response
$data = json_decode($response, true);
if ($data && $data['status'] === 'SUCCESS') {
$checkoutUrl = $data['data']['checkoutUrl'];
echo '';
} else {
?>