Integrate NodeJS and Braintree
Trexle connects NodeJS to Braintree and 100+ other payment gateways using a single plugin for one time annual fee
Braintree and NodeJS Integration Guide
To get your Braintree Payments API keys, register your account at Braintree production or Braintree sandbox and login. Once logged in, navigate to Setting -> API Keys as follows..
Click the Generate New API Key button to generate your public and private API keys..
Click the green View link located under Public key and it should prompt you with your Public API key, Private API key, Environment, and Merchant ID as shown below.
Take the credentials you just obtained from Braintree and navigate to Trexle dashboard, click Payments Gateways and select Braintree from the drop down menu as shown below.
Fill into your Braintree credential and click Add Gateway. Click the Activate button next to Braintree, and it will give you a success message and the button will turn into green. You should see something like below.
In your NodeJS project, open a terminal and issue the following command:
npm install trexlejs
If you want to test, consider writing the following example in a test.js file:
var Trexle = require('trexlejs');
var trexle = Trexle.setup({
key: ‘your-api-key’,
production: false
});
trexle.createCharge({
amount: 400,
currency: ‘usd’,
description: ‘test charge’,
email: ‘[email protected]’,
ip_address: ‘66.249.79.118’,
card: {
number: ‘4242424242424242’,
expiry_month: 8,
expiry_year: 2018,
cvc: 123,
name: ‘John Milwood’,
address_line1: ‘423 Shoreline Park’,
address_city: ‘Mountain View’,
address_postcode: 94043,
address_state: ‘CA’,
address_country: ‘US’
}
}, function (response) {
console.log(response.body);
});
Then run the code:
node test.js
Use the credit card values below to trigger different responses from the gateway.
No credit card errors
The following credit card values will not trigger specific credit card errors, but this does not mean that your test transaction will be successful. Values passed with the transaction (e.g. amount) can be used to trigger other types of gateway responses.
Test Value | Card Type |
---|---|
378282246310005 |
American Express |
371449635398431 |
American Express |
36259600000004 |
Diners Club |
6011111111111117 |
Discover |
3530111333300000 |
JCB |
6304000000000000 |
Maestro |
5555555555554444 |
Mastercard |
2223000048400011 |
Mastercard |
4111111111111111 |
Visa |
4005519200000004 |
Visa |
4009348888881881 |
Visa |
4012000033330026 |
Visa |
4012000077777777 |
Visa |
4012888888881881 |
Visa |
4217651111111119 |
Visa |
4500600000000061 |
Visa |
Unsuccessful credit card verification
The following credit card numbers will simulate an unsuccessful card verification response.
Test Value | Card Type | Verification Response |
---|---|---|
4000111111111115 |
Visa | processor declined |
5105105105105100 |
Mastercard | processor declined |
378734493671000 |
American Express | processor declined |
6011000990139424 |
Discover | processor declined |
3566002020360505 |
JCB | failed (3000) |
Card type indicators
The following card numbers can be used to simulate various types of cards. Using any of the card numbers below will force the corresponding card type indicator to return “Yes” and the others to return “No” or “Unknown”:
Test Value | Card Type Indicator Response |
---|---|
4500600000000061 |
prepaid = “Yes” |
4009040000000009 |
commercial = “Yes” |
4005519200000004 |
Durbin regulated = “Yes” |
4012000033330026 |
healthcare = “Yes” |
4012000033330125 |
debit = “Yes” |
4012000033330224 |
payroll = “Yes” |
4012000033330422 |
all values = “No” |
4012000033330323 |
all values = “Unknown” |
Other card information
Test Value | Card Information |
---|---|
4012000033330620 |
country of issuance = “USA” |
4012000033330521 |
issuing bank =”NETWORK ONLY” |
Braintree Supported Countries
Braintree Supported Payment Processing Actions
✔ Authorize
✔ Capture
✔ Void
✔ Credit
✔ Recurring
✔ Card Store
Key Features
About Trexle
Trexle is a powerful online recurring subscription billing platform that integrate Braintree and other +100 payment gateways with NodeJS and other dozen of e-commerce platforms.
About Braintree
Braintree — a subsidiary of PayPal — is a company based in Chicago that specializes in mobile and web payment systems for ecommerce companies. Braintree emphasizes its easy integrations, simple pricing, security, and support.
About NodeJS
Node.js is an open-source, cross-platform JavaScript runtime environment for executing JavaScript code server-side, and uses the Chrome V8 JavaScript engine. Historically, JavaScript was used primarily for client-side scripting, in which scripts written in JavaScript are embedded in a webpage's HTML, to be run client-side by a JavaScript engine in the user's web browser. Node.js enables JavaScript to be used for server-side scripting, and runs scripts server-side to produce dynamic web page content before the page is sent to the user's web browser.