PHP code example of jetfueltw / gaotongpay-php

1. Go to this page and download the library: Download jetfueltw/gaotongpay-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 / gaotongpay-php example snippets


composer 

$merchantId = 'XXXXXXXXXXXXXXX'; // 商家號
$secretKey = 'XXXXXXXXXXXXXXX'; // md5 密鑰
$tradeNo = '20180109023351XXXXX'; // 商家產生的唯一訂單號
$channel = Channel::WECHAT; // 支付通道,支援微信支付、QQ錢包
$amount = 1.00; // 消費金額 (元)
$notifyUrl = 'https://XXX.XXX.XXX'; // 交易完成後異步通知接口


$payment = new DigitalPayment(merchantId, secretKey);
$result = $payment->order($tradeNo, $channel, $amount, $notifyUrl);

Post Data: 
[
    'partner' => 'XXXXXXXXXXXXXXX'; // 商家號
    'ordernumber' => '20180109023351XXXXX'; // 商家產生的唯一訂單號
    'orderstatus' => 'X'; //1:支付成功,非1為支付失敗
    'paymoney'  => 1.00; //元
    'sysnumber' => 'XXXXXXXXXXXXX' //此次交易中高通支付介面系統內的訂單ID
    'attach' => 'XXXXXXXXXX' // 備註訊息
    'sign' => 'XXXXXXXXXXXXXXXXXXXXXX' // md5簽名
]

$tradeQuery = new TradeQuery(merchantId, secretKey);
$result = $tradeQuery->find($tradeNo);

Result:
[
    'data' => //如果查詢失敗此欄會回傳 null
      [
        'r1_mchtid' => 'XXXXXXXXXXXXXXX'; // 商家號
        'r2_systemorderno' => 'XXXXXXXXXXXXXXXXX' //平台唯一流水号
        'r3_orderno' => '20180109023351XXXXX'; // 商家產生的唯一訂單號
        'r4_amount' => 1.00; //订单交易金额
        'r5_orderstate' => 'X'; //0.支付中 1.成功,2.失败,3.失败
        'r6_version' => 'v2.8';
        'sign' => 'XXXXXXXXXXXXXXXXXXXXXX' // md5簽名
      ]
    'rspCode' => '1' //1表示成功
    'rspMsg' => 'XXXXXX' // 回覆訊息
]

$tradeQuery = new TradeQuery($merchantId, $secretKey);
$result = $tradeQuery->isPaid($tradeNo);