Backups Created:
/home/japatmex/public_html/wp-content/edit-wolf.php
Savvy
W
olf -
MANAGER
Edit File: CI_binance_pay.php
<?php /*require_once "binance-api/Binance_pay.php"; class CI_binance_pay extends Binance_pay { public function __construct() { parent::__construct(); } } */ class CI_binance_pay { private $api_key; private $secret_key; private $timestamp; private $nonce; private $return_url; private $cancel_url; public function __construct() { $this->api_key = $this->api_key(); $this->secret_key = $this->secret_key(); $this->timestamp = $this->timestamp(); $this->nonce = $this->nonce(); $this->return_url = $this->return_url(); $this->cancel_url = $this->cancel_url(); } public function create_order($merchant_trade_no, $amount, $currency) { // Request body $request = [ 'env' => [ 'terminalType' => 'WEB', ], 'merchantTradeNo' => $merchant_trade_no, 'orderAmount' => $amount, 'currency' => $currency, 'returnUrl' => $this->return_url . '&mtno=' . base64_encode($merchant_trade_no), 'cancelUrl' => $this->cancel_url . '&mtno=' . base64_encode($merchant_trade_no), 'goods' => [ 'goodsType' => '01', 'goodsCategory' => 'D000', 'referenceGoodsId' => '7876763A3B', 'goodsName' => 'Ice Cream', 'goodsDetail' => 'Greentea ice cream cone', ] ]; $json_request = json_encode($request); $payload = $this->timestamp."\n".$this->nonce."\n".$json_request."\n"; $signature = strtoupper(hash_hmac('SHA512', $payload, $this->secret_key)); $headers[] = "Content-Type: application/json"; $headers[] = "BinancePay-Timestamp: " . $this->timestamp; $headers[] = "BinancePay-Nonce: " . $this->nonce; $headers[] = "BinancePay-Certificate-SN: " . $this->api_key; $headers[] = "BinancePay-Signature: $signature"; $ch = curl_init(); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_URL, "https://bpay.binanceapi.com/binancepay/openapi/v2/order"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $json_request); $result = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } curl_close ($ch); $result = json_decode($result, true); return $result; } public function query_order($merchant_trade_no) { // Request body $request = [ 'merchantTradeNo' => base64_decode($merchant_trade_no) ]; $json_request = json_encode($request); $payload = $this->timestamp."\n".$this->nonce."\n".$json_request."\n"; $signature = strtoupper(hash_hmac('SHA512', $payload, $this->secret_key)); $headers[] = "Content-Type: application/json"; $headers[] = "BinancePay-Timestamp: " . $this->timestamp; $headers[] = "BinancePay-Nonce: " . $this->nonce; $headers[] = "BinancePay-Certificate-SN: " . $this->api_key; $headers[] = "BinancePay-Signature: $signature"; $ch = curl_init(); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_URL, "https://bpay.binanceapi.com/binancepay/openapi/v2/order/query"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $json_request); $result = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } curl_close ($ch); $result = json_decode($result, true); return $result; } private function timestamp() { return round(microtime(true) * 1000); } private function nonce() { $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $nonce_str = ''; for($i=1; $i <= 32; $i++) { $pos = mt_rand(0, strlen($chars) - 1); $char = $chars[$pos]; $nonce_str .= $char; } return $nonce_str; } private function dump($data) { echo '<pre>';print_r($data);die; } private function debug() { echo time();die; } private function api_key() { return 'vqce6hfvd6n3tsy1c7hnj95xsrl9fn4tz6sxupavnysjwgn3xuuehbsmthfsraml'; } private function secret_key() { return 'zcetv5mjuq7amumqoga8xnqxfdtqsixirhfpcxoggydbif6u2vnzjrsr2u1naxek'; } private function return_url() { return 'https://codeunlocksource.com/binance-pay-api/callback.php?event=return'; } private function cancel_url() { return 'https://codeunlocksource.com/binance-pay-api/callback.php?event=cancel'; } }