PHP code example of lyhiving / payjs

1. Go to this page and download the library: Download lyhiving/payjs 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/ */

    

lyhiving / payjs example snippets

$xslt

s\Payjs;

$payjs = new Payjs([
    //jspay商户号id
    'AK' => '',
    //jspay商户密钥
    'SK' => ''
]);

//订单id
$orderid = 'OID_' . time();  
//订单金额,单位是分,也就是说101为收1.01RMB  
$total_fee = 101;  
//商品说明  
$body = '测试订单';  

//增加回传数据,适合支付,不适用查询
$payjs = $payjs->attach($attach);  

//如果想指定回调地址
$payjs = $payjs->notify($notifyurl);  

//扫码支付  
$r1 = $payjs->qrpay($orderid,$total_fee,$body);  
print_r($r1);  

//收银台模式
$gourl ='';//暂时不支持跳转,如果有填写会出错。以后支持即为支付后跳转
$r2 = $payjs->cashier($orderid, $total_fee, $body, $gourl);
print_r($r2);


//查询订单
$r3= $payjs->Query($orderid);
print_r($r3);