0.1.2 • Published 5 years ago
trimepay-node v0.1.2
trimepay-node
Continuous integration status:
NPM status:
Install
yarn add trimepay-node
Types files is bundled so you don't need to install external typings.
Usage
Create a order
import Trimepay from 'trimepay-node';
const client = new Trimepay('{APP ID}', '{APP SECRET}');
client.notifyUrl = 'https://exmaple.com/notify';
client.returnUrl = 'https://exmaple.com/return';
async function createOrder(ctx) {
const order = await client.createOrder({
merchantTradeNo: 'TRADE NO',
totalFee: 100,
payType: 'ALIPAY_WEB',
// notifyUrl: 'https://example.com/notify2',
// returnUrl: 'https://example.com/return2',
});
ctx.redirect(order.data);
}
Handle notify (TypeScript)
import {TrimepayNotifyQuery} from 'trimepay-node';
async function notify(ctx) {
const query = ctx.request.query as TrimepayNotifyQuery;
if (query.payStatus === 'SUCCESS') {
// complete order...
}
}
License
Code released under MIT LICENSE