PHP code example of jetfueltw / biwpay-php

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


composer 

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

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

Post Data: 
[
    'trade_result' => 'X'; // 交易結果; 0 未支付 1 支付成功
    'mer_no' => 'XXXXXXXXXXXXXXX'; // 商家號 
    'mer_return_msg' => 'XXXXXXXX'; // 商戶返回信息說明
    'mer_order_no' => '20180109023351XXXXX'; // 商家產生的唯一訂單號
    'notify_type' => 'back_notify'; // 通知類型
    'currency' => 1; //幣種
    'trade_amount' => '1.00'; //交易金額 單位為元
    'order_date' => '2018-01-16 20:13:29'; // 訂單時間
    'pay_date' => '2018-01-16 22:13:29'; // 支付時間
    'order_no' => 'XXXXXXX'; //支付訂單號
    'sign_type' => 'MD5'; //簽名類型
    'sign' => 'XXXXXXXXXXXXXXXXXXXXXX'; //簽名 
]

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

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

$merchantId = 'XXXXXXXXXXXXXXX'; // 商家號
$secretKey = 'XXXXXXXXXXXXXXX'; // MD5 密鑰
$tradeNo = '20180109023351XXXXX'; // 商家產生的唯一訂單號
$bank = Bank::ABC; // 銀行編號
$amount = 1.00; // 消費金額 (元)
$notifyUrl = 'https://XXX.XXX.XXX'; // 交易完成後異步通知接口
$returnUrl = 'https://XXX.XXX.XXX'; // 交易完成後會跳轉到這個頁面

$payment = new BankPayment($merchantId, $secretKey);
$result = $payment->order($tradeNo, $bank, $amount, $notifyUrl, $returnUrl);