PHP code example of djlin / wechatpayapi

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

    

djlin / wechatpayapi example snippets



use Wechatpayapi\Wechatpay;
$mp = array(
    'appid'=>'',//微信appid
    'mch_id'=>'',//商户号
    'key'=>'',//key
);
$w = new Wechatpay($mp);

$data = array(
    'body' => '商品描述',
    'out_trade_no' => '订单号',
    'total_fee' => '金额(分)',
    'notify_url' => '回调地址',
);
$res = $w->wechatAppPay($data);

//查询订单
$data = array(
    'out_trade_no' => '订单号',
);
$res = $w->wechatOrderresult($data);