biangbiang / wxpay-php Goto Github PK
View Code? Open in Web Editor NEWphp项目基于微信支付JS SDK和JS API的接入开发
License: MIT License
php项目基于微信支付JS SDK和JS API的接入开发
License: MIT License
借楼问一下。还没成功调用过,有很多疑问。
为什么我就没有找到一个成功的demo。
官方的demo支付窗口出不来。
我自己支付的时候 config可以成功,但是调用支付的时候就失败了 没有任何错误代码。
一直提示choseWXPay:fail
export const wxpay = ({timestamp, nonceStr, wxPackage, signType = "MD5", paySign, success, fail, complete, cancel}) => {
wx.chooseWXPay({
timestamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
nonceStr, // 支付签名随机串,不长于 32 位
package: wxPackage, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=***)
signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
paySign, // 支付签名
success,
fail,
complete,
cancel,
});
}
export function wxpay2({timestamp, nonceStr, wxPackage, signType = "MD5", paySign, success, fail, complete, cancel}) {
function onBridgeReady() {
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
"appId": WX_APPID, //公众号名称,由商户传入
"timestamp": timestamp, //时间戳,自1970年以来的秒数
"nonceStr": nonceStr, //随机串
"package": wxPackage,
"signType": signType, //微信签名方式:
"paySign": paySign //微信签名
},
fail
);
}
if (typeof WeixinJSBridge == "undefined") {
if (document.addEventListener) {
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false)
} else if (document.attachEvent) {
document.attachEvent('WeixinJSBridgeReady', onBridgeReady)
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady)
}
} else {
onBridgeReady()
}
}
以上两种方法我都试过,签名也和签名验证工具一致的。
上面说新版本用MD5
我也换过md5 ,签名的时候timeStamp也换成过大写S 最后还是以失败告终。
由于官方文档太混乱,前后不一致 和demo也不一致,只能来问一下老司机了。
最后调通了 研读了一下官方的php demo 签名方法,发现和全部文档都不一致,不需要jstickt 不需要url,签名发字段名全部都是驼峰
求指教,
支持composer更好。。。。。
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.