PHP code example of ddliu / wxpay
1. Go to this page and download the library: Download ddliu/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/ */
ddliu / wxpay example snippets
use ddliu\wxpay\Notify;
$notify = new Notify();
$data = $notify->checkNotifyData();
if (!$data) {
// 检查通知数据失败
$notify->replyFail();
} elseif ($data['result_code'] == 'SUCCESS') {
// 支付成功
$orderNo = $data['out_trade_no'];
// 查询数据库取得订单信息
// $order = query_my_order($orderNo);
// 处理成功逻辑
// 响应通知
$notify->replySuccess();
} else {
// 处理失败逻辑
// 检查通知数据失败
$notify->replyFail();
}