1.72.0 • Published 6 months ago

@rebilly/framepay v1.72.0

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

@rebilly/framepay

A lightweight wrapper to load Rebilly's FramePay library and provide types.

Why use @rebilly/framepay?

FramePay must be loaded from our CDN, by adding a script tag to your webpage, for example:

<html>
  <head>
    <link href="https://framepay.rebilly.com/framepay.css" rel="stylesheet" />
    <script src="https://framepay.rebilly.com/framepay.js"></script>
  </head>
  <body></body>
</html>

But this can be difficult to implement in a modern web application in a non-blocking way, and cannot provide types for typescript applications.

This library provides:

  • 🔄 Async script loading to ensure page rendering isn't blocked
  • ⚡️ A Promise API to know when script loading is complete
  • 🛠 TypeScript support out of the box

Installation

npm install @rebilly/framepay
# or
yarn add @rebilly/framepay

Usage

The package exports a loadFramepay function that loads the FramePay CDN script and CSS. It returns a promise that resolves with the FramePay instance.

Basic Usage

import { loadFramepay } from '@rebilly/framepay';

try {
  const framepay = await loadFramepay();

  // Use FramePay as normal.
  // For complete examples, see: https://www.rebilly.com/docs/dev-docs/basic-setup
  framepay.initialize({
    publishableKey: 'your-publishable-key',
    // Additional configuration parameters
  });
  framepay.on('error', function (error) {
    console.error('FramePay error:', error);
  });
  framepay.on('ready', function () {
    // Your page should have a DOM element with the id "card-element"
    framepay.card.mount('#card-element');
  });
} catch (error) {
  console.error('Failed to load Framepay: ', error);
}

TypeScript Support

This package includes TypeScript declarations for FramePay.

For example:

import type { FramePay, CardElement } from '@rebilly/framepay';

const mountCard = (framepay: FramePay, elementId: string): CardElement => {
  return framepay.card.mount(elementId);
};

Custom Script/Style URLs

You can optionally specify custom URLs for the FramePay script and stylesheet:

const framepay = await loadFramepay({
  scriptLink: 'https://custom-domain.com/framepay.js',
  styleLink: 'https://custom-domain.com/framepay.css',
});

Global Window Object

When FramePay is loaded, it automatically adds itself to the global window object. This means you can also access FramePay directly through these global variables:

const framepay = await loadFramepay();

// After loading, you can access FramePay as a global variable:
window.Framepay.initialize({
  // ...
});
1.72.0

6 months ago

1.71.1

6 months ago

1.71.0

6 months ago

1.70.2

6 months ago

1.70.1

6 months ago

1.70.0

6 months ago

1.69.1

6 months ago

1.69.0

6 months ago

1.68.0

6 months ago

1.67.0

6 months ago

1.66.2

6 months ago

1.66.1

6 months ago

1.66.0

6 months ago

1.65.0

6 months ago

1.64.1

6 months ago

1.64.0

6 months ago

1.63.0

6 months ago

1.62.2

6 months ago

1.62.1

6 months ago

1.62.0

6 months ago

1.61.1

6 months ago

1.61.0

7 months ago

1.60.2

7 months ago

1.60.1

7 months ago

1.60.0

7 months ago

1.59.1

7 months ago

1.59.0

7 months ago

1.58.0

7 months ago

1.57.2

7 months ago

1.57.1

7 months ago

1.57.0

7 months ago

1.56.5

7 months ago

1.56.4

7 months ago

1.56.3

7 months ago

1.56.2

7 months ago

1.56.1

7 months ago

1.56.0

7 months ago

1.55.1

7 months ago

1.55.0

7 months ago

1.54.0

7 months ago

1.53.0

7 months ago

1.52.3

7 months ago

1.52.2

7 months ago

1.52.1

7 months ago

1.52.0

7 months ago

1.51.2

8 months ago

1.51.1

8 months ago

1.51.0

8 months ago

1.50.0

8 months ago

1.49.0

8 months ago

1.48.1

8 months ago

1.48.0

8 months ago

1.47.0

8 months ago

1.46.0

8 months ago

1.45.0

8 months ago

1.44.0

8 months ago

1.43.0

8 months ago

1.42.1

8 months ago

1.42.0

8 months ago

1.41.0

8 months ago

1.40.1

8 months ago

1.40.0

8 months ago

1.39.0

8 months ago

1.38.2

8 months ago

1.38.1

8 months ago

1.38.0

8 months ago

1.37.0

8 months ago

1.36.1

8 months ago

1.36.0

9 months ago

1.35.0

9 months ago

1.34.0

9 months ago

1.33.6

9 months ago

1.33.5

9 months ago

1.33.4

9 months ago

1.33.3

9 months ago

1.33.2

9 months ago

1.33.1

9 months ago

1.33.0

9 months ago

1.32.0

9 months ago

1.31.1

9 months ago

1.31.0

9 months ago

1.30.0

9 months ago

1.29.0

9 months ago

1.28.1

9 months ago

1.28.0

9 months ago

1.27.0

10 months ago

1.26.0

10 months ago

1.25.2

10 months ago

1.25.1

10 months ago

1.25.0

10 months ago

1.24.1

10 months ago

1.24.0

10 months ago

1.23.0

10 months ago

1.22.0

10 months ago

1.21.3

10 months ago

1.21.2

10 months ago

1.21.1

10 months ago

1.21.0

10 months ago

1.20.1

10 months ago

1.20.0

10 months ago

1.19.0

10 months ago

1.18.0

10 months ago

1.17.4

10 months ago

1.17.3

11 months ago

1.17.2

11 months ago

1.17.1

11 months ago

1.17.0

11 months ago

1.16.0

11 months ago

1.15.0

11 months ago

1.14.1

11 months ago

1.14.0

11 months ago

1.13.0

11 months ago

1.12.0

11 months ago

1.11.0

11 months ago

1.10.0

11 months ago

1.9.0

11 months ago

1.8.1

11 months ago

1.8.0

11 months ago

1.7.1

12 months ago

1.7.0

12 months ago

1.6.0

12 months ago

1.5.2

12 months ago

1.5.1

12 months ago

1.5.0

12 months ago

1.4.6

12 months ago

1.4.5

12 months ago

1.4.4

12 months ago

1.4.3

12 months ago

1.4.2

12 months ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago