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

@lytrax/everypay

v1.0.9

Published

EveryPay payment gateway REST API adapter for JavaScript/NodeJS

Downloads

22

Readme

EveryPay Gateway REST API ES6 Bindings

This is an UNOFFICIAL Javascript ES6 library for binding EveryPay payments gateway REST API. By using this software you agree that the author has no responsibility of any issues, bugs, malfunctions or side-effects that may occur by using any piece of code included in this library.

This library is for server side usage. You must NEVER use or expose Private Key in client side. The only functions that can be used in client side using a Public Key, are when you need to create / retreive a token using createToken / retreiveToken.

Minimum requirement of NodeJS 10. It can also be compiled using Babel or directly use in React Native. It utilizes the fetch Web API and uses window.fetch for Web, global.fetch for React Native, node-fetch for NodeJS or fallback if there is no native fetch support.

You can find full API Documentation and Testing instructions.

Installation

NPM: npm install @lytrax/everypay --save Yarn: yarn add @lytrax/everypay

API Keys

Use environment variables to setup your gateway account credentials. There is an .env.example file you can check and copy. You can use dotenv package to auto load project root .env files. The library expects the following environment variables to be present:

EVERYPAY_APIENDPOINT="https://sandbox-api.everypay.gr"
EVERYPAY_PUBLIC_KEY="pk_..."
EVERYPAY_PRIVATE_KEY="sk_..."
EVERYPAY_SHARED_KEY="sh_..."

For Firebase, you can use Firebase CLI to set environment configuration:

firebase functions:config:set \
everypay_sandbox_public_key="pk_..." \
everypay_sandbox_private_key="sk_..." \
everypay_sandbox_shared_key="sh_..."

and then use functions config to initialize node process environment variables:

process.env['EVERYPAY_APIENDPOINT'] = 'https://sandbox-api.everypay.gr';
process.env['EVERYPAY_PUBLIC_KEY'] = functions.config().everypay_sandbox_public_key;
process.env['EVERYPAY_PRIVATE_KEY'] = functions.config().everypay_sandbox_private_key;
process.env['EVERYPAY_SHARED_KEY'] = functions.config().everypay_sandbox_shared_key;

Usage

API Documentation

Every function returns a Promise that can be either success with a result or fail with an error. When it fails, if the error contains an endPointError property, then that reflects an error at the gateway endpoint. You can find the endpoint error structure at the EveryPay API Reference Errors.

Every function can take an optional custom endpoint URL and/or endpoint key to use. When these parameters are omitted, default environment variables are used for all keys and endpoint URL. This can be usefull when creating tokens at the client and we receive the public key dynamically:

createToken({
  // Will use EVERYPAY_APIENDPOINT environment variable when omitted
  endPointURL: 'https://api.everypay.gr',
  // Will use EVERYPAY_PUBLIC_KEY environment variable when omitted
  endPointKey: 'pk_...',
  ...
})

Create token example

const { createToken } = require('@lytrax/everypay/Tokens');
// Or ES6 import
// import { createToken } from '@lytrax/everypay/Tokens';

// This should be called at the client

createToken({
  card_number: '5217925525906273',
  expiration_year: '2022',
  expiration_month: '05',
  cvv: '343',
  holder_name: 'John Doe'
})
  .then((token) => {
    // Success: Store or use the token
    // ...
  })
  .catch((error) => {
    if ('endPointError' in error) {
      // Handle EveryPay API error
    } else {
      // Handle other code error
    }
  });

Create customer using token example (using async/await)

const { createCustomer } = require('@lytrax/everypay/Customers');
// Or ES6 import
// import { createCustomer } from '@lytrax/everypay/Customers';

async function myFlow({
  tokenId: token,
  customerDescription: description,
  customerName: full_name,
  customerEmail: email
}) {
  try {
    const customer = await createCustomer({
      token,
      description,
      full_name,
      email
    });

    // Success: Use the customer object
    // ...
  } catch (error) {
    if ('endPointError' in error) {
      // Handle EveryPay API error
    } else {
      // Handle other code error
    }
  }
}

Testing

Testing instructions

All API bindings are fully tested:

EveryPay JS API All Tests Passed

License

MIT License

Copyright (c) Christos Lytras <[email protected]> (lytrax.io)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.