npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@brad-jones/cc-tokenizer-client

v1.11.0

Published

The client side component of the cc-tokenizer.

Downloads

22

Readme

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' });