1.0.2 • Published 2 months ago

@guestyorg/tokenization-js v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Guesty Tokenization JS SDK

There are two ways to integrate the SDK:

Manually include a script tag

Add a script tag to your application head or body. This loads guestyTokenization object to the global window scope of the browser

<script src="https://pay.guesty.com/tokenization/v1/init.js"></script>

Note: To be PCI-compliant, you must load the SDK directly from https://pay.guesty.com. You cannot include it in a bundle or host it yourself

Use it as an ES module

Advantages of loading the SDK as a module:

  • loads script asynchronously to ensure page rendering isn't blocked
  • returns a Promise to know when script loading is complete
  • resolves to null if called in a server environment

Installation

Use npm to install the Guesty Tokenization JS module:

npm install @guestyorg/tokenization-js

Usage

Import the loadScript function for asynchronously loading the Guesty Tokenization JS SDK

loadScript(options?)

  • accepts an options object to configure script URL and attributes
  • returns a Promise that resolves with window.guestyTokenization after the SDK is finished loading

options

  • sandbox - load the SDK in a sandbox mode
loadScript({ sandbox: true });

This is equivalent to the following script:

<script
  src="https://pay.guesty.com/tokenization/v1/init.js"
  data-env="sandbox"
></script>

Async/Await

import { loadScript } from '@guesty/tokenization-js';

try {
  const guestyTokenization = await loadScript();
  // Guesty Tokenization JS SDK is loaded and ready to use
} catch (error) {
  console.error('Failed to load the Guesty Tokenization JS SDK script', error);
}

Promises

import { loadScript } from '@guesty/tokenization-js';

loadScript()
  .then((guestyTokenization) => {
    // Guesty Tokenization JS SDK is loaded and ready to use
  })
  .catch((error) => {
    console.error(
      'Failed to load the Guesty Tokenization JS SDK script',
      error
    );
  });

TypeScript Support

This package includes TypeScript type definitions for the Guesty Tokenization JS SDK. This includes types for the window.guestyTokenization namespace. We support projects using TypeScript versions >= 3.8.

1.0.2

2 months ago

1.0.1

3 months ago

1.0.1-0

3 months ago

1.0.0-0

8 months ago