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

@maximkott/epik

v9.2.0

Published

E-Payment Integration Kit.

Downloads

78

Readme

EPIK

E-Payment Integration Kit.

It's a JS-library that allows you to integrate Raisenow's E-payment functionalities into your website.

Installation

Simply run npm install

Run locally

You can test epik inside a browser by running the demo widget and the temporary credit card iframe wrapper.

  # run demo widget with epik
  npm run demo
  
  # run credit card iframe
  npm run iframe
  
  # build and deploy iframe
  npm run iframe-build-and-deploy

To build epik for distribution, run command below. This will create three different epik versions - "esm", "cjs" and "umd", each inside a separate directory

# build epik without production optimizations
npm run epik

# build epik and publish to npm with production optimizations
npm run epik-build-and-publish

Sample widget implementation flow

;(async function() {
  //////////////////////////////////////////////////////////////////////////////
  // 1. Retrieve form data from your widget
  //////////////////////////////////////////////////////////////////////////////

  // return form data, you might want to
  // retrieve actual form data from an html form
  function getFormData() {
    return {
      // supported flows are iframe, popup or redirect
      flow: 'popup',
      payment_method: 'cc',
      currency: 'usd',
      amount: 1000,
      cardno: '4242424242424242',
      cvv: '123',
      expm: '12',
      expy: '18',
      stored_customer_firstname: 'John',
      stored_customer_lastname: 'Snow',
    }
  }

  //////////////////////////////////////////////////////////////////////////////
  // 2. Handle validation errors
  //////////////////////////////////////////////////////////////////////////////

  // handle validation errors
  function handleValidationErrors(errors) {
    console.log('validation errors', errors)
  }

  //////////////////////////////////////////////////////////////////////////////
  // 3. Handle payment response
  //////////////////////////////////////////////////////////////////////////////

  // handle payment response, either successful or not
  function handleResponse(response) {
    let success = response.epayment_status === 'success'

    if (success) {
      console.log('successful payment', response)
    }

    if (!success) {
      console.error('failed payment', response)
    }
  }

  //////////////////////////////////////////////////////////////////////////////
  // 4. Submit a new payment
  //////////////////////////////////////////////////////////////////////////////

  async function sendPayment (payment) {
    // validate payment
    let errors = await payment.validate()

    // handle errors, if any
    if (errors) {
      handleValidationErrors(errors)
    }

    if (!errors) {
      // submit payment
      let response = await payment.send()
      handleResponse(response)
    }
  }

  //////////////////////////////////////////////////////////////////////////////
  // 5. Create a new EPIK instance
  //////////////////////////////////////////////////////////////////////////////

  // create a new epik instance
  let epik = rnw.createEpik({
    // your api key
    apiKey: '1234567890',
    // use current window location for success / error / cancel payment redirects
    successUrl: window.location.origin + window.location.pathname + '?success',
    errorUrl: window.location.origin + window.location.pathname + '?error',
    cancelUrl: window.location.origin + window.location.pathname + '?cancel',
  })


  //////////////////////////////////////////////////////////////////////////////
  // 6. Actual code to trigger a payment
  //////////////////////////////////////////////////////////////////////////////

  // retrieve probable redirect response,
  // it might or might not exist
  // you'll get a redirect response after a payment
  // that has caused the browser to redirect away from your page
  let response = await epik.getRedirectTransaction()

  // if there is a redirect payment response available, handle it
  if (response) {
    handleResponse(response)
  }

  if (!response) {
    // create a new payment based on form data
    let payment = epik.createPayment(getFormData())
    // set to true to enable credit card iframe
    let useCreditCardIframe = false

    // if credit card iframe is used,
    // you may not send this payment immediately,
    // you must fill out the credit card form first
    if (useCreditCardIframe) {
      // render credit card iframe
      await payment.showCreditCardIframe()
    }

    // call window.sendPayment() manually from console
    // after you've filled the credit card iframe
    window.sendPayment = () => sendPayment(payment)
  }

  //////////////////////////////////////////////////////////////////////////////
  // YOU CAN COPY & PASTE THIS INTO YOUR BROWSER'S CONSOLE
  //////////////////////////////////////////////////////////////////////////////
})()

EPIK flow

Use this chart as reference for the various EPIK flows.

flow chart