loopback-component-braintree

1.0.0 • Public • Published

Loopback Braintree Component

NPM version Build Status Dependency Status Coverage percentage

The Braintree connector for the LoopBack framework

Installation

npm install --save loopback-component-braintree

Usage

Define new datasource configuration for your Braintree account (file datasources.json)

{
  "braintree": {
    "environment": "sandbox",
    "merchantId": "your_merchant_id",
    "publicKey": "your_public_key",
    "privateKey": "your_private_key"
    }
  }
}

Define new model in file model-config.json with datasource braintree

{
  "Braintree": {
    "dataSource": "braintree",
    "public": false
  }
}

use model Braintree in your application:

Braintree.gateway.transaction.sale({
  amount: '5.00',
  paymentMethodNonce: 'nonce-from-the-client',
  options: {
    submitForSettlement: true
  }
}).then(function (result) {
  if (result.success) {
    console.log('Transaction ID: ' + result.transaction.id);
  } else {
    console.error(result.message);
  }
}).catch(function (err) {
  console.error(err);
});

Running tests

npm install
npm test

Contributing

We love contributions!

When contributing, follow the simple rules:

  • Don't violate DRY principles.
  • Boy Scout Rule needs to have been applied.
  • Your code should look like all the other code – this project should look like it was written by one man, always.
  • If you want to propose something – just create an issue and describe your question with as much description as you can.
  • If you think you have some general improvement, consider creating a pull request with it.
  • If you add new code, it should be covered by tests. No tests – no code.
  • If you add a new feature, don't forget to update the documentation for it.
  • If you find a bug (or at least you think it is a bug), create an issue with the library version and test case that we can run and see what are you talking about, or at least full steps by which we can reproduce it.

License

MIT © Matteo Padovano

Package Sidebar

Install

npm i loopback-component-braintree

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

9.97 kB

Total Files

7

Last publish

Collaborators

  • mrbatista