node-alipay
v0.0.4
Published
alipay interface for node
Downloads
2
Readme
node-alipay
alipay apis for node
Install
$ npm install --save node-alipay
Support
=======
crypt supported: md5, rsa(not tested)
sub module support list: mobile wap
Key Generation
Private keygen:
windows/linux:
genrsa -out rsa_private_key.pem 4096
mac:
openssl genrsa -out rsa_private_key.pem 4096
Public keygen:
windows/linux:
rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem
mac
openssl rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem
Usage
var alipay = require("node-alipay");
var keys = require('./keys');
var baseUrl = "";
var partner = "";
var account = ""; //seller_account_name
var product = "鞋子"; //subject
var id = '1010'; //req_id
var orderNo = "183828282822"; //out_trade_no
var fee = 0.01; //total_fee
var user_id = 1; //user_id
var data = {
partner: partner,
account: account,
urls: {
callback: baseUrl + '/alipay/callback',
notify: baseUrl + '/alipay/notify',
merchant: baseUrl + '/alipay/merchant'
}
};
var auth = alipay.mobile.auth.get(data, keys);
auth.update(id, product, orderNo, fee, user_id);
auth.request(function (error, token) {
var exec = alipay.mobile.exec.get(data, keys, token);
exec.request(function (error, data) {
console.log(data);
});
});
keys file format:
var privateKey = "";
var publicKey = "";
var aliPublicKey = "";
var md5Key = "";
module.exports = {
rsa: {
private: privateKey,
public: publicKey
},
md5: md5Key,
aliKey: aliPublicKey
}