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-nodejs

v1.2.2

Published

GoPay node.js SDK for payments REST API =========

Downloads

106

Readme

GoPay node.js SDK for payments REST API

David GitHub GitHub code size in bytes

Please visit https://doc.gopay.com/en/ for more informations.

Installation

You can install via npm

npm install gopay-nodejs

Basic usage

const gopay = require('gopay-nodejs');

Initialization is done through class GoPay. This class accepts three parameters. First your Client ID as string, second Client secret as string and third is optional boolean value for sandbox (true) or live (false) mode (default is true).

const gp = new gopay.GoPay("ClientID", "ClientSecret", true);

After initialization you can use all methods listed below. Every method accepts and returns data according to official GoPay documentation.

Example

const gopay = require('gopay-nodejs');

const gp = new gopay.GoPay("ClientID", "ClientSecret", true);
const data = {
  "target": {
            "type":"ACCOUNT",
            "goid":"8123456789"
          },
  "amount":"10000",
  "currency":"CZK",
  "order_number":"001",
  "items": [{
            "type":"ITEM", 
            "name":"obuv",
            "product_url":"https://www.eshop.cz/boty/lodicky", 
            "ean":1234567890123,
            "amount":10000,
            "count":1,
            "vat_rate":21
            }],
  "callback":{
            "return_url":"http://www.eshop.cz/return",
            "notification_url":"http://www.eshop.cz/notify"
          },
}

gp.createPayment(data).then(payment => {
  console.log(payment)
})

Get token

Function getToken() accepts one optional string parameter called scope. Default value is "payment-all". You can find all accepting values in docs: scope. Function returns token as string.

gp.getToken().then(token => {
  console.log(token)
}

Create payment

Function createPayment(JSON_DATA) accepts one required json parameter. You can find all informations about required json in docs: payment. Function returns json described in docs: payment

gp.createPayment(JSON_DATA).then(payment => {
  console.log(payment)
}

Payment status

Function getStatus(PAYMENT_ID) accepts one required string parameter called payment ID (payment ID is generated by GoPay). Function returns json described in docs: payment status

gp.getStatus(PAYMENT_ID).then(status => {
  console.log(status)
}

Void authorization

Function voidAuthorization(PAYMENT_ID) accepts one required string parameter called payment ID (payment ID is generated by GoPay). Function returns json described in docs: void auth

gp.voidAuthorization(PAYMENT_ID).then(info => {
  console.log(info)
}

Capture authorization

Function captureAuthorization(PAYMENT_ID) accepts one required string parameter called payment ID (payment ID is generated by GoPay). Function returns json described in docs: capture auth

gp.captureAuthorization(PAYMENT_ID).then(info => {
  console.log(info)
}

Partial authorization

Function partialAuthorization(PAYMENT_ID, JSON_DATA) accepts two required parameters. First is string called payment ID (payment ID is generated by GoPay) and second is json described in docs: json. Function returns json described in docs: partian auth

gp.partialAuthorization(PAYMENT_ID, JSON_DATA).then(info => {
  console.log(info)
}

Create recurrence

Function createRecurrence(PAYMENT_ID, JSON_DATA) accepts two required parameters. First is string called payment ID (payment ID is generated by GoPay) and second is json described in docs: json. Function returns json described in docs: recurring on demand

gp.createRecurrence(PAYMENT_ID, JSON_DATA).then(info => {
  console.log(info)
}

Void recurrence

Function voidRecurrence(PAYMENT_ID) accepts one required string parameter called payment ID (payment ID is generated by GoPay). Function returns json described in docs:void recurrence

gp.voidRecurrence(PAYMENT_ID).then(info => {
  console.log(info)
}

Refund payment

Function refundPayment(PAYMENT_ID, AMOUNT) accepts two required parameters. First is string called payment ID (payment ID is generated by GoPay) and second is number, number represents amount in cents (long > 0) more in docs: refund. Function returns json described in docs:refund

gp.refundPayment(PAYMENT_ID, AMOUNT).then(info => {
  console.log(info)
}