@canner/pay2gojs
v3.1.0
Published
pay2go
Downloads
51
Readme
pay2gojs
damn easy pay2go api for express
usage
一次付費
const app = express();
const pay2GoClient = new pay2go.Client({...});
app.use('/product/payment', pay2GoClient.serve({
baseUrl: "/product/payment",
beforeCharged: ({parameter, dataStore}) => {
parameter.setAmount(300);
parameter.setDesc("description");
return dataStore.setData({
name: "wwwy3y3"
});
},
afterCharged: ({data}) => {
data.name.should.be.eql('wwwy3y3');
}
}));
定期定額
NOTICE
afterStart
在 PeriodStartType=2 的時候,馬上執行首刷,會比onCharge
早回來- PeriodStartType=2 的時候,馬上首刷,但如果今天的日期不是 PeriodPoint 的日期,會多收一期的費用,換句話說,想要每月10號收費,今天是10號的話,就是總共 12 期,收了第一期,剩下11期,但是如果今天是11號,則總共13期,,下個月10號才會收第二期
const app = express();
const pay2GoClient = new pay2go.PeriodClient({...});
app.use('/product/:productId/payment', pay2GoClient.serve({
beforeStart: ({parameter, dataStore}) => {
parameter.setParam('PeriodAmt', 10000);
parameter.setParam('ProdDesc', "description");
parameter.setParam('PeriodPoint', "13");
parameter.setParam('PeriodStartType', 2);
parameter.setParam('PayerEmail', "[email protected]");
return dataStore.setData({
name: "wwwy3y3"
});
},
afterStart: ({data, result}) => {
console.log(data);
console.log(result);
},
onCharge: ({orderNo, result}) => {
console.log(orderNo);
console.log(result);
}
}));