0.1.2 • Published 7 years ago

alipayment v0.1.2

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

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);
});

其他API请求参数,请参看以下链接

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago