FromXml 支付回调 xml 转数组
public function xx(){
$xml = '<xml><appid><![CDATA[xxxxxxxxxxxxx]]></appid>
<bank_type><![CDATA[CFT]]></bank_type>
<cash_fee><![CDATA[]]></cash_fee>
<fee_type><![CDATA[CNY]]></fee_type>
<is_subscribe><![CDATA[N]]></is_subscribe>
<mch_id><![CDATA[xxxxxxxxxxxx]]></mch_id>
<nonce_str><![CDATA[xxxxxxxxxxxxx]]></nonce_str>
<openid><![CDATA[xxxxxxxxxxxxxxxxxxxxxxxxxx]]></openid>
<out_trade_no><![CDATA[111400xxxxxxxxxxxxxx]]></out_trade_no>
<result_code><![CDATA[SUCCESS]]></result_code>
<return_code><![CDATA[SUCCESS]]></return_code>
<sign><![CDATA[DBBB36A12ECE7E3Cxxxxxxxxxxxxxxxx]]></sign>
<time_end><![CDATA[]]></time_end>
<total_fee></total_fee>
<trade_type><![CDATA[JSAPI]]></trade_type>
<transaction_id><![CDATA[42000004xxxxxxxxxxxxxxxxxxxx3]]></transaction_id>
</xml>';
$data = $this->FromXml($xml);
dump($data);
}
public function FromXml($xml)
{
if(!$xml){
throw new WxPayException("xml数据异常!");
}
//将XML转为array
//禁止引用外部xml实体
libxml_disable_entity_loader(true);
$this->values = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
return $this->values;
}
<pre>array(16) {
["appid"] => string(18) "xxxxxxxxxxxxxxxxxxx"
["bank_type"] => string(3) "CFT"
["cash_fee"] => string(4) "3500"
["fee_type"] => string(3) "CNY"
["is_subscribe"] => string(1) "N"
["mch_id"] => string(10) "xxxxxxxxxxxxx"
["nonce_str"] => string(16) "Oec5xxxxxxxxxxxxx"
["openid"] => string(28) "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
["out_trade_no"] => string(18) "111400522494411933"
["result_code"] => string(7) "SUCCESS"
["return_code"] => string(7) "SUCCESS"
["sign"] => string(32) "DBBB36A12ECxxxxxxxxxxxxxxxxxxxxxxxxxx"
["time_end"] => string(14) "20191114005240"
["total_fee"] => string(4) "3500"
["trade_type"] => string(5) "JSAPI"
["transaction_id"] => string(28) "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
</pre>
FromXml 支付回调 xml 转数组的更多相关文章
- PHP:微信小程序调用【统一下单】【微信支付】【支付回调】API;XML转Array,Array转XML方法(通用)
1.微信公众号.微信小程序开发过程中,第三方服务器与微信服务器数据交互,需要进行数据转换,必须用到这两个函数: 分别是xml_to_array.array_to_xml ; /** * 输出xml字符 ...
- 原创:微信小程序调用【统一下单】、【支付】、【支付回调】api并处理请求
1.服务器端使用TP3.2处理(随便写在一个Controller里面) /* 小程序报名,生成订单 */ public function make_order(){ if(IS_POST){ $dat ...
- 微信支付重复回调,java微信支付回调问题
这几天一直在研究微信支付回调这个问题,发现之前微信支付回调都是正常的也没怎么在意,今天在自己项目上测试的时候发现相同的代码在我这个项目上微信支付回调老是重复执行导致支付成功之后的回调逻辑一直在执行,很 ...
- php对微信支付回调处理的方法(合集)
支付完成后,微信会把相关支付结果和用户信息发送给商户,商户需要接收处理,并返回应答. 对后台通知交互时,如果微信收到商户的应答不是成功或超时,微信认为通知失败,微信会通过一定的策略定期重新发起通知,尽 ...
- 到处都是坑的微信支付V3之 微信支付回调页面
据上次 到处都是坑的微信支付V3 后很多园友在被虐了千百遍后终于跳转到了亲切的微信支付界面,但输入密码支付后却不知道怎么处理了,接下来补上支付后的处理流程. 1. html中根据前台支付后反馈信息成功 ...
- 教你快速高效接入SDK——服务器端支付回调的处理方式
转载自:http://blog.csdn.net/chenjie19891104/article/details/48321427今天着重把之前渠道服务器端SDK的时候,遇到的一个蛋疼的问题给解决了. ...
- 微信JSAPI支付回调
在微信支付中,当用户支付成功后,微信会把相关支付结果和用户信息发送给商户,商户需要接收处理,并返回应答. 在经历了千幸万苦之,填完了所有的JSAPI支付的坑后(微信JSAPI支付 跟 所遇到的那些坑) ...
- 微信支付回调,XXE攻击漏洞防止方法
最近微信支付回调发现的XXE攻击漏洞(什么是XXE攻击,度娘.bing去搜,一搜一大把),收到通知后即检查代码, 微信给的解决方法是如果你使用的是: XmlDocument: XmlDocument ...
- PHP7 微信支付回调失败 解决
升级完PHP7 发现微信支付回调失败.原来是 $GLOBALS['HTTP_RAW_POST_DATA'];没有定义的问题.php7 移除了这个全局变量. 问题代码如下: 微信API :WxPay.A ...
随机推荐
- ES6中Number中的扩展
1.Number.parseInt() , Number.parseFloat() 在ES6中将parseInt()和parseFloat()都移植到Number对象上去,方法的行为保持不变. // ...
- Python通过xpath查找元素通过selenium读取元素信息
#coding:utf-8 from selenium import webdriver import time url ='http://www.baidu.com' driver = webdri ...
- hiveSQL常用日期函数
注意 MM,DD,MO,TU 等要大写 Hive 可以在 where 条件中使用 case when 已知日期 要求日期 语句 结果 本周任意一天 本周一 select date_sub(next_d ...
- python高性能编程 读书笔记
GIL 确保 Python 进程一次只能执行一条指令 ====分析工具cProfile 分析函数耗时line_profiler 逐行分析 heapy 追踪 Python 内存中所有的对象— 这对于消 ...
- 关于AndroidStudio的apk打包遇到的问题记录
12月份末尾,想来个总结,主要是得记一些重要的. 首先就得是AndroidStudi内的apk打包,就是弄当前项目app的安装包出来. 下面就说下具体步骤和注意问题. 首先 : 看到AndroidSt ...
- 域渗透:pth(pass the hash)
pass the hash原理: 在Windows系统中,通常会使用NTLM身份认证,NTLM认证不使用明文口令,而是使用口令加密后的hash值,hash值由系统API生成(例如LsaLogonUse ...
- LeetCode 1059. All Paths from Source Lead to Destination
原题链接在这里:https://leetcode.com/problems/all-paths-from-source-lead-to-destination/ 题目: Given the edges ...
- SpringBoot第二节(SpringBoot整合Mybatis)
1.创建Spring Initiallizr项目 一直点击下一步 2.引入依赖 <dependencies> <dependency> <groupId>org.s ...
- 使用Quasar设计Material和IOS风格的响应式网站
使用Quasar设计Material和IOS风格的响应式网站 栏目: CSS · 发布时间: 8个月前 来源: segmentfault.com 本文转载自:https://segmentfaul ...
- learning java 重定向标准输入输出
output redirectionOut: public class RedirectOut { public static void main(String[] args) throws File ...