PHP code example of jetfueltw / gpp365-php
1. Go to this page and download the library: Download jetfueltw/gpp365-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/ */
jetfueltw / gpp365-php example snippets
composer
$merchantId = '123XXXXXXXX86'; // 商家號
$secretKey = 'XXXXXXXXXX'; // md5 密鑰
$tradeNo = '20170101235959XXX'; // 商家產生的唯一訂單號
$channel = Channel::WECHAT; // 支付通道,支援微信支付、QQ錢包、支付寶
$amount = 100.00; // 消費金額 (元)
$clientIp = 'XXX.XXX.XXX.XXX'; // 消費者端 IP 位址
$notifyUrl = 'https://XXX.XXX.XXX'; // 交易完成後異步通知接口
$payment = new DigitalPayment($merchantId, $secretKey);
$result = $payment->order($tradeNo, $channel, $amount, $clientIp, $notifyUrl);
Post Data:
[
'code' => '0000'
'message' => '操作成功'
'data' => [
'merchant' => '123XXXXXXXX86' // 商家號
'tradeNo' => '20170101235959XXX' // 商家產生的唯一訂單號
'ordernumber' => '123XXXXXXXXXXXXXX890' // 聚合支付平台訂單號
'payType' => '1' // 交易類型 1.WECHAT、2.ALIPAY、4.QQ
'amount' => '100.00' // 消費金額 (分)
'curType' => 'CNY' // 交易幣別
'status' => '1' // 訂單狀態 0.處理中、1.交易成功、2.交易失敗
'tradeTime' => '2017-08-01 09:00:00' // 交易時間
'sign' => '946XXXXXXXXXXXXXXXXXXXXXXXXXX008' // 簽名
]
]
$tradeQuery = new TradeQuery($merchantId, $secretKey);
$result = $tradeQuery->find($tradeNo, $channel);
$tradeQuery = new TradeQuery($merchantId, $secretKey);
$result = $tradeQuery->isPaid($tradeNo);
$merchantId = '123XXXXXXXX86'; // 商家號
$secretKey = 'XXXXXXXXXX'; // md5 密鑰
$tradeNo = '20170101235959XXX'; // 商家產生的唯一訂單號
$bank = Bank::ABOC; // 銀行編號
$amount = 100.00; // 消費金額 (元)
$clientIp = 'XXX.XXX.XXX.XXX'; // 消費者端 IP 位址
$notifyUrl = 'https://XXX.XXX.XXX'; // 交易完成後異步通知接口
$payment = new BankPayment($merchantId, $secretKey);
$result = $payment->order($tradeNo, $bank, $amount, $clientIp, $notifyUrl);
Post Data:
[
'code' => '0000'
'message' => '操作成功'
'data' => [
'merchant' => '123XXXXXXXX86' // 商家號
'tradeNo' => '20170101235959XXX' // 商家產生的唯一訂單號
'ordernumber' => '123XXXXXXXXXXXXXX890' // 聚合支付平台訂單號
'payType' => '3' // 交易類型,固定值 3
'amount' => '100.00' // 消費金額 (分)
'curType' => 'CNY' // 交易幣別
'status' => '1' // 訂單狀態 0.處理中、1.交易成功、2.交易失敗
'tradeTime' => '2017-08-01 09:00:00' // 交易時間
'sign' => '946XXXXXXXXXXXXXXXXXXXXXXXXXX008' // 簽名
]
]
$tradeQuery = new TradeQuery($merchantId, $secretKey);
$result = $tradeQuery->find($tradeNo);
$tradeQuery = new TradeQuery($merchantId, $secretKey);
$result = $tradeQuery->isPaid($tradeNo);