1.0.0 • Published 2 years ago
billplz-rest v1.0.0
billplz-rest
billplz-rest provides a minimal higher-level wrapper around BillPlz's API..
Currently only support stable version API v3 with Typescript.
Installation
billplz-rest is available from npm.
npm i billplz-restSetup
- Register for Billplz account at Billplz
- Fetch your BillPlz Secret - String and Billplz XSignature - String
- Prepare your
callback URLandredirect callbackendpoint for redirect and webhook. You can use Webhook to test webhook. - Import and initialize billplz module using these information.
Usage
// Get Collection By Collection ID
import Billpz from 'billplz-rest'
const GetCollectionById = async () => {
const billplz = new Billpz({
isProduction: false,
secretKey: 'secret-key-from-billplz-account',
signature: 'signature-from-billplz-account',
redirectUrl: 'https://mywebsite.com/payment-page',
callbackUrl: ' https://webhook.site/8b4c6eb5-5977-4ba1-beea-abcd12345',
});
const res = await billplz
.collection()
.getById('abcd123')
if (res?.fetchSucess) {
console.info(res);
}
}
GetCollectionById();// Verify webhook
import Billpz from 'billplz-rest'
import { BplzCallback } from './node_modules/billplz-rest/dist/lib/type'
const VerifyCallback = async (payload: BplzCallback) => {
const billplz = new Billpz({
isProduction: false,
secretKey: 'secret-key-from-billplz-account',
signature: 'signature-from-billplz-account',
redirectUrl: 'https://mywebsite.com/payment-page',
callbackUrl: ' https://webhook.site/8b4c6eb5-5977-4ba1-beea-abcd12345',
});
const res = await billplz
.callback()
.verify(payload)
if (res) {
console.info(res);
}
}
VerifyCallback({
// billplz webhook payload
});1.0.0
2 years ago