1.0.0 • Published 1 year 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-rest
Setup
- Register for Billplz account at Billplz
- Fetch your BillPlz Secret - String and Billplz XSignature - String
- Prepare your
callback URL
andredirect callback
endpoint 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
1 year ago