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

payok

v2.0.0

Published

Node JS module for payok.io with types

Downloads

109

Readme

PAYOK

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

📦 Установка

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

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

import { PAYOK } from "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) проекта | + |

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


const link = payok.getPaymentLink({
    amount: 10,
    desc: "Описание вашего товара",
    success_url: `https://github.com/kravetsone/payok`,
    email: "[email protected]",
    custom: { id: 123456 },
});
console.log(link); // { 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) | - | | custom.* | any | Любой ваш параметр, который придёт к вам на вебхук в случае оплаты | - |

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


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

// Запускаем сам веб-сервер
payok.createWebhook(3000, "/amazing-secret-url-path");
// Слушаем обработанное событие пополнения
payok.events.on("payment", (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 | Порт на котором вы хотите раскрыть вебхук | + | | path | string | Путь по которому будет доступен вебхук | - |

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


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

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

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


payok.api.getTransactions({ offset: 1 }).then((res) => {
    console.log(res);
    /*[{
                "id": "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);
    /*[{
                "id": "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 | + | | webhook_url | string | URL вебхука для отправки статуса выплаты | - |

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

Changelog:

2.0.0 - Избавился от Axios, qs, добавил типов для ответа и всякие разные improves (но API всё ещё плохое)

1.0.4 - Breaking Change. Поменяли систему событий. Добавили примеры и множество более скромных деяних. Подробнее

1.0.3 - Поддержка TypeScript. Рефакторинг кода. Мелкие изменения в Readme. Зависимость node-fetch заменена на axios.

1.0.2 - Исправлены проблемы с API запросами (был неверно передан Content-Type). Убраны лишние зависимости (7 => 3)

1.0.1 - Фикс множества ошибок.

1.0.0 - Релиз библиотеки. Добавлен Readme