alipayment-fork
v0.1.4
Published
Alipay sdk for nodejs, forked from https://github.com/EasingLab/alipayment
Downloads
4
Readme
alipayment
支付宝开放平台API Request For Nodejs,支持RSA和RSA2签名。
Installation
$ npm install alipayment
API
实例化
var alipayment = new Alipayment({
appId: "<APPID>",
privateKey: "<应用私钥>", //需要PKCS8格式
publicKey: "<支付宝公钥>",
gateway: "<支付网关地址>"
});
//gateway线上: https://openapi.alipay.com/gateway.do
//gateway sanbox: https://openapi.alipaydev.com/gateway.do
获取wap支付地址
/*
* @params <object> 请求参数
* @return <string> 需要跳转的支付地址
*/
tradePayment.getRequestURI({
method: "alipay.trade.wap.pay",
sign_type: "RSA2",
return_url: "http://localhost:8200",
biz_content: JSON.stringify({
body: "支付测试",
subject: "支付测试",
out_trade_no: "201688888",
total_amount: 1.0,
product_code: "QUICK_WAP_PAY"
})
});
支付报文签名验证
/*
* @params <object> 支付异步或者Return回调请求参数
* @return <true | false>
*/
tradePayment.verifySign(params)
订单查询
tradePayment.request({
method: "alipay.trade.query",
sign_type: "RSA2",
biz_content: JSON.stringify({
out_trade_no: <商户订单号>
})
}).then(function(body) {
console.log(body);
}).catch(function(err) {
console.log(err);
});