Exemplo n.º 1
0
use Thenbsp\Wechat\Util\Util;
use Thenbsp\Wechat\Util\Json;
use Thenbsp\Wechat\Util\Cache;
try {
    $cache = new Cache('../Storage');
} catch (\Exception $e) {
    exit($e->getMessage());
}
if (!($request = @file_get_contents('php://input'))) {
    exit('Invalid Request');
}
/**
 * 微信服务器请求过来的数据
 */
$request = Util::XML2Array($request);
$cache->set('payment_notify', $request);
// 微信服务器会在支付成功后该求该 URL,以 XML 的方式提交此次支付信息,具体信息类似:
// {
//     "appid":"wx345f3830c28971f4",
//     "bank_type":"CFT",
//     "cash_fee":"1",
//     "fee_type":"CNY",
//     "is_subscribe":"Y",
//     "mch_id":"1241642202",
//     "nonce_str":"fTbkMTXgMmnvTaO1",
//     "openid":"oWY-5jjLjo7pYUK86JPpwvcnF2Js",
//     "out_trade_no":"124164220220150803161536",
//     "result_code":"SUCCESS",
//     "return_code":"SUCCESS",
//     "sign":"4B8948BD3E831394C956B5DFA8AAEB1E",
//     "time_end":"20150803161547",
Exemplo n.º 2
0
<?php

require './config.php';
use Thenbsp\Wechat\Util\Util;
use Thenbsp\Wechat\Util\Json;
use Thenbsp\Wechat\Util\Cache;
try {
    $cache = new Cache('../Storage');
} catch (\Exception $e) {
    exit($e->getMessage());
}
if ($request = @file_get_contents('php://input')) {
    $content = Util::XML2Array($request);
    $cache->set('payment_notify', Json::encode($content));
}
// 微信服务器会在支付成功后该求该 URL,以 XML 的方式提交此次支付信息,具体信息类似:
// {
//     "appid":"wx345f3830c28971f4",
//     "bank_type":"CFT",
//     "cash_fee":"1",
//     "fee_type":"CNY",
//     "is_subscribe":"Y",
//     "mch_id":"1241642202",
//     "nonce_str":"fTbkMTXgMmnvTaO1",
//     "openid":"oWY-5jjLjo7pYUK86JPpwvcnF2Js",
//     "out_trade_no":"124164220220150803161536",
//     "result_code":"SUCCESS",
//     "return_code":"SUCCESS",
//     "sign":"4B8948BD3E831394C956B5DFA8AAEB1E",
//     "time_end":"20150803161547",
//     "total_fee":"1",