checkout-web-components
v0.2.0-beta
Published
Checkout Payment Components loader
Downloads
97
Readme
Checkout Web Components Loader
Loader for Checkout Web Components.
Table of contents
Installation
Use npm
to install the package.
npm install checkout-web-components
Usage
The loadCheckoutWebComponents
function is the entry point for the library.
The function returns a Promise
resolving with a CheckoutWebComponents
instance, and handles loading the Checkout Web Components
script. This instance can then be used to create PaymentComponents that can be mounted.
import { loadCheckoutWebComponents } from 'checkout-web-components';
Example
const cko = await loadCheckoutWebComponents({
publicKey: 'pk_XXXXXX',
paymentSession,
environment: 'sandbox'
});
// You can now create and mount a payment component using 'cko'
const paymentsComponent = cko.create('payments');
// Mount payments component to div with an id of 'payments'
paymentsComponent.mount('#payments');
Replace the example pk_XXXXXX
value with your own public key. You can find your public key in the Developers section of your Checkout.com Production Dashboard or Checkout.com Sandbox Dashboard. See our API keys documentation for more information.
License
This project is licensed under the MIT License.