fym201 / alipay-node-sdk Goto Github PK
View Code? Open in Web Editor NEW支付宝新版App支付nodejs版sdk.
License: MIT License
支付宝新版App支付nodejs版sdk.
License: MIT License
版本信息:"version": "1.1.9"
函数:props.preCreate = function (opts) {
var biz_content = {
out_trade_no: opts.outTradeId,
subject: opts.subject,
total_amount: opts.amount,
body: opts.body,
timeout_express: opts.timeout,
goods_detail: opts.goodsDetail,
extend_params: opts.extendParams,
enable_pay_channels: opts.enablePayChannels,
disable_pay_channels: opts.disablePayChannels
};
var params = this.makeParams('alipay.trade.precreate', biz_content);
params.notify_url = this.notifyUrl;
// params.return_url = opts.return_url;
var body = utl.processParams(params, this.rsaPrivate, this.signType);
//缺少步骤
return utl.request({
method: 'GET',
url: (this.sandbox? alipay_gate_way_sandbox : alipay_gate_way) + '?' + body
});
//原步骤已注释
// return utl.processParams(params, this.rsaPrivate, this.signType);
};
望修复
调用你的回调验签方法,算不对啊一直都是false
app_id=2017051707267063&biz_content=%7B%22body%22%3A%22%E7%B1%B3%E5%85%9C%E8%B4%A6%E6%88%B7%E5%85%85%E5%80%BC20%E5%85%83%22%2C%22subject%22%3A%22%E7%B1%B3%E5%85%9C%E8%B4%A6%E6%88%B7%E5%85%85%E5%80%BC%22%2C%22out_trade_no%22%3A%22592647955ad2b1452073ef7f%22%2C%22timeout_express%22%3A%2210m%22%2C%22total_amount%22%3A20%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%2C%22goods_type%22%3A%22balance%22%7D&charset=utf-8&format=JSON&method=alipay.trade.app.pay¬ify_url=https%3A%2F%2Fwxu.midoull.com%2Fapi%2Fwebhooks%2Falipay&sign_type=RSA2×tamp=2017-05-25%2010%3A56%3A24&version=1.0&sign=RG2rgWeDtMEX89W0gYCkRlpQItggqpzF8aBVofE62CQtq%2BCgT9ly%2BD4AG5b27DaWrdDDG6VFuqBhQ9wzb4BS%2BJUrKdrRJLLz1ohmAQrHGKij%2FzBO6hdFdsp9UnqlJUiNyYXEjmz2ANvA8K%2FnfDaraS0ZpRIaOu%2FcYKbLWprho4b2Jhdh4oqrZdzcdc2B1b%2BRCebwSHU7ahUxxQciB44C5XGeLK7aBq%2ByD5Is2Ha63%2F2RPavTLApjpFE22G%2Fwp7SIBnIO7cLFoTCbnR4RgsgS2Kax7K7lMwFpU0EhXUSndYof4zUK5JfMpuK8IPgdTyJGHzSzApODiOQY3saapsdeQg%3D%3D
以上是我得到的,但希望是JSON格式的。
:)
meteor node -v
v4.8.4
node_modules/alipay-node-sdk/lib/utl.js:138
let ret = {response:res, body:body};
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
只要把这个let 改下就可以了
如题,想在支付宝小程序里,集成支付宝支付的功能。可以用这个开源项目吗?谢谢
alipays.query({
outTradeId: '201807069324414819'
}).then(function (ret) {
console.log("***** ret.body=" + ret.body);
//签名校验
var ok = alipay.signVerify(ret.body);
console.log(ok);
});
UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Hash must be a string or a buffer
是否支持RSA2?
error:0906D06C:PEM routines:PEM_read_bio:no start line这是什么错
router.post('/path/to/notify_url', async(req, res) => {
console.log(req.body)
console.log(req)
})
交易完成后,notify_url有响应,收到了些信息
req.body为空: {}
req里找不到任何关于交易的信息,比如交易编号,交易状态等
return_url ,这个是公共参数,你写入了请求参数里面了,导致支付后无法跳转。
router.get('/return', function (req, res) {
var lalala = ali.signVerify(req.query);
if (lalala === false) {
return res.error("回调签名验证未通过");
}
//获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表(以下仅供参考)//
var trade_no = req.query["trade_no"]; //支付宝交易号
var order_no = req.query["out_trade_no"]; //获取订单号
var total_amount = req.query["total_amount"]; //获取总金额
//var buyer_email = req.query.buyer_email; //买家支付宝账号
var trade_status = req.query["trade_status"]; //交易状态
if ( trade_status == "TRADE_SUCCESS") {
//判断该笔订单是否在商户网站中已经做过处理
//如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
//如果有做过处理,不执行商户的业务程序
handleRecharge(order_no, res);
}
res.end("success");
});
router.post('/notify', function (req, res) {
var lalala = ali.signVerify(req.body);
if (lalala === false) {
return res.error("回调签名验证未通过");
}
//获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表(以下仅供参考)//
var trade_no = req.body["trade_no"]; //支付宝交易号
var order_no = req.body["out_trade_no"]; //获取订单号
var total_amount = req.body["total_amount"]; //获取总金额
//var buyer_email = req.query.buyer_email; //买家支付宝账号
var trade_status = req.body["trade_status"]; //交易状态
if (trade_status == "TRADE_SUCCESS") {
//判断该笔订单是否在商户网站中已经做过处理
//如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
//如果有做过处理,不执行商户的业务程序
handleRecharge(order_no, res);
}
res.end("success");
});
我阿里支付上只有一串字符,没有文件生成呀?不知道应该怎么生成这个pem文件
你好,我的Nodejs 版本是 v4.4.5,能否给个可以运行的Demo呢? 非常感谢(我不会Nodejs)!
您好,我参考了test下index.js代码,但是调起支付时,后台报了一个'fs.readFileSync is not a function'的错误。找了一下没发现解决办法,所以过来请教您一下。。。
{"result":"{\"alipay_trade_app_pay_response\":{\"code\":\"40002\",\"msg\":\"Invalid Arguments\",\"sub_code\":\"isv.invalid-signature\",\"sub_msg\":\"无效签名\"}}","resultStatus":"4000","memo":""}
我的配置如下
alipay: {
appId: '2017051707267063',
notifyUrl: `${protocol}://${domain}/api/webhooks/alipay`,
rsaPrivate: path.resolve(root + '/cert/alipay/private.txt'),
rsaPublic: path.resolve(root + '/cert/alipay/public.txt'),
// sandbox: true,
signType: 'RSA2'
}
问题1:支持RSA2吗?
问题2:rsaPrivate,rsaPublic 都是指什么呀?
问题3:开放平台里有【 查看应用公钥 | 查看支付宝公钥】,我是应该用哪个呢?
var params = ali.pagePay({
});
console.log(params);
然后请求带参数请求支付宝网关,获取一个支付二维码的页面。
那么怎么才能实现把这个页面的二维码嵌套进前端页面,好让用户付款。
请问应该使用的是pkcs8还是pkcs1?这边使用pkcs1的一直无法成功。
这是我生成的测试
http://api.1pai.ren/api/v1/pay/getAlipay
after call ali.pagePay
,i got params
, compose the params with alipay gateway, the link is :
but the link looks is not a right link, any problem, could you help check it?
sorry, i write this issue on ubunut , do not install Chinese input
出现很多%%%%
您好,
我这边调试始终报 订单参数异常(ALIN42273)错误;
部分代码:
var ali = new Alipay({
appId: '2019021863225883',
notifyUrl: 'http://0000000/api/pay/notify.js',
rsaPrivate: path.resolve('../key/alipem/yh_private_1.pem'),
rsaPublic: path.resolve('../key/alipem/alipay_public_1.pem'),
sandbox: true,
signType: 'RSA2'
});
var appparams = ali.appPay({
subject: '测试商品',
body: '测试商品描述',
outTradeId: outTradeId,
timeout: '5m',
amount: "'"+query.total+"'",
goodsType: '0'
});
console.log('ali.appPay:',appparams);
res.send(appparams);
用支付宝公钥验证签名的时候一直返回false,用支付宝工具验证签名是正确的
得到参数后要向支付宝发请求吗?
这个参数可以不填吗?支付后支付宝调用这个地址通知商户,又不能带参数有什么用?
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.