npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

boom-pay-sdk

v2.0.2

Published

Boom Pay SDK

Downloads

11

Readme

BoomPay SDK

BoomPay SDK is a powerful library allowing developers to interact seamlessly with the BoomPay API. The key features encompassed by this SDK include:

  • Payment intent creation and retrieval
  • Default Wallet retrieval
  • Convenient Webhook integration

The SDK is built to support both TypeScript and JavaScript.

Installation

Use the following command to install the BoomPay SDK via npm:

npm install boompay-sdk

Basic Usage

Start by importing the SDK and initializing it with your API key:

const BoomPay = require('boompay-sdk');

const boomPay = new BoomPay({
  apiKey: 'your-api-key',
  sandbox: true, // Optional: Enable the sandbox mode for testing purposes.
});

// Rest of your code

SDK Methods

Create a Wallet

Wallets are now created on the Boom App. You can download it here. Once created this will be the wallet which is tied to your API Key hence you won't need to specify the wallet address on API requests.

Create a Payment Intent

Create a new payment intent by specifying the amount, URLs for success and failure scenarios, additional metadata, and a label:

const payment = await boomPay.payments.createIntent({
  amount: 5,
  currency: 'BMC',
  successUrl: 'https://your-success-url.com',
  failureUrl: 'https://your-failure-url.com',
  metadata: {
    anyKey: 'anyValue',
  },
  label: 'Payment Label',
});

console.log(payment);

Retrieve a Payment

Retrieve details of a specific payment using its ID:

const payment = await boomPay.payments.getPayment('payment-id');

console.log(payment);

Retrieve the Default Wallet

Retrieve details of the default wallet:

const defaultWallet = await boomPay.wallets.getDefaultWallet();

console.log(defaultWallet);

Webhooks

BoomPay SDK provides an Express middleware for webhook handling. In addition to delivering the data payload, each webhook event comes with a signature in the request header. This signature is essential for verifying the authenticity of the event.

app.get('/webhook/success', boomPay.webhooks({
  apiKey: 'zHTRNaf6gaTE3YC2HI72PJjiyBtik1Q8',
}), (req, res) => {
  return res.status(200).send('OK');
});

The BoomPay SDK handles this verification process automatically when you use the provided boomPay.webhooks() function, ensuring the data received is indeed from BoomPay.

Error Handling

Ensure you handle exceptions for each function as they would throw an Error if the request fails:

try {
  const wallet = await boomPay.wallets.getDefaultWallet();
} catch (error) {
  console.error('Error getting default wallet:', error);
}

Sandbox Mode

The SDK offers a sandbox mode to aid testing. Enable it by setting the sandbox option to true:

const boomPay = new BoomPay({
  apiKey: 'your-sandbox-api-key',
  sandbox: true, // Enable sandbox mode
});

Supported Currencies

The SDK supports only Boomcoin (BMC) and as such there is no need to specify the currency when creating a payment intent.

TypeScript Support

TypeScript definitions for all types and interfaces are included. Simply import BoomPay from boompay-sdk:

import BoomPay from 'boompay-sdk';

Use the SDK just as in the JavaScript examples.