PHP code example of xup6m6fu04 / bitwin-sdk-php
1. Go to this page and download the library: Download xup6m6fu04/bitwin-sdk-php 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/ */
xup6m6fu04 / bitwin-sdk-php example snippets
up6m6fu04\Bitwin;
use Xup6m6fu04\Bitwin\Exception\BitwinSDKException;
use Xup6m6fu04\Bitwin\HTTPClient\GuzzleHTTPClient;
$c = new Example();
$c->createCryptoPayOrder();
class Example
{
/**
* @var \Xup6m6fu04\Bitwin\HTTPClient\GuzzleHTTPClient
*/
private $httpClient;
/**
* @var \Xup6m6fu04\Bitwin
*/
private $bitwin;
/**
* @throws \Xup6m6fu04\Bitwin\Exception\BitwinSDKException
*/
public function __construct()
{
$this->httpClient = new GuzzleHTTPClient();
$this->bitwin = new Bitwin($this->httpClient, [
'merchant_id' => 'your_merchant_id',
'sign_key' => 'your_sign_key',
'access_key' => 'your_access_key',
'is_prod_environment' => false, // true is production environment
]);
}
/**
* Create Crypto Pay Order
* 建立付款訂單
* 建立付款订单
*/
public function createCryptoPayOrder()
{
try {
$args = [
'MerchantUserId' => 'YOZERO_USER_01',
'MerchantOrderId' => 'YOZERO_ORDER_01',
'OrderDescription' => 'YOZERO_DESC_01',
'Amount' => '700000000', // 7 USDT
'FiatCurrency' => 'RMB',
'FiatCurrencyAmount' => '45.38',
'Symbol' => 'USDT_ERC20',
'CallBackUrl' => 'https://test.com/api/callback',
'TimeStamp' => '1628664587'
];
$result = $this->bitwin->api('CreateCryptoPayOrder')->call($args);
print_r($result->getJSONDecodedBody());
/**
* Successfully printed the result
* Array
* (
* [OrderId] => 53298248131218784
* [Qrcode] => https://stage-api.bitwin.ai/order/53298248131218784
* [Amount] => 700000000
* [RealAmount] => 700000000
* [CryptoWallet] => 0x70E6a93eB33A9bf69Fcc30F01029083E7D5bb65f
* [ReturnCode] => 200
* [ReturnMessage] =>
* [Sign] => 041FAA025359DEC6C8D4D283582E0456
* )
*/
} catch (BitwinSDKException | Exception $e) {
echo $e->getMessage();
}
}
...