npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@easypaypt/checkout-sdk

v2.6.2

Published

SDK for easypay's Checkout

Downloads

139

Readme

Easypay Checkout SDK

Easypay's Checkout SDK is intended to facilitate integration between your application and our solution to receive payments.

easypay-checkout

Installation:

Install the package with:

npm install --save @easypaypt/checkout-sdk

# or

yarn add @easypaypt/checkout-sdk

Usage:

Import

import { startCheckout } from '@easypaypt/checkout-sdk'

const checkoutInstance = startCheckout(manifest, [options])

manifest - server to server response from checkout session creation

| Option | Type | Required | Default | Description | | ---------------- | ---------- | -------- | -------------------- | -------------------------------------------------------------------------- | | id | string | no | 'easypay-checkout' | The id of the HTML element where the Checkout form should be included. | | onSuccess | function | no | () => {} | Callback function to be called when the Checkout is finished successfully. | | onError | function | no | () => {} | Callback function to be called on (unrecoverable) errors. | | onPaymentError | function | no | () => {} | Callback function to be called on (recoverable) payment errors. | | onClose | function | no | undefined | Callback function to be called when the Checkout interaction is closed. | | testing | boolean | no | false | Whether to use the testing API (true) or the production one (false). | | display(1) | string | no | 'inline' | The display style of the element that hosts the Checkout. | | hideDetails | boolean | no | false | Whether to hide the details form or not. An expandable summary will be shown with the details, instead. | | language(2) | string | no | undefined | The language in which to display the Checkout. | | logoUrl | string | no | undefined | The merchant logo url to display in the Checkout. | | backgroundColor | string | no | '#ffffff' | The color used as the background of the Checkout page. | | accentColor | string | no | '#0d71f9' | The color used in highlights, as well as default buttons and input borders. | | errorColor | string | no | '#ff151f' | The color used for errors. | | inputBackgroundColor | string | no | 'transparent' | The color used for the input backgrounds. | | inputBorderColor | string | no | accentColor | The color for input borders. | | inputBorderRadius | number | no | 50 | The border radius for inputs, in px. | | inputFloatingLabel | boolean | no | true | Whether inputs should use floating labels. | | buttonBackgroundColor | string | no | accentColor | The color used for the button backgrounds. | | buttonBorderRadius | number | no | 50 | The border radius for buttons, in px. | | buttonBoxShadow | boolean | no | true | Whether the buttons should have box-shadow. | | fontFamily | string | no | 'Overpass' | The font used for the text. | | baseFontSize | number | no | 10 | The value in px for the font size of the root element (1rem). |

Options

(1)display available values: inline(default) or popup (2)language available values: en or pt_PT

Linking to the Page

<div id="easypay-checkout"></div>

Remove checkout from Page

checkoutInstance.unmount()

On Success

function mySuccessHandler(successInfo) {
  /** Show your own thank you message and/or do something with the payment info. */
}

const checkoutInstance = startCheckout(manifest, {
  onSuccess: mySuccessHandler,
})

On Error

function myErrorHandler(error) {
  checkoutInstance.unmount()
  switch (error.code) {
    case 'checkout-expired':
      /** The Checkout session expired and a new one must be created. */
      const manifest = await yourFunctionToGetTheManifest()
      checkoutInstance = startCheckout(manifest, {
        onError: myErrorHandler
      })
      break
    case 'already-paid':
      /** Order was already paid. */
      break
    case 'checkout-canceled':
      /** Order was canceled */
      break
    default:
      /** Unable to process payment. */
  }
}

const checkoutInstance = startCheckout(manifest, {
  onError: myErrorHandler
})

On Close

function myCloseHandler() {
  /** Checkout interaction closed */
}

const checkoutInstance = startCheckout(manifest, {
  onClose: myCloseHandler,
})

Changing appearance

const checkoutInstance = easypayCheckout.startCheckout(manifest, {
  logoUrl: 'www.example.com/mylogo.png',
  accentColor: 'orange',
  buttonBackgroundColor: '#111',
  buttonBoxShadow: false,
  buttonBorderRadius: 5,
  inputBorderRadius: 5,
  inputBorderColor: '#000',
  inputBackgroundColor: '#ffe7c4',
  backgroundColor: '#eee',
  fontFamily: 'https://fonts.gstatic.com/s/raleway/v28/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvaorCIPrEVIT9d0c8.woff2',
})

Development

Install dependencies:

$ yarn install

# or

$ npm install

Build package:

$ yarn build

#or

$ npm run build

Publish package:

$ npm publish

Demo

A live version of an integration with the SDK is available.

To test the package locally, you can use the source code for the checkout-demo as a starting point.

Common Problems

There are a few problems that may come up while integrating Checkout with your app.

  • Checkout not showing/Blank page initiating checkout

    If this occurs while integrating Checkout, check the browser devtools to see more details about the error. Sometimes due to some misconfiguration, while calling Checkout creation, this may happen. The fix is simple:

    1. Open the browser devtools to check which config option is throwing the error.
    2. Update the option accordingly.