ihaolin / wepay Goto Github PK
View Code? Open in Web Editor NEW轻量的微信支付组件(A Lightweight Wechat Pay Component)
License: MIT License
轻量的微信支付组件(A Lightweight Wechat Pay Component)
License: MIT License
[FAIL]签名错误
在component中是有doverifysign(String xml)会先校验return_code
但是在NOtifies中verifySign是(Map)---调用doVerifySign(Map),没有校验return_Code。
把这个doVerifySign入参改了,校验return_code.
或者在notifies中加个toMap(xml){super.toMap(xml)}? 你觉得怎么样。
在wepay-core模块中,PayRequest.java中,注释上写的是“客户端IP”,但是起的变量名是clientId,请问这是有特殊含义还是手误写错了?
返回的xml为:
<return_code></return_code>
<return_msg></return_msg>
估计是因为中文引起的。
stack:
com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: 2 字节的 UTF-8 序列的字节 2 无效。
at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:691) ~[na:1.8.0_31]
at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:372) ~[na:1.8.0_31]
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1743) ~[na:1.8.0_31]
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.scanData(XMLEntityScanner.java:1256) ~[na:1.8.0_31]
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanCDATASection(XMLDocumentFragmentScannerImpl.java:1654) ~[na:1.8.0_31]
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3020) ~[na:1.8.0_31]
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606) ~[na:1.8.0_31]
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510) ~[na:1.8.0_31]
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848) ~[na:1.8.0_31]
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777) ~[na:1.8.0_31]
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) ~[na:1.8.0_31]
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243) ~[na:1.8.0_31]
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:348) ~[na:1.8.0_31]
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121) ~[na:1.8.0_31]
at me.hao0.common.xml.XmlReaders.create(XmlReaders.java:43) ~[common-1.1.0.jar:na]
at me.hao0.common.xml.XmlReaders.create(XmlReaders.java:37) ~[common-1.1.0.jar:na]
at me.hao0.wepay.core.Component.readResp(Component.java:62) ~[wepay-core-1.1.2.jar:na]
at me.hao0.wepay.core.Component.toMap(Component.java:52) ~[wepay-core-1.1.2.jar:na]
at me.hao0.wepay.core.Component.doPost(Component.java:31) ~[wepay-core-1.1.2.jar:na]
at me.hao0.wepay.core.Pays.doPay(Pays.java:128) ~[wepay-core-1.1.2.jar:na]
at me.hao0.wepay.core.Pays.doJsPay(Pays.java:102) ~[wepay-core-1.1.2.jar:na]
at me.hao0.wepay.core.Pays.jsPay(Pays.java:50) ~[wepay-core-1.1.2.jar:na]
首先赞一下作者的项目,实实在在降低了支付接入的门槛,但看测试用例,都是面向pc的,那当前项目是否也适合移动端的支付呢?
在doVerifySign时应该在效验结果false的时候throw个runtimeException? 或者直接返回false。
xml替换空格后,转换的map里面多了一个#text字段。建议重新将空格去除。
me.hao0.wepay.exception.WepayException: java.io.IOException: keystore password was incorrect
Path path = Paths.get("C:\nginx-1.15.12\web\1416758702_20190529_cert\apiclient_cert.p12");
byte[] data = Files.readAllBytes(path);
// 加载证书文件
wepay = WepayBuilder.newBuilder(appid, secret, mchId)
.certPasswd(mchId)
.certs(data)
.build();
AppPayResponse 的“签名”属性命名为 paySign 是有其他考虑么?谢谢
需求:获取微信服务器返回的报文信息
解决:
在 me.hao0.wepay.core.Component
增加以下代码来满足需求
private Map<String, String> responseXml = new ConcurrentHashMap<>();
public String getAndRemoveRespXml(String outTradeNo) {
return responseXml.remove(outTradeNo); // 无需考虑 outTradeNo 多个 responseXml
}
楼主能否提供微信服务器返回的报文信息,谢谢
作者你好:
RefundQueryResponse查询退款里为什么没有退款状态字段? 我想要维护我退款单状态。
一直用你的组件,来完成微信和支付宝的支付,建议提供企业付款到银行卡和企业付款到零钱的接口。
项目除了使用 code_url,还需要用到 prepay_id,能否提供 prepay_id 的获取方法。谢谢!
周末愉快~
不知道是不是有中文的原因
返回结果:
<xml><return_code><![CDATA[SUCCESS]]></return_code> <return_msg><![CDATA[OK]]></return_msg> <appid><![CDATA[wxe37]]></appid> <mch_id><![CDATA[137]]></mch_id> <nonce_str><![CDATA[AYySchVKar2W0Ynb]]></nonce_str> <sign><![CDATA[C2DD53C14B94761843CEA701254B8E4]]></sign> <result_code><![CDATA[FAIL]]></result_code> <err_code><![CDATA[OUT_TRADE_NO_USED]]></err_code> <err_code_des><![CDATA[商户订单号重复]]></err_code_des> </xml>
me.hao0.common.exception.XmlException: Xmls create fail at me.hao0.common.xml.XmlReaders.create(XmlReaders.java:45) at me.hao0.common.xml.XmlReaders.create(XmlReaders.java:37) at me.hao0.wepay.core.Component.readResp(Component.java:62) at me.hao0.wepay.core.Component.toMap(Component.java:52) at me.hao0.wepay.core.Component.doPost(Component.java:31) at me.hao0.wepay.core.Pays.doPay(Pays.java:128) at me.hao0.wepay.core.Pays.doAppPay(Pays.java:112) at me.hao0.wepay.core.Pays.appPay(Pays.java:90) at com.tn.shop.service.WepayService.appPay(WepayService.java:59) at com.tn.shop.service.WepayService$$FastClassByCGLIB$$146187c5.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) at com.tn.shop.service.WepayService$$EnhancerBySpringCGLIB$$e2fe1e22.appPay(<generated>) at com.tn.shop.controller.api.payment.PayController.pay(PayController.java:108) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:653) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at com.tn.shop.filter.RequestLogFilter.doFilter(RequestLogFilter.java:59) at com.tn.shop.filter.AbstractFilter.doFilter(AbstractFilter.java:28) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218) at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:122) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1082) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:623) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2517) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2506) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) Caused by: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: 2 字节的 UTF-8 序列的字节 2 无效。 at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:691) at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:372) at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1743) at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.scanData(XMLEntityScanner.java:1242) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanCDATASection(XMLDocumentFragmentScannerImpl.java:1654) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3020) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:348) at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121) at me.hao0.common.xml.XmlReaders.create(XmlReaders.java:43) ... 68 more
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.