Socket
Socket
Sign inDemoInstall

@dintero/checkout-web-sdk

Package Overview
Dependencies
Maintainers
2
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dintero/checkout-web-sdk

Dintero Checkout SDK for web frontends


Version published
Weekly downloads
782
increased by25.32%
Maintainers
2
Weekly downloads
 
Created
Source

Dintero Checkout JavaScript SDK for frontend applications

Use this SDK in your frontend application to

  • embed an existing Dintero Checkout payment session in an iframe on your website
  • redirect the end user to the full page version of the Dintero Checkout for an existing payment session

Note that this SDK is for redirecting or embedding existing payment sessions. You cannot use this SDK to send requests to the Checkout API or to crate new payment sessions.

Learn more about the Dintero Checkout at docs.dintero.com

Before you start

We cannot guarantee the delivery of events from the embedded checkout to the SDK client runtime. The sessions machine-to-machine callback_url will be delivered at least once. Read more about the callback_url parameter in our api spec.

For payments on devices with the Vipps app installed, after payment is completed in the Vipps app, the end user will be returned to the browser where the return_url on the payment is opened in a ew browser tab leaving the site that has the embedded checkout still open in a background browser tab on the device. In this case the SDK cannot guarantee that the handlers for onPaymentAuthorized or onPaymentError will be called.

If no custom handler are added for onPaymentError, onPaymentAuthorized and onPaymentCanceled the SDK will redirect the user to the return_url in the payment session.

Installation

NPM package

npm install @dintero/checkout-web-sdk

unpkg

Load the Dintero Checkout SDK in a script tag on your site.

<script src="https://unpkg.com/@dintero/checkout-web-sdk@0.0.8/dist/checkout-web-sdk.umd.js" integrity="sha384-Pum6UWrLeVO8MviAwvk6LNBgChlJBjPheE/NRbxFEYwXBMCA5Mq8g2LXGqFI8OJv"></script>

Using the SDK for an embedded checkout

The Dintero Checkout will be added to the <div id="checkout-container"></div> DOM-node.

Inline HTML JavaScript example

The checkout sdk will add a polyfill for promises if the browser does not support promises natively.

<script type="text/javascript">
    const container = document.getElementById("#checkout-container");

    dintero
        .embed({
            container,
            sid: "T11223344.<short-uuid>",
            onSession: function(event, checkout) {
                console.log("session", event.session);
            },
            onSessionPaymentAuthorized: function(event, checkout) {
                console.log("transaction_id", event.transaction_id);
                console.log("href", event.href);
                checkout.destroy();
            },
            onSessionPaymentError: function(event, checkout) {
                console.log("href", event.href);
                checkout.destroy();
            },
            onSessionCancel: function(event, checkout) {
                console.log("href", event.href);
                checkout.destroy();
            },
        })
        .then(function(checkout) {
            console.log("checkout", checkout);
        });
</script>

Typescript example

import {
    dintero,
    SessionLoaded,
    SessionUpdated,
    SessionPaymentAuthorized,
    SessionPaymentError,
    SessionCancel,
} from "@dintero/checkout-web-sdk";

const container = document.getElementById("#checkout-container");

const checkout = await dintero.embed({
    container,
    sid: "T11223344.<short-uuid>",
    onSession: (event: SessionLoaded | SessionUpdated) => {
        console.log("session", event.session);
    },
    onSessionPaymentAuthorized: (event: SessionPaymentAuthorized) => {
        console.log("transaction_id", event.transaction_id);
        console.log("href", event.href);
        checkout.destroy();
    },
    onSessionPaymentError: (event: SessionPaymentError) => {
        console.log("href", event.href);
        checkout.destroy();
    },
    onSessionCancel: (event: SessionCancel) => {
        console.log("href", event.href);
        checkout.destroy();
    },
});

Using the SDK for a redirect checkout

The user is redirected to the Dintero Checkout to complete payment.

import { dintero, SessionPaymentAuthorized } from "dintero-checkout-web-sdk";

const checkout = dintero.redirect({
    sid: "T11223344.<short-uuid>",
});

Bugs

Bugs can be reported to https://github.com/dintero/checkout-web-sdk/issues

Security

Contact us at security@dintero.com

Browser support

All major browsers above version N - 1, where N is the most recent version. For Internet Explorer, only version 11 is supported.

The SDK includes a polyfill for promises that is added to the global scope if promises are not supported by the browser.

Building from source

npm install
npm run build

The Dintero Checkout SDK is built with microbundle.

Creating a new release checklist

  1. Bump the package version in package.json.
  2. Regenerate integrity hash and update the unpgk install instructions in this file shasum -b -a 384 dist/checkout-web-sdk.umd.js | awk '{ print $1 }' | xxd -r -p | base64 | sed "s/^/sha384-/g"
  3. Publish new version to npm with npm publish --access=public.

FAQs

Package last updated on 10 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc