微信支払コールバック処理
4675 ワード
微信支払コールバック処理
WeChat公式支払ドキュメント:
https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_1
公式DEMO:
https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=11_1
//
public function app_notify()
{
//
$data = file_get_contents('php://input');
$result = xmlToArray($data);
if($result['return_code'] == 'SUCCESS'){
//attach
$attach = $result['attach'];
//
$out_trade_no = $result['out_trade_no'];
//
echo "success";
}else{
echo "fail";
}
}
// XML array
function xmlToArray($xml)
{
// xml
libxml_disable_entity_loader(true);
$values = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
return $values;
}