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

gopay-js

v1.5.4

Published

The only functional library for GoPay payment gateway.

Downloads

35

Readme

⚡️ Getting Started

Installation

$ npm i gopay-js
# or if you are using Yarn
$ yarn add gopay-js

Tree

GoPay

  • init
  • getTokens()
  • getAccessToken()

Payments

  • getStatus()
  • createPayment()
  • refundPayment()
  • createRecurrence()

Misc

  • getAllowedMethodes()
  • accountStatement()

Types

  • Format
  • Item

🖇 Documentation

GoPay

Setting up enviroment is used to switch between sandbox (sandbox) and the production gateway (production).

import { goPay } from "gopay-js";

const client = new goPay({
  log: true,
  enviroment: "sandbox",
  credentials: {
    goID: "999999999",
    clientID: "00000000",
    clientSecret: "99999999",
  },
});

Methodes

All methodes included in base module.

getTokens()

the getTokens() method returns all the necessary keys, to work with GoPay here is example.:

client.getTokens();
//returns
{
  "token_type": "bearer",
  "access_token": "token",
  "expires_in": 1800,
  "refresh_token": "token"
}

getAccessToken()

client.getAccessToken();

Returns only access_token for necessary Authorization

Payments

It is necessary to create a payment before calling the payment gateway.

import { Payments } from "gopay-js";

const payments = new Payments({
  client: client,
});

getStatus()

The payment status functionality allows the point of sale to find out the current status of a previously created payment. By default, the payment status is queried upon receipt of a payment status change notification.

payments.getStatus(payment_id);

createPayment()

The payment is intended for payment of the order by credit card, bank transfer, GoPay account and other payment methods.

payments.createPayment({
  payment_info: {
    allowed_payment_instruments: [
      "PAYMENT_CARD",
      "BANK_ACCOUNT"
    ],
    default_payment_instrument: "PAYMENT_CARD",
    allowed_swifts: [
      "FIOBCZPP",
      "BREXCZPP"
    ],
    default_swift: "FIOBCZPP",
  }
  contact: {
    first_name: "Zbyněk",
    last_name: "Žák",
    email: "[email protected]",
    phone_number: "+420777456123",
    city: "České Budějovice",
    street: "Planá 67",
    postal_code: "37301",
    country_code: "CZE",
  },
  order_info: {
    amount: 119990,
    currency: "CZK",
    order_number: "OBJ20200825",
    order_description: "Obuv",
    lang: "CS",
  },
  callback: {
    return_url: "https://www.example.com/return",
    notification_url: "https://www.example.com/notify",
  },
  items: [
    {
      "type": "DISCOUNT",
      "name": "Obuv",
      "amount": 119990,
      "count": 1,
      "vat_rate": "21",
      "ean": 1234567890123,
      "product_url": "https://www.eshop.cz/boty/lodicky"
    }
  ],
});

The items parameter in body must contain order items in a certain form, so we have pre-created a type for you. More in Types section

refundPayment()

Payment refund allows you to return funds for a payment that has already been made to the customer. Refunds can be made in two ways. A full refund allows you to refund the full amount based on the amount parameter, while a partial refund specifies the refund amount.

payments.refundPayment(payment_id, amount);

createRecurrence()

With the request, it is possible to repeat the payment on the basis of a previously established recurring payment in the ON_DEMAND mode (on request). By recurring in this mode, a subsequent payment of any amount is established. The point of sale is informed of the payment in the form of a notification of a change in the payment status.

payments.createRecurrence({
  amount: 123,
  currency: "CZK",
  order_number: "OBJ1233878",
  order_description: "some desc.",
  items: [
    {
      type: "ITEM",
      name: "Pojisteni",
      amount: 119900,
      count: 1,
      vat_rate: "21",
      ean: 1234567890123,
      product_url: "https://www.eshop.cz/pojisteni",
    },
  ],
});

Misc

import { Misc } from "gopay-js";

const misc = new Misc({
  client: client,
});

getAllowedMethodes()

The method returns the JSON structure of all allowed payment methods on the e-shop profile. You only need to fill up currency option.

misc.getAllowedMethodes("currency");

accountStatement()

The funcionality generates statements from GoPay business account. It returns content of account statement file. More information about file types specification you can find in Help

misc.accountStatement({
  date_from: new Date(),
  date_to: new Date(),
  currency: "CZK",
  format: "CSV_A",
});

Types

Here is a list and description of the types created, which are for simplification and safer work with this library

Formats

| CSV | XLS | ABO | | ----- | ----- | ----- | | CSV_A | XLS_A | ABO_A | | CSV_B | XLS_B | ABO_B | | CSV_C | XLS_C | | CSV_D |

Item Type

The items parameter in body must contain order items in a certain form, so we have pre-created a type for you.

You can import simply import it and use it

import { item } from "gopay-js";

Here is the form

type: string;
name: string;
amount: number;
count: number;
vat_rate: string;
ean: number;
product_url: string;

🙅🏿‍♂️ Used OSS

  • Chalk
    • https://github.com/chalk/chalk

⭐️ License

gopay-js is licensed under MIT. See the LICENSE file.