Package Exports
- @bleumi/pay-sdk
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@bleumi/pay-sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Bleumi Pay SDK for NodeJS
The Bleumi Pay SDK is a one-stop shop to help you integrate ERC-20, Ethereum, xDai payments and/or 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.jsonhas to include'es5'and'es2015.promise'undercompilerOptions.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
In Node.js
npm install @bleumi/pay-sdk -gRun Sample Code
The following code generates a payment request to accept payment from the buyer:
import { PaymentsApi, PaymentsApiApiKeys, CreatePaymentRequest, EthAddress, Chain } from '@bleumi/pay-sdk';
// Instantiate client
const bleumiPay = new PaymentsApi();
async function createPayment(id: string) {
try {
bleumiPay.setApiKey(PaymentsApiApiKeys.ApiKeyAuth, '<YOUR_API_KEY>'); //Replace <YOUR_API_KEY> with your actual API key
const buyer = new EthAddress('<BUYER_ADDR>'); // Replace <BUYER_ADDR> with the Buyer's Enthereum Network Address
const merchant = new EthAddress('<MERCHANT_ADDR>'); // Replace <MERCHANT_ADDR> with the Merchant's Enthereum Network Address
const createPaymentRequest = new CreatePaymentRequest();
createPaymentRequest.id = id;
createPaymentRequest.buyerAddress = buyer;
createPaymentRequest.transferAddress = merchant;
const chain = Chain.Ropsten; // Specify the chain for payment creation
const response = await bleumiPay.createPayment(createPaymentRequest, chain);
const createPaymentResponse = response.body;
console.log(JSON.stringify(createPaymentResponse));
} catch (err) {
console.error('Error statusCode:', err.response.statusCode);
console.error('Error reponse:', err.response.body);
}
}
More examples can be found under each method in SDK Classes section.
SDK Classes
| Class | Method | HTTP request | Description |
|---|---|---|---|
| PaymentsApi | createPayment | POST /v1/payment | Generate a unique wallet address in the specified network to accept 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. |
| 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. |
| PayoutsApi | createPayout | POST /v1/payout | Create a payout. |
| PayoutsApi | listPayouts | GET /v1/payout | Returns a list of payouts |
Documentation For Models
- BadRequest
- Chain
- CheckoutToken
- CreateCheckoutUrlRequest
- CreateCheckoutUrlResponse
- CreatePaymentRequest
- CreatePaymentResponse
- CreatePayoutRequest
- CreatePayoutResponse
- EthAddress
- PaginatedPaymentOperations
- PaginatedPayments
- PaginatedPayoutItems
- Payment
- PaymentAddresses
- PaymentBalances
- PaymentOperation
- PaymentOperationInputs
- PaymentOperationResponse
- PaymentRefundRequest
- PaymentSettleRequest
- Payout
- PayoutItem
- PayoutItemInputs
- Token
- ValidateCheckoutRequest
- ValidateCheckoutResponse
- WalletAddress
- WalletBalance
Limitations
License
Copyright 2019 Bleumi, Inc.
Code licensed under the MIT License.