Skip to content

jamescarr/braintree_node

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

This is a node.js library for integrating with the Braintree gateway. It is a work in progress, very much alpha. Feedback is appreciated. It can be used in the sandbox environment, contact us if you're interested in using it in production.

Installing

  • clone this repo somewhere in your require.paths
  • require 'braintree-node/lib/braintree'
  • npm coming soon!

Dependencies

  • node 0.2.0
  • underscore.js

Quick Start

var sys = require('sys'),
    _ = require('underscore')._,
    braintree = require('braintree-node/lib/braintree');

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

gateway.transaction.sale(
  {
    amount: '5.00',
    creditCard: {
      number: '5105105105105100',
      expirationDate: '05/12'
    }
  },
  function (err, response) {
    if (err) {
      sys.puts(err.message);
      return;
    }

    if (response.success) {
      sys.puts('Transaction id: ' + response.transaction.id);
      sys.puts('Transaction status: ' + response.transaction.status);
      sys.puts('Transaction amount: ' + response.transaction.amount);
    } else {
      if (response.transaction) {
        sys.puts('Transaction status: ' + response.transaction.status);
      } else {
        _.each(response.errors.deepErrors(), function (error) {
          sys.puts(error.message);
        });
      }
    }
  }
);

About

braintree node.js client library

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%