braintree
A library for integrating with Braintree.
Last updated 22 days ago by braintree .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install braintree 
SYNC missed versions from official npm registry.

Braintree Node library

The Braintree Node library provides integration access to the Braintree Gateway.

Please Note

The Payment Card Industry (PCI) Council has mandated that early versions of TLS be retired from service. All organizations that handle credit card information are required to comply with this standard. As part of this obligation, Braintree is updating its services to require TLS 1.2 for all HTTPS connections. Braintree will also require HTTP/1.1 for all connections. Please see our technical documentation for more information.

Installation

  • npm install braintree
  • var braintree = require('braintree')

Dependencies

  • node >= 4

Links

Quick Start

var braintree = require('braintree');

// previously, gateways were created by calling `braintree.connect`, but as no
// connection takes place in the method call, we've opted to document how
// to instantiate a Braintree Gateway directly. `connect` can still be used,
// but it is deprecated and will be removed in the next major version
var gateway = new braintree.BraintreeGateway({
  environment: braintree.Environment.Sandbox,
  merchantId: 'your_merchant_id',
  publicKey: 'your_public_key',
  privateKey: 'your_private_key'
});

gateway.transaction.sale({
  amount: '5.00',
  paymentMethodNonce: 'nonce-from-the-client',
  options: {
    submitForSettlement: true
  }
}, function (err, result) {
  if (err) {
    console.error(err);
    return;
  }

  if (result.success) {
    console.log('Transaction ID: ' + result.transaction.id);
  } else {
    console.error(result.message);
  }
});

Promises

You can also use Promises instead of callbacks.

var braintree = require('braintree');

var gateway = new braintree.BraintreeGateway({
  environment: braintree.Environment.Sandbox,
  merchantId: 'your_merchant_id',
  publicKey: 'your_public_key',
  privateKey: 'your_private_key'
});

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);
});

Almost all methods that uses a callback can alternatively use a Promise. The only exceptions are gateway.merchantAccount.all or any of the search methods because they return a stream if no callback is provided.

Developing (Docker)

The Makefile and Dockerfile will build an image containing the dependencies and drop you to a terminal where you can run tests.

make

Tests

The unit specs can be run by anyone on any system, but the integration specs are meant to be run against a local development server of our gateway code. These integration specs are not meant for public consumption and will likely fail if run on your system. To run unit tests use rake (rake test:unit) or npm (npm test).

License

See the LICENSE file.

Current Tags

  • 2.23.0                                ...           latest (22 days ago)

94 Versions

  • 2.23.0                                ...           22 days ago
  • 2.22.0                                ...           3 months ago
  • 2.21.0                                ...           7 months ago
  • 2.20.0                                ...           9 months ago
  • 2.19.0                                ...           10 months ago
  • 2.18.0                                ...           a year ago
  • 2.17.0                                ...           a year ago
  • 2.16.0                                ...           a year ago
  • 2.15.0                                ...           a year ago
  • 2.14.0                                ...           a year ago
  • 2.13.1                                ...           2 years ago
  • 2.13.0                                ...           2 years ago
  • 2.12.0                                ...           2 years ago
  • 2.11.0                                ...           2 years ago
  • 2.10.0                                ...           2 years ago
  • 2.9.0                                ...           2 years ago
  • 2.8.0                                ...           2 years ago
  • 2.7.0                                ...           2 years ago
  • 2.6.0                                ...           2 years ago
  • 2.5.0                                ...           2 years ago
  • 2.4.0                                ...           3 years ago
  • 2.3.0                                ...           3 years ago
  • 2.2.0                                ...           3 years ago
  • 2.1.1                                ...           3 years ago
  • 2.1.0                                ...           3 years ago
  • 2.0.2                                ...           3 years ago
  • 1.47.1                                ...           3 years ago
  • 2.0.1                                ...           3 years ago
  • 2.0.0                                ...           3 years ago
  • 1.47.0                                ...           3 years ago
  • 1.46.0                                ...           3 years ago
  • 1.45.0                                ...           3 years ago
  • 1.44.0                                ...           4 years ago
  • 1.43.0                                ...           4 years ago
  • 1.42.0                                ...           4 years ago
  • 1.41.0                                ...           4 years ago
  • 1.40.0                                ...           4 years ago
  • 1.39.0                                ...           4 years ago
  • 1.38.0                                ...           4 years ago
  • 1.37.1                                ...           4 years ago
  • 1.37.0                                ...           4 years ago
  • 1.36.0                                ...           4 years ago
  • 1.35.1                                ...           4 years ago
  • 1.35.0                                ...           4 years ago
  • 1.34.0                                ...           4 years ago
  • 1.32.0                                ...           5 years ago
  • 1.31.0                                ...           5 years ago
  • 1.30.0                                ...           5 years ago
  • 1.29.0                                ...           5 years ago
  • 1.28.0                                ...           5 years ago
  • 1.27.0                                ...           5 years ago
  • 1.26.0                                ...           5 years ago
  • 1.25.0                                ...           5 years ago
  • 1.24.0                                ...           5 years ago
  • 1.23.0                                ...           5 years ago
  • 1.22.0                                ...           5 years ago
  • 1.21.0                                ...           6 years ago
  • 1.20.0                                ...           6 years ago
  • 1.19.0                                ...           6 years ago
  • 1.18.1                                ...           6 years ago
  • 1.18.0                                ...           6 years ago
  • 1.17.0                                ...           6 years ago
  • 1.16.0                                ...           6 years ago
  • 1.15.0                                ...           6 years ago
  • 1.14.1                                ...           6 years ago
  • 1.14.0                                ...           6 years ago
  • 1.13.1                                ...           6 years ago
  • 1.13.0                                ...           6 years ago
  • 1.12.0                                ...           6 years ago
  • 1.11.2                                ...           6 years ago
  • 1.11.1                                ...           6 years ago
  • 1.11.0                                ...           6 years ago
  • 1.10.0                                ...           6 years ago
  • 1.9.2                                ...           7 years ago
  • 1.9.1                                ...           7 years ago
  • 1.9.0                                ...           7 years ago
  • 1.8.0                                ...           7 years ago
  • 1.7.0                                ...           7 years ago
  • 1.6.0                                ...           7 years ago
  • 1.5.1                                ...           8 years ago
  • 1.4.0                                ...           8 years ago
  • 1.3.0                                ...           8 years ago
  • 1.2.0                                ...           8 years ago
  • 1.1.2                                ...           8 years ago
  • 1.1.1                                ...           8 years ago
  • 1.1.0                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
  • 0.5.1                                ...           8 years ago
  • 0.5.0                                ...           8 years ago
  • 0.4.1                                ...           9 years ago
  • 0.4.0                                ...           9 years ago
  • 0.3.0                                ...           9 years ago
  • 0.2.0                                ...           9 years ago
  • 0.1.1                                ...           9 years ago

Copyright 2014 - 2016 © taobao.org |