1.11.0 • Published 6 years ago

@brad-jones/cc-tokenizer-client v1.11.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

Credit Card Tokenizer Client

The client side component of the cc-tokenizer.

Usage

Install with Npm/Yarn

npm install @brad-jones/cc-tokenizer-client

OR

yarn add @brad-jones/cc-tokenizer-client

Bundling into your client side app.

This package has been distributed with a CommonJs & a ES2015 build. Older style bundlers may make use of the CommonJs build, located in the main ./dist folder. More modern style bundlers can make use of the ES2015 build, located in ./dist-esm.

Using the browser build

Located in /dist-browser is a build ready to be consumed directly in a browser via a script tag.

UnPkg CDN: For the super lazy, get it via the UnPkg CDN.

<script src="https://unpkg.com/@brad-jones/cc-tokenizer-client/dist-browser/index.js"></script>

Once loaded into the browser, the browser bundle exposes all it's exports on a namespaced window object, like this:

var pkg = window['@brad-jones/cc-tokenizer-client'];
var client = new pkg.CcTokenizerClient();

NOTE: It's actually a fuse-box module.

All bundles are transpiled down to ES5 and polyfilled.

Client Config

Regardless of how you have loaded the package into the browser, the first and most important thing to understand is how this package is coupled to the server package. Or not coupled...

Roughly the client follows this workflow:

  • Makes a request to what we call the auth/token endpoint. This is some endpoint that you are responsible for hosting. Using cc-tokenizer-server or not... its up to you.

  • The auth/token endpoint then calls a payment gateway to get the single use auth token. And then returns this token to the client, along with a special url pointing directly to the payment gateway, that the client has to call next.

  • The client then sends a request directly to the returned URL (via AJAX & CORS or JSONP) that includes the actual credit card details and uses the auth/token to authenticate the request.

  • The payment gateway then returns a result-token & a redirection-url. NOTE: This token does not yet represent the final credit card token.

  • The client then sends a request to the redirection-url with the result-token. The redirection-url has been baked into the original auth/token request. It is what we call the token/receipt endpoint. Again this is another endpoint that you are responsible for hosting. A reference implementation is also provided in cc-tokenizer-server.

So the up shot of that, the client needs to know where the very first endpoint is, the rest should be automatically discovered.

var client = new CcTokenizerClient({ authTokenEndpoint: 'https://your.api.server/v1/auth/token' });
1.11.0

6 years ago

1.10.0

6 years ago

1.9.1

6 years ago

1.9.0

6 years ago

1.8.0

6 years ago

1.7.0-dev

6 years ago

1.7.0

6 years ago

1.4.0

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago