@commercetools/checkout-browser-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published

Commercetools Checkout Typescript SDK

Usage examples

Browser environment

<script src="https://unpkg.com/@commercetools/checkout-browser-sdk@latest/browser/sdk.js"></script>
<script>
  (function(w, d, s){
    if (w.ctc) {return;}
    var js, fjs = d.getElementsByTagName(s)[0];
    var q = [];
    w.ctc = w.ctc || function() { q.push(arguments); }
    w.ctc.q = q;
    js = d.createElement(s);
    js.type = 'text/javascript';
    js.async = true;
    js.src = 'https://cdn.checkout.europe-west1.gcp.commercetools.com/sdk.js';
    fjs.parentNode.insertBefore(js, fjs);
  }(window, document, 'script'));
  ctc('init', {
    checkoutConfig: {
      sellerId: '{sellerId}',
      applicationId: '{applicationId}',
      host: 'https://app.checkout.{region}.commercetools.com',
      callbackUrl: '{callbackUrl}',
      cartId: '{cartId}',
      accessToken: '{accessToken}',
      locale: '{locale}'
    }
  });
</script>

Node environment

import sdk from '@commercetools/checkout-browser-sdk';

sdk.init({
  checkoutConfig: {
    sellerId: '{sellerId}',
    applicationId: '{applicationId}',
    host: 'https://app.checkout.{region}.commercetools.com',
    callbackUrl: '{callbackUrl}',
    cartId: '{cartId}',
    accessToken: '{accessToken}',
    locale: '{locale}'
  }
  logInfo: true,
  logWarn: true,
  logError: true,
  onInfo: m => console.log('[Info]', m),
});

Readme

Keywords

none

Package Sidebar

Install

npm i @commercetools/checkout-browser-sdk

Weekly Downloads

134

Version

0.4.0

License

none

Unpacked Size

32.8 kB

Total Files

19

Last publish

Collaborators

  • commercetools-admin
  • emmenko
  • hajoeichler
  • yanns
  • tdeekens
  • timonrey
  • vineetkumarkushwaha
  • markusazer
  • jherey
  • danrleyt
  • jenschude
  • chukwuemeka