1.0.8 • Published 1 year ago

@bleumi/pay-sdk v1.0.8

Weekly downloads
Last release
1 year ago

Bleumi Pay SDK for NodeJS

GitHub license

The Bleumi Pay SDK helps you integrate Algo, Algorand Standard Asset, Ethereum, ERC-20, RSK, RSK ERC-20 & xDai payments and payouts into your business or application. The SDK bundles Bleumi Pay API into one SDK to ease implementation and support.

bleumi-pay-sdk-nodejs is a TypeScrpit-NodeJS library that provides an interface between your NodeJS application and Bleumi Pay API. This tutorial covers the basics, including examples, needed to use the SDK.

Getting Started

The Bleumi Pay SDK for NodeJS bundles TypeScript definition files for use in TypeScript projects and to support tools that can read .d.ts files. Our goal is to keep these TypeScript definition files updated with each release for any public api.


Before you can begin using these TypeScript definitions with your project, you need to make sure your project meets a few of these requirements:

Development Environment

  • Use TypeScript v2.x
  • Includes the TypeScript definitions for node. You can use npm to install this by typing the following into a terminal window:

    npm install --save-dev @types/node
  • If you are targeting at es5 or older ECMA standards, your tsconfig.json has to include 'es5' and 'es2015.promise' under compilerOptions.lib. See tsconfig.json for an example.

Obtain An API Key

Bleumi Pay SDK uses API keys to authenticate requests. You can obtain an API key through the Bleumi Pay Dashboard.

Install Package

npm (scoped)

In Node.js

npm install @bleumi/pay-sdk -g

Run Sample Code

The following code generates an unique checkout URL to accept payment from the buyer:

import { HostedCheckoutsApi, HostedCheckoutsApiApiKeys, CreateCheckoutUrlRequest } from '@bleumi/pay-sdk';

// Instantiate client
const bleumiPay = new HostedCheckoutsApi();

async function createCheckoutUrl(id: string) {
    try {
        bleumiPay.setApiKey(HostedCheckoutsApiApiKeys.ApiKeyAuth, '<YOUR_API_KEY>'); //Replace <YOUR_API_KEY> with your actual API key

        const chain = Chain.Goerli;
        const createCheckoutUrlRequest = new CreateCheckoutUrlRequest();

        createCheckoutUrlRequest.id = id
        createCheckoutUrlRequest.currency = "<CURRENCY>"
        createCheckoutUrlRequest.amount = "<AMOUNT>"
        createCheckoutUrlRequest.cancelUrl = "<CANCEL_URL>" // Eg. https://demo.store/api/cancelOrder
        createCheckoutUrlRequest.successUrl = "<SUCCESS_URL>" // Eg. https://demo.store/api/completeOrder
        createCheckoutUrlRequest.token = '<TOKEN>'; // string | Replace <TOKEN>  by anyone of the following values: 'ETH' or 'XDAI' or 'XDAIT' or ECR-20 Contract Address or 'RBTC' or RSK ECR-20 Contract Address or 'Asset ID' of Algorand Standard Asset. | Optional

        createCheckoutUrlRequest.chain = chain;

        const response = await bleumiPay.createCheckoutUrl(createCheckoutUrlRequest);
        const createCheckoutUrlResponse = response.body;
    } catch (err) {
        if (err.response) {
            console.error('Error statusCode:', err.response.statusCode);
            console.error('Error reponse:', err.response.body);
        console.log('Error message:',err.message);

More examples can be found under each method in SDK Classes section.

SDK Classes

ClassMethodHTTP requestDescription
HostedCheckoutsApicreateCheckoutUrlPOST /v1/payment/hcGenerate a unique checkout URL to accept payment.
HostedCheckoutsApilistTokensGET /v1/payment/hc/tokensRetrieve all tokens configured for the Hosted Checkout in your account in the Bleumi Pay Dashboard.
HostedCheckoutsApivalidateCheckoutPaymentPOST /v1/payment/hc/validateValidate the GET parameters passed by Hosted Checkout in successUrl upon successfully completing payment.
PaymentsApigetPaymentGET /v1/payment/{id}Retrieve the wallet addresses & token balances for a given payment
PaymentsApilistPaymentsGET /v1/paymentRetrieve all payments created.
PaymentsApisettlePaymentPOST /v1/payment/{id}/settleSettle a specific amount of a token for a given payment to the transferAddress and remaining balance (if any) will be refunded to the buyerAddress
PaymentsApirefundPaymentPOST /v1/payment/{id}/refundRefund the balance of a token for a given payment to the buyerAddress
PaymentsApigetPaymentOperationGET /v1/payment/{id}/operation/{txid}Retrieve a payment operation for a specific payment.
PaymentsApilistPaymentOperationsGET /v1/payment/{id}/operationRetrieve all payment operations for a specific payment.
PayoutsApicreatePayoutPOST /v1/payoutCreate a payout.
PayoutsApilistPayoutsGET /v1/payoutReturns a list of payouts

Documentation For Models



Copyright 2020 Bleumi, Inc.

Code licensed under the MIT License.