This library is a wrapper for RBS's BlueBank API using restler.
Supported operations:
- List customers that the bearer is authorized for.
- Update a customer's phone number
- List accounts for a customer
- Update an account's friendly name
- List account payments
- List account transactions
- List payments
- Payment:
- Request payment
- Get Payment Info
- Update payment (i.e. authorize 2FA payment with OTP code)
- Find ATMs
- Find Branches - Currently not implemented by RBS
- RBS have yet to implement the Branches API
- There is an issue with Payment API for payments over 30GBP (i.e. that need 2FA). Any such POST request will take a very long time then result in a 500 Internal Server Error. It is possible this depends on your phone number. However, the payment is still created and can be seen when listing all payments.
- At the moment I do not receive SMS codes through OTP, neither does the bypass code (123456) seem to work, so the authorize payment was not tested.
- Keep in mind this wasn't tested very thoroughly.
Notice the examples, for demonstration purposes, use the "complete" event on the request which fires for either success, failure (http request succeeded but got 4XX/5XX) or error (e.g. timeout). More specific events exist and are better for actual usage - success/fail/error/STATUS_CODE.
var blue = new BlueBank({subscriberKey: subscriberKey, bearer: bearer});
//List all customers for this bearer token
blue.customers().once("complete", onCustomerList);
function onCustomerList(customers) {
var customer = customers[0]; //ignoring the rest;
console.log("Customer", customer.id, customer);
//Update Phone Number:
blue.customer(customer, {"mobilePhone": "911"}).on("complete", function() {
console.log("Updated Mobile Phone");
});
//List accounts:
blue.customerAccounts(customer.id).once("complete", onCustomerAccounts);
}
function onCustomerAccounts(accounts) {
console.log("Accounts:");
console.log(accounts);
var account = accounts[0];
//Update Account Friendly Name:
var name = account.accountFriendlyName +"!";
blue.account(account.id, {accountFriendlyName: name})
.once("complete", function onAccountUpdated(account) {
//patching an account returns the new info
console.log("Account Updated: ",account);
});
accessPayments(accounts[0], accounts[1]);
}
function accessPayments(from, to) {
function authorizePayment(payment) {
console.log("Authorizing payment with OTP Code 123456",payment);
blue.payments(from, payment, {
"OTPCode": "123456" //Authorize Code
}).once("complete", function(updated) {
console.log("Payment Updated", updated);
});
}
//List all payments in account
blue.payments(from).once("complete", function(payments) {
console.log("Current payments",payments);
//Authorize an example 2FA pending payment:
var needsAuth = payments.find(blue.requires2FA);
if(needsAuth) {
authorizePayment(needsAuth);
}
});
//Make a payment:
blue.paymentTo(from, to, 1.1, "PayRef", undefined).once("complete", function(payment, response) {
if(blue.requires2FA(payment)) {
console.log("Payment requires authorization", payment);
authorizePayment(payment);
}
else {
console.log("Payment requested", payment);
}
}).once("fail", function(data, response) {
console.log("Payment Failed", data);
});
}
//List ATMs
blue.atms().once("complete", function(atms) {
console.log("ATMS", atms);
});
//Not implemented.
//blue.branches().once("complete", function(branches) {
// console.log("BRANCHES", branches);
//});
Kind: global class
-
BlueBank
- new BlueBank(options)
- .customer(id, [patchData]) ⇒ EventEmitter
- .customers() ⇒ EventEmitter
- .customerAccounts(id) ⇒ EventEmitter
- .account(id, [patchData]) ⇒ EventEmitter
- .paymentTo(from, to, reference, [callbackUri]) ⇒ EventEmitter
- .payments(account, [paymentId], [paymentData]) ⇒ EventEmitter
- .requires2FA(payment) ⇒ boolean
- .transactions(account, [options]) ⇒ EventEmitter
- .atms([options]) ⇒ EventEmitter
- .branches([options]) ⇒ EventEmitter
Creates a new BlueBank API accessor.
Param | Type | Description |
---|---|---|
options | Object | |
options.subscriberKey | string | The Subscriber Key received when subcribed to the API |
[options.bearer] | string | The customer's bearer with which to authorize the requests. |
Retrieves or updates the customer with the given id.
Kind: instance method of BlueBank Returns: EventEmitter - the restler Request instance
Param | Type | Description |
---|---|---|
id | string | the customer id to retrieve or update |
[patchData] | object | When supplied should contain the mobilePhone field that will be set for this customer. |
List all customers current bearer is authorized to see.
Kind: instance method of BlueBank Returns: EventEmitter - the restler Request instance
List all accounts under the given customer
Kind: instance method of BlueBank Returns: EventEmitter - the restler Request instance
Param | Type | Description |
---|---|---|
id | string | the customer id whose accounts to list |
Retrieves or updates the account with the given id.
Kind: instance method of BlueBank Returns: EventEmitter - the restler Request instance
Param | Type | Description |
---|---|---|
id | string | the account id to retrieve or update |
[patchData] | object | When supplied should contain the accountFriendlyName field that will be set for this account. |
Makes a payment to the account {from} to the account {to} with the given amount and payment reference with an optional callback uri.
Kind: instance method of BlueBank Returns: EventEmitter - the restler Request instance
Param | Type | Description |
---|---|---|
from | Object | string | the account object or id from which to transfer money |
to | Object | The transfer destination account |
to.accountNumber | string | The transfer destination account number |
to.sortCode | string | The transfer destination account sort code |
reference | string | The payment reference string (any) |
[callbackUri] | string | The callback URI for payment updates from RBS |
account => all payments will be retrieved. account, payment id => The payment is retrieved. account, paymentData => New payment created with this data account, payment id, paymentData => Given payment updated with the given data.
Kind: instance method of BlueBank Returns: EventEmitter - the restler Request instance
Param | Type | Description |
---|---|---|
account | Object | string | the account object or id for the payments |
[paymentId] | string | Object | The id (or an object containing the paymentId field ) to retrieve or update |
[paymentData] | Object | The payment data to update into the given payment id, or to create if no payment id was given. |
Returns true if and only if the given payment object has a paymentStatus of '2FA required'
Kind: instance method of BlueBank Returns: boolean - true if and only if the given payment object has a paymentStatus of '2FA required'
Param | Type | Description |
---|---|---|
payment | object | the payment object to check. |
Lists all transactions in the account
Kind: instance method of BlueBank Returns: EventEmitter - the restler Request instance
Param | Type | Description |
---|---|---|
account | Object | string | the account object or id from which to transfer money |
[options] | Object | The query options as per the API |
Lists atms by location or query
Kind: instance method of BlueBank Returns: EventEmitter - the restler Request instance
Param | Type | Description |
---|---|---|
[options] | Object | either a query object as per the API or a "Nearby" query containing {lat,long,radius} fields |
NOT IMPLEMENTED. Lists branches by location or query or retrieves a branch
Kind: instance method of BlueBank Returns: EventEmitter - the restler Request instance
Param | Type | Description |
---|---|---|
[options] | Object | string | either a branch id to query or query object as per the API or a "Nearby" query containing {lat,long,radius} fields |