beanstream-nodejs (Legacy)
NodeJS integration to Bambora API.
The Node SDK for Bambora lets you take payments, save payment profiles, and run reports on your transactions. It's easy to get started, just follow the steps below
For testing instructions with our TLS1.2-only server, please refer to our developer portal
Import the project directly from npm:
npm install beanstream-node
var beanstream = require('beanstream-node')('merchantId', 'Payments API key', 'Profiles API key', 'Reporting API key');
Supply your merchant ID, payments API Key, Profiles API key (optional), and Reporting API key (optional).
The Bambora SDK uses promises to handle asynchronous calls to the server. You will get your results in a Promise object. Here is an example:
var tokenPayment = {
order_number: 'order-abc1234',
amount:10.00,
payment_method:'card',
token:{
name:'John Doe',
code: 'token-string',
complete: true
}
};
beanstream.payments.makePayment(tokenPayment)
.then(function(response){
// successful payment
console.log("Payment response: ", response);
})
.catch(function(error){
// all errors end up here, even declined payments
console.log(error);
});
Here is an example with a raw card number:
var cardPayment = {
order_number: 'order-abc1234',
amount:10.00,
payment_method:'card',
card:{
name:'John Doe',
number:'5100000010001004',
expiry_month:'02',
expiry_year:'19',
cvd:'123'
}
};
beanstream.payments.makePayment(cardPayment)
.then(function(response){
// successful payment
console.log("Payment response: ", response);
})
.catch(function(error){
// all errors end up here, even declined payments
console.log(error);
});
Note that you should tokenize cards in your client-side app in order to reduce your PCI scope. More details here:
Visit developer portal for more code examples. You will learn how to:
- create a card token
- make a payment with a token
- make a card payment
- make a card pre-authorization and completion
- make a payment profile
- charge a payment profile
- update payment profiles
- query your transaction history using reports
Whether it is a bug fix or a new feature improvement feel free to fork the project and send us pull requests. We are always excited to work with the community to improve the project. We even have code bounties as a reward for great contributions. So never hesitate to send improvements our way!