easypay
v1.0.2
Published
Node.js Alipay SDK
Downloads
3
Readme
Node.js Alipay SDK
Requirements
Node.js v7+
API Interface
- Web Payment
| Parameter | Type | Usage | | ---- | ---- | ---- | | amount | String | Transaction amount (formatted "0.01") | | name | String | Product Name | | description | String | Product Description | | return_url | String | Return URL | | notify_url | String | Alipay official callback API | | out_trade_no | String | Merchant-side identifier |
- Refund
| Parameter | Type | Usage | | ---- | ---- | ---- | | refund_amount | String | Refund amount (formatted "0.01") | | trade_no | String | Either fill in trade_no or out_trade_no to make it work | | out_trade_no | String | Use merchant-side identifier to signal a refund |
Example
- Web Payment
var fs = require('fs');
var alipay = require('./lib')
var Alipay = new alipay({
privateKey: fs.readFileSync('./app_private_key.pem'),
publicKey: fs.readFileSync('./app_public_key.pem'),
app_id: 'your_app_id'
})
console.log(Alipay.webPayment({
amount: "0.01",
name: 'iPhone X'
}))
- Refund
var fs = require('fs');
var alipay = require('./lib')
var Alipay = new alipay({
privateKey: fs.readFileSync('./app_private_key.pem'),
publicKey: fs.readFileSync('./app_public_key.pem'),
app_id: 'your_app_id'
})
Alipay.refund({
refund_amount: '1.00',
trade_no: 'your_trade_no'
}).then((body) => {
console.log(body);
}).catch((err) => {
console.log('ERR: ' + err);
});