2.0.2 • Published 1 year ago

@bambora/wallet v2.0.2

Weekly downloads
6
License
MIT
Repository
github
Last release
1 year ago

Bambora Online JavaScript wallet API / library

Implements an abstraction layer over the various wallet integrations offered by Bambora Online.

Strongly typed. Promise-based.

Currently, the following wallet solutions are supported:

  • MobilePay
  • Vipps
  • Bambora Online test wallet

You will need a merchant account with Bambora Online to use this library.

If you're looking for documentation for the wallet API it can be found here.

Installation

NPM: npm install @bambora/wallet

CDN: https://static.bambora.com/wallet/v2/latest/wallet.min.js

Minified and gzipped size is ~9 KB.

Browser support: All major browsers above version N - 1, where N is the most recent version. For Internet Explorer, only version 11 is supported. Pull requests for bugs related to older versions or uncommon browsers are welcome, but not supported by Bambora.

Quick start

Global approach

Include the following snippet on your page just before the </body> tag:

<script type="text/javascript" src="https://static.bambora.com/wallet/latest/wallet.min.js"></script>

The Wallet constructor function will then be accessible on window via Bambora.Wallet:

document.addEventListener("DOMContentLoaded", function() {
  // ...
  var wallet = new Bambora.Wallet();
  // ...
}, false);

Modular approach

ES5: var Wallet = require("@bambora/wallet");

TS/ES6: import Wallet from "@bambora/wallet";

Integration

Wallets are initiated as follows:

const wallet = new Bambora.Wallet();

wallet.open("input session token here").then(
  function onFulfilled(response) => {
    // Success handler.
    // Enters on successful payment.
  },
  function onRejected(error) => {
    // Failure/cancel handler.
    // Enters on error or rejected payment.
  }
);

Or a one-liner:

new Bambora.Wallet().open("input session token here").then(successHandler, errorHandler);

The open method is a function that returns a promise. It resolves when a payment was successfully authorized, and rejects when an exception occurs or the payment was rejected.

Build

Requirements are Node and NPM.

Clone the project, navigate to the project root, and run npm run build in your terminal. This will install all dependencies and output all assets to the dist-folder.

Main developer dependencies

  • Webpack
  • TypeScript
  • Mocha
  • Chai

Test

Run npm test in your terminal in the project root.

Contributing

Create a pull request or an issue. Thanks.

More info coming soon.

CI/CD

CI/CD is done by Jenkins by reading the Jenkinsfile. The CI/CD pipeline goes through 4 steps:

  1. Build.
  2. Publish to Bambora CDN (files are uploaded to S3).
  3. Invalidate Bambora CDN Cache (the cache on CloudFront is invalidated).
  4. Publish to public NPM.

This will be run on the master branch and with tagged commits only.

Use npm version to bump the version and create a tagged commit as it ensures consistency.

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.8

4 years ago

1.2.7

5 years ago

1.2.5

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.0

6 years ago

1.1.15

6 years ago

1.1.14

6 years ago

1.1.13

7 years ago

1.1.12

7 years ago

1.1.11

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago