This package has been deprecated

Author message:

moved to @nsftx/seven-sdk

@nsoft/seven-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.4.0 • Public • Published

Publishing

Seven SDK for JavaScript

The official Seven SDK for JavaScript, available for browsers (where applicable), or Node.js backends. Sources for implementation:

Installing

npm install @nsoft/seven-sdk

Usage and Getting Started

Import modules required by your application:

import sdk from '@nsoft/seven-sdk';

or using CommonJS:

const sdk = require('@nsoft/seven-sdk').default;

Since we use @babel/plugin-transform-runtime it is required to use @babel/runtime with this library.

npm install --save @babel/runtime

Example of generating access key needed to access some APIs:

const accessKey = new sdk.Security.AccessKey({
  keyId: '00000000-0000-0000-0000-000000000000',
  keySecret: 'abcdefghijklmnopqrst',
});

Example of generating betslip barcode:

const betslip = new sdk.Betslip({
  barcodePrefix: 'XX',
  barcodeSalt: 'abcdef0000',
});

const barcode = betslip.getBarcode(1000);

Wallet

To use wallet first create wallet instance:

const wallet = new sdk.Wallets.Wallet({
  environment: 'production',
  dataCenter: 'ro',
  authOptions: {
    keyId: 'keyId',
    keySecret: 'keySecret',
  },
});

Then you can use wallet instance to call wallet actions. Debit action requires two parameters, debit payload and requests payload (required for debugging and auditing), for non cash payments:

const debitResult = await wallet.debit(
  {
    // Debit payload
    requests: [{
      uuid: '08e9e088-6ee7-43de-a42f-3f1e59af10b8',
    }],
    paymentId: '00000000-0000-0000-0000-000000000001',
    amount: 10,
    bonusAmount: 0,
    sourceId: 'Roulette',
    refId: '8X1VTSH4D',
    md5Sig: 'md5Signature',
    ticket: {},
    money: {
      subtotal: 950,
      taxApplied: 50,
      total: 1000,
    },
  }, 
  {
    // Request payload
    locale: 'en',
    uuid: '064920e0-4f52-4348-8a70-0ce303f1ee47',
  },
);

For cash payments, third parameter is required:

const debitResult = await wallet.debit(
  { // Debit payload ... }, 
  { // Request payload ... },
  {
    // Cash payload
    cashPayment: true,
    cashRegister: '08e9e088-6ee7-43de-a42f-3f1e59af10b8',
    userUuid: '485251bc-73ea-4d20-9903-d35d15044130',
    userUsername: 'buha',
  },
);

md5Sig property is provided by Betslip API. To generate it for testing purposes, WalletHash method can be used.

const hash = new sdk.Wallets.WalletHash('Roulette', 'secret');
const md5Sig = hash.getSignature(requests, {
  cashPayment: true,
  cashRegister: '08e9e088-6ee7-43de-a42f-3f1e59af10b8',
  userUuid: '485251bc-73ea-4d20-9903-d35d15044130',
});

Getting Help

Contact us at Slack channel #team-seven;

Opening Issues

Please create detailed issue on GitHub Issues.

License

This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.

Dependents (1)

Package Sidebar

Install

npm i @nsoft/seven-sdk

Weekly Downloads

40

Version

1.4.0

License

MIT

Unpacked Size

256 kB

Total Files

145

Last publish

Collaborators

  • npm-support