0.1.15 • Published 7 years ago

brillantpay v0.1.15

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

BrillantPay Node.js Library

Version Build Status Downloads

The BrillantPay Node library provides convenient access to the BrillantPay API from applications written in server-side JavaScript.

Please keep in mind that this package is for use with server-side Node that uses BrillantPay keys. To maintain compliance and offer ideal user experience, always call brillantpay.js in all integrations or checkout.js in the script src attribute of the form when using BrillantPay Checkout.

Documentation

See the Node API documentation.

Installation

Install the package with:

npm install brillantpay --save

Usage

The package needs to be configured with your account's publishable and secret keys which are available in your BrillantPay Dashboard. Require it with the Secret Key value:

const brillantpay = require("brillantpay");

const transaction = new brillantpay.BrillantPay('sk_test_...');

Creating a payment

Create a payment data object and fill it with the form data returned then create the actual payment:

// Create a new payment:
this.data = {
     "confirmation": "HJVHGFT65675",
     "account": 424324324,
     "bp_token": 'bp_tok_2367tdygywttwetfef'
     "currency": "KES",
     "amount": 500,
     "description": "Chiffon dress",
     "option": "MOBILEMONEY",
     "service": "MPESA",
     "email": "john.doe@brillantpay.com",
     "phone": 254718287827
};

transaction.payments(this.data.confirmation,
     this.data.account,
     this.data.bp_token,
     this.data.currency,
     this.data.amount,
     this.data.description,
     this.data.option,
     this.data.service,
     this.data.email,
     this.data.phone, function(err, response) {
         if (err) {
             // Deal with an error
         }
         // A new payment created. Do something
     });

Configuring Timeout

Request timeout is configurable (the default is Node's default of 120 seconds):

transaction.setTimeout(30000); // in ms (this is 30 seconds)

Writing a Plugin

If you're writing a plugin that uses the library, we'd appreciate it if you identified using brillantpay.setAppInfo():

brillantpay.setAppInfo({
  name: 'MyAwesomePlugin',
  version: '1.2.34', // Optional
  url: 'https://myawesomeplugin.info', // Optional
});

This information is passed along when the library makes calls to the BrillantPay API.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-awesome-feature)
  3. Commit your changes (git commit -am 'Add some awesome feature')
  4. Push to the branch (git push origin my-awesome-feature)

Development

Run all tests:

$ npm install
$ npm test

Run a single test suite:

$ npm run mocha -- test/resources/payment.spec.js

License

Released under the MIT licence.

Copyright (c) Brillant Innovations Ltd

0.1.15

7 years ago

0.1.14

7 years ago

0.1.13

7 years ago

0.1.12

7 years ago

0.1.11

7 years ago

0.1.10

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.3

7 years ago