<xml><appid><![CDATA[wxf2e83f1160dfcxxx]]></appid><bank_type><![CDATA[ICBC_DEBIT]]></bank_type>/<cash_fee><![CDATA[1]]></cash_fee>/<fee_type><![CDATA[CNY]]></fee_type>/<is_subscribe><![CDATA[N]]></is_subscribe>/<mch_id><![CDATA[130xxx8601]]></mch_id>/<nonce_str><![CDATA[LhpVcEPpTNASOaQysNFNlYLrpMgyWDLa]]></nonce_str>/<openid><![CDATA[oC7xr5TZehbHbe__UUNPJzDapxxx]]></openid>/<out_trade_no><![CDATA[1528360591]]></out_trade_no>/<result_code><![CDATA[SUCCESS]]></result_code>/<return_code><![CDATA[SUCCESS]]></return_code>/<sign><![CDATA[766868113312ED3C141BF3D3487D1BDF]]></sign>/<time_end><![CDATA[20180607163654]]></time_end>/<total_fee>1</total_fee>/<trade_type><![CDATA[JSAPI]]></trade_type>/<transaction_id><![CDATA[4200000123201806075922186660]]></transaction_id>/</xml>

{"appid":"wxf2e83f1160dfcxxx","bank_type":"ICBC_DEBIT","cash_fee":"1","fee_type":"CNY","is_subscribe":"N","mch_id":"130xxx8601","nonce_str":"yHbHrfbyDnWvRuogoOLWffsuFEXhDBeT","openid":"oC7xr5TZehbHbe__UUNPJzDapxxx","out_trade_no":"1528361071","result_code":"SUCCESS","return_code":"SUCCESS","sign":"364C903E8668AE6B49A1EE2B7A217D97","time_end":"20180607164442","total_fee":"1","trade_type":"JSAPI","transaction_id":"4200000126201806078162413986"}

接收并处理

$data['postStr']=isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : file_get_contents("php://input");
$postdata = json_decode(json_encode(simplexml_load_string($data['postStr'], 'SimpleXMLElement', LIBXML_NOCDATA)), true);

JSON格式化

{
    "appid": "wxf2e83f1160dfcxxx",
    "bank_type": "ICBC_DEBIT",
    "cash_fee": "1",
    "fee_type": "CNY",
    "is_subscribe": "N",
    "mch_id": "130xxx8601",
    "nonce_str": "yHbHrfbyDnWvRuogoOLWffsuFEXhDBeT",
    "openid": "oC7xr5TZehbHbe__UUNPJzDapxxx",
    "out_trade_no": "1528361071",
    "result_code": "SUCCESS",
    "return_code": "SUCCESS",
    "sign": "364C903E8668AE6B49A1EE2B7A217D97",
    "time_end": "20180607164442",
    "total_fee": "1",
    "trade_type": "JSAPI",
    "transaction_id": "4200000126201806078162413986"
}

官方文档:https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=9_7&index=8

发表评论

电子邮件地址不会被公开。 必填项已用*标注