1. Go to this page and download the library: Download papajo/wxpay 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/ */
papajo / wxpay example snippets
use WXPay\WXPay;
use WXPay\WXPayConstants;
use WXPay\WXPayUtil;
$wxpay = new WXPay(
'wx888888888', // appid
'22222222', // mch id
'123456781234567812345678', // key
'/path/to/apiclient_cert.pem',
'/path/to/apiclient_key.pem',
6000); // 超时时间,毫秒
$resp = $wxpay->orderQuery(array(
'out_trade_no' => '201610265257070987061763',
'total_fee' => 1,
'body' => '腾讯充值中心-QQ会员充值',
'spbill_create_ip' => '123.12.12.123',
'trade_type' => 'NATIVE',
'notify_url' => 'https://www.example.com/wxpay/notify'
));
var_dump($resp);
use WXPay\WXPay;
use WXPay\WXPayConstants;
use WXPay\WXPayUtil;
$wxpay = new WXPay(
'wx888888888', // appid
'22222222', // mch id
'123456781234567812345678', // key
'/path/to/apiclient_cert.pem',
'/path/to/apiclient_key.pem',
6000); // 超时时间,毫秒
$resp = $wxpay->orderQuery(array('out_trade_no' => '201610265257070987061763'));
var_dump($resp);