Node JS module for payok.io

Overview

PAYOK

NODE JS модуль, который позволит принимать платежи платёжного агрегатора payok.io

PAYOK

📦 Установка

  • используя npm
    npm i payok
  • используя Yarn
    yarn add payok
  • используя pnpm
    pnpm add payok

🛠️ Использование

const { PAYOK } = require("payok");
const payok = new PAYOK({
    apiId: 1,
    apiKey: "yourApiKey",
    secretKey: "yourSecretKey",
    shop: 2000,
});
Параметр Тип Описание Обязательный
apiId number Ваш идентификатор (ID) API ключа +
apiKey string Ваш API ключ +
secretKey string Секретный ключ, который принадлежит проекту +
shop number Идентификатор (ID) проекта +

💳 Создание ссылки на форму оплаты


payok
    .getPaymentLink({
        amount: 10,
        desc: "Описание вашего товара",
        success_url: `https://github.com/kravetsone/payok`,
        email: "[email protected]",
        id: 123456,
    })
    .then((bill) => {
        console.log(bill); // { payUrl: "https://payok.io/pay?...", paymentId: "98dd5-51e1-a0644"}
    });
Параметр Тип Описание Обязательный
amount number Сумма платежа +
desc string Название или описание вашего товара +
success_url string Ссылка, на которую переадресует пользователя после успешной оплаты -
email string Email пользователя -
method string Способ оплаты -
lang string Язык интерфейса (RU/ENG) -
* any Любой ваш параметр, который придёт к вам на вебхук в случае оплаты -

Создание вебхука (обработчик успешной оплаты)


🚧 Параметр sign, приходящий вместе с платежём, уже проверен библиотекой, так что с ним вам взаимодействовать не потребуется.

payok.createWebhook(3000, (payment) => {
    console.log(payment);
    /*{
        payment_id: '51387-77a3-d3724',
        shop: '2000',
        amount: '10',
        profit: '10',
        desc: 'Описание вашего товара',
        currency: 'RUB',
        currency_amount: '10.69',
        sign: 'b7453a35683171d235dfb13a16b61f41',
        email: '[email protected]',
        date: '11.06.2022 12:13:15',
        method: 'Qiwi', 
        custom: { id: '123456' } 
    }*/
});
Параметр Тип Описание Обязательный
port number Порт на котором вы хотите раскрыть вебхук +
handler function Функция, которая выполниться при успешной оплате +

💰 Получение баланса


payok.api.getBalance().then((res) => {
    console.log(res); //{ balance: "10.00", ref_balance: "0" }
});

Без параметров

👉 Получить список транзакций


payok.api.getTransaction({ offset: 1 }).then((res) => {
    console.log(res);
    /*{
        {
            "status": "success"
            "1": {
                "transaction": 10000,
                "email": "[email protected]",
                "amount": "1065",
                "currency": "USD",
                "currency_amount": "14.26",
                "comission_percent": 5 ,
                "comission_fixed": "15",
                "amount_profit": "1000",
                "method": Visa/Mastercard,
                "payment_id": "10500",
                "description": "Описание транзакции",
                "date": "26.09.2021 20:40:07",
                "pay_date": "26.09.2021 21:00:00"
                "transaction_status": 0
                "custom_fields": null
                "webhook_status": 1
                "webhook_amount": 1
            }
        }
    }*/
});
Параметр Тип Описание Обязательный
payment string Идентификатор (ID) платежа -
offset number Пропуск определённого числа строк -

👈 Получить список выплат


payok.api.getPayouts({ offset: 1 }).then((res) => {
    console.log(res);
    /*{
        {
            "status": "success"
            "1": {
                "payout": 10000,
                "method": "card",
                "reciever": "5000400030002000",
                "type": "main",
                "amount": "1000",
                "comission_percent": 2 ,
                "comission_fixed": "50",
                "amount_profit": 930,
                "date_create": "26.09.2021 20:40:07",
                "date_pay": "26.09.2021 20:55:01",
                "status": 0
            }
        }
    }*/
});
Параметр Тип Описание Обязательный
payout_id string Идентификатор (ID) выплаты -
offset number Пропуск определённого числа строк -

Создание выплаты


payok.api
    .createPayout({
        amount: 10,
        method: "qiwi",
        reciever: "+79851628442",
        comission_type: "balance",
    })
    .then((res) => {
        console.log(res);
        /*{
            {
                "status":"success",
                "remain_balance":"229.44",
                "data": {
                    "payout_id": 100,
                    "method": "card",
                    "reciever": "5000400030002000",
                    "amount": 1000,
                    "comission_percent": 2 ,
                    "comission_fixed": "50",
                    "amount_profit": 930,
                    "date": "26.09.2021 20:40:07",
                    "payout_status_code": 0,
                    "payout_status_text": "WAIT"
                }
            }
        }*/
    });
Параметр Тип Описание Обязательный
amount number Сумма выплаты +
method string Способ оплаты +
reciever string Реквезиты на которые придёт выплата +
comission_type string Комиссия с баланса - balance, а если с выплаты - payment +
reciever string Реквезиты на которые придёт выплата +
webhook_url string URL вебхука для отправки статуса выплаты -

Если нашли ошибку, то создайте ISSUES

Changelog:

1.0.2 - Исправлены проблемы с API запросами (был неверно передан Content-Type). Убраны лишние зависимости (7 => 3) 1.0.1 - Фикс множества ошибок. 1.0.0 - Релиз библиотеки. Добавлен Readme

You might also like...

Babel-plugin-amd-checker - Module format checking plugin for Babel usable in both Node.js the web browser environments.

babel-plugin-amd-checker A Babel plugin to check the format of your modules when compiling your code using Babel. This plugin allows you to abort the

Jan 6, 2022

TzKTApi is a Node.js module to communicate with a tzkt API.

TzKTAPI TzKTApi is a Node.js module to communicate with a tzkt API. Heavily inspired by the dipdup-sdk. It uses the openapi-typescript-codegen to gene

Mar 10, 2022

OpenAPI (Swagger) module for Nest framework (node.js) :earth_americas:

A progressive Node.js framework for building efficient and scalable server-side applications. Description OpenAPI (Swagger) module for Nest. Installat

Jan 6, 2023

An NODE Module For Getting Data From Discord API Called Discord Info

An NODE Module For Getting Data From Discord API Called Discord Info

An NODE Module For Getting Data From Discord API Called Discord Info

Jun 7, 2022

Node module for synchronously and recursively merging multiple folders or collections of files into one folder.

merge-dirs Node module for synchronously and recursively merging multiple folders or collections of files into one folder. Install yarn add @nooooooom

Mar 20, 2022

Node.js module for verifying Plumo proofs and reading states based on it

plumo-verifier Node.js module for verifying Plumo proofs and reading states based on it. Plumo is a SNARK-based light client verifier for the Celo blo

Dec 15, 2022

A Node.js module for processing .aff files.

affutil.js 一个照抄 feightwywx/arcfutil aff模块 的 Node.js模块 in Typescript 可以进行aff格式字符串与Javascript对象之间的相互转换 为Note对象提供了有限的方法 恐狼是神,快去用arcfutil 用法 导入: In Node.j

Jun 9, 2022

Node module to easily lookup any pincode details in India.

pincode-india Node module to easily lookup any pincode details in India. The pincode data used in this module is provided by data.gov.in Install using

Sep 26, 2022

A simple Node.js module to access the MultiVersus API.

multiversus.js About A simple Node.js module to access the MultiVersus API. Installation npm install multiversus.js yarn add multiversus.js Example us

Dec 20, 2022
  • [email protected](Sep 7, 2022)

    🚧 Breaking change:

    • Перешли на events, так что для того чтобы мигрировать вам потребуется заменить payok.createWebhook(3000, eventFunction); на
    // Запускаем сам веб-сервер
    payok.createWebhook(3000, "/amazing-secret-url-path");
    // Слушаем обработанное событие пополнения
    payok.events.on("payment", eventFunction);
    
    • Теперь, к методу getPaymentLink нет нужды применять await, а так же дополнительные параметры необходимо вложить в custom. Например:
    const link = payok
        .getPaymentLink({
            amount: 10,
            desc: "Описание вашего товара",
            success_url: `https://github.com/kravetsone/payok`,
            email: "[email protected]",
            custom: {id: 123456}, //вместо id: 123456
        });
    

    ⚙Всякое разное:

    • Добавлены примеры
    • Вынес тяжелые типы из интерфейсов
    • Фикс ошибок в API запросах
    • Генерация *.d.ts файлов
    • Лого (/logo.png) вынесено в папку /assets/
    • Небольшие изменения в Readme

    Full Changelog: https://github.com/kravetsone/payok/commits/[email protected]

    Source code(tar.gz)
    Source code(zip)
Owner
kravets
kravets
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
An npm package for demonstration purposes using TypeScript to build for both the ECMAScript Module format (i.e. ESM or ES Module) and CommonJS Module format. It can be used in Node.js and browser applications.

An npm package for demonstration purposes using TypeScript to build for both the ECMAScript Module format (i.e. ESM or ES Module) and CommonJS Module format. It can be used in Node.js and browser applications.

Snyk Labs 57 Dec 28, 2022
Userland module that implements the module path mapping that Node.js does with "exports" in package.json

exports-map Userland module that implements the module path mapping that Node.js does with "exports" in package.json npm install exports-map Usage co

Mathias Buus 9 May 31, 2022
Node 18's node:test, as a node module

node-core-test This is a user-land port of node:test, the experimental test runner introduced in Node.js 18. This module makes it available in Node.js

Julian Gruber 62 Dec 15, 2022
Fintoc.js ES Module - Use the Fintoc widget as an ES module

Fintoc.js ES Module Use the Fintoc widget as an ES module. Installation Install using npm! (or your favourite package manager) # Using npm npm install

Fintoc 6 May 13, 2022
Template Repository for making your own budder Module. CORE is not included, this is just for the module.

A quick copy of the "How to make your own module" section Check out the official budderAPI repository Template Repository for making your own budder M

Logic 2 Apr 3, 2022
A module federation SDK which is unrelated to tool chain for module consumer.

hel-micro, 模块联邦sdk化,免构建、热更新、工具链无关的微模块方案 Demo hel-loadash codesandbox hel-loadash git Why hel-micro 如何使用远程模块 仅需要一句npm命令即可载入远程模块,查看下面例子线上示例 1 安装hel-micr

腾讯TNTWeb前端团队 319 Jan 3, 2023
Inter Process Communication Module for node supporting Unix sockets, TCP, TLS, and UDP. Giving lightning speed on Linux, Mac, and Windows. Neural Networking in Node.JS

Inter Process Communication Module for node supporting Unix sockets, TCP, TLS, and UDP. Giving lightning speed on Linux, Mac, and Windows. Neural Networking in Node.JS

Node IPC 43 Dec 9, 2022