@bleumi/pay-sdk
NodeJS SDK for Bleumi Pay API
Last updated 17 hours ago by thirupathyks .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @bleumi/pay-sdk 
SYNC missed versions from official npm registry.

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.

Pre-requisites

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;
        console.log(JSON.stringify(createCheckoutUrlResponse));
    } 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

Class Method HTTP request Description
HostedCheckoutsApi createCheckoutUrl POST /v1/payment/hc Generate a unique checkout URL to accept payment.
HostedCheckoutsApi listTokens GET /v1/payment/hc/tokens Retrieve all tokens configured for the Hosted Checkout in your account in the Bleumi Pay Dashboard.
HostedCheckoutsApi validateCheckoutPayment POST /v1/payment/hc/validate Validate the GET parameters passed by Hosted Checkout in successUrl upon successfully completing payment.
PaymentsApi getPayment GET /v1/payment/{id} Retrieve the wallet addresses & token balances for a given payment
PaymentsApi listPayments GET /v1/payment Retrieve all payments created.
PaymentsApi settlePayment POST /v1/payment/{id}/settle Settle a specific amount of a token for a given payment to the transferAddress and remaining balance (if any) will be refunded to the buyerAddress
PaymentsApi refundPayment POST /v1/payment/{id}/refund Refund the balance of a token for a given payment to the buyerAddress
PaymentsApi getPaymentOperation GET /v1/payment/{id}/operation/{txid} Retrieve a payment operation for a specific payment.
PaymentsApi listPaymentOperations GET /v1/payment/{id}/operation Retrieve all payment operations for a specific payment.
PayoutsApi createPayout POST /v1/payout Create a payout.
PayoutsApi listPayouts GET /v1/payout Returns a list of payouts

Documentation For Models

Limitations

License

Copyright 2020 Bleumi, Inc.

Code licensed under the MIT License.

Current Tags

  • 1.0.7                                ...           latest (17 hours ago)

8 Versions

  • 1.0.7                                ...           17 hours ago
  • 1.0.6                                ...           3 months ago
  • 1.0.5                                ...           4 months ago
  • 1.0.4                                ...           6 months ago
  • 1.0.3                                ...           6 months ago
  • 1.0.2                                ...           6 months ago
  • 1.0.1                                ...           7 months ago
  • 1.0.0                                ...           7 months ago
Downloads
Today 1
This Week 9
This Month 9
Last Day 8
Last Week 7
Last Month 15
Dependencies (5)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |