Universal payments API SDK (UNOFFICIAL QIWI CLIENT)

Overview

Qiwi Php Client

Latest Version Software License Total Downloads

Especially for 🦊 Zorra Telecom and 👥 Everyone else

Привет

Attention: At the moment the number of methods is very limited, they will be added later if QIWI does not make a normal alternative... Внимание: На данный момент количество методов сильно ограниченно, они будут добавлены позже, если QIWI не сделает нормальную альтернативу...

Минимальный набор API - ЕСТЬ

Создание счета

Запрос создает платежный счет.

PUT /payin/v1/sites/{siteId}/bills/{billId}

Статус счета

Запрос предназначен для получения деталей платежного счета. В успешном ответе приходит список данных по счету и его платежам с запрошенным billId.

GET /payin/v1/sites/{siteId}/bills/{billId}/details

Получение списка платежей по счету

Получение списка платежей по счету

GET /payin/v1/sites/{siteId}/bills/{billId}

МОЖНО ИСПОЛЬЗОВАТЬ: Статус счета

Платеж

Запрос создает платежную транзакцию.

PUT /payin/v1/sites/{siteId}/payments/{paymentId}

ПОКА НЕ ПРИГОДИЛСЯ

Статус платежа

Получить информацию о платежной транзакции.

GET /payin/v1/sites/{siteId}/payments/{paymentId}

ПОКА НЕ ПРИГОДИЛСЯ

МОЖНО ИСПОЛЬЗОВАТЬ: Статус счета

Завершение аутентификации клиента

После успешного прохождения дополнительной аутентификации, ТСП необходимо отправить запрос с параметрами соответствующими типу дополнительной аутентификации для завершения проверки.

POST /payin/v1/sites/{siteId}/payments/{paymentId}/complete

ПОКА НЕ ПРИГОДИЛСЯ

Подтверждение платежа

Подтверждает платеж после холдирования средств. Если используется двухшаговый сценарий, то мерчанту необходимо отправить этот запрос после авторизации платежа.

PUT /payin/v1/sites/{siteId}/payments/{paymentId}/captures/{captureId}

ПОКА НЕ ПРИГОДИЛСЯ

Статус подтверждения

Запрашивает статус указанного подтверждения платежа.

GET /payin/v1/sites/{siteId}/payments/{paymentId}/captures/{captureId}

ПОКА НЕ ПРИГОДИЛСЯ

Операция возврата

Запрос предназначен для возврата средств по завершенному платежу. ТСП может выполнить несколько запросов для возврата частичных сумм.

PUT /payin/v1/sites/{siteId}/payments/{paymentId}/refunds/{refundId}

ПОКА НЕ ПРИГОДИЛСЯ

Install

Composer

composer require terentev-space/qiwi-php-client

Usage

  1. Set up QIWI: https://developer.qiwi.com/ru/payments/#start
  2. Connect the library
  3. Prepare
// Factories
$configFactory = new \QiwiClient\Factories\ConfigFactory();
$clientFactory = new \QiwiClient\Factories\ClientFactory();

// Make Config
$config = $configFactory->make(
    'siteId',
    'token',
    'publicKey' // optional
);
/* OR */
$config = new \QiwiClient\Entities\ClientConfig(
    'siteId',
    'publicKey',
    'token'
);

// Make Client
$client = $clientFactory->make(
    'siteId',
    'token',
    'publicKey' // optional
);
/* OR */
$client = Qiwi::client(
    'siteId',
    'token'
);
/* OR */
$client = new \QiwiClient\Client(
    $config,
    new \GuzzleHttp\Client(),
    new \Psr\Log\NullLogger()
);
  1. Use
$billId = '...';

$amount = 1.01;
/* OR */
$amount = 1.019; // = 1.01

$currency = Qiwi::CURRENCY_RUB;
/* OR */
$currency = 'RUB';

$expiration = null; // +1 day
/* OR */
$expiration = '2022-01-01T00:00:00+00:00';
/* OR */
$expiration = new DateTime();
/* OR */
$expiration = $datetime->format(\QiwiClient\Qiwi::DATETIME_FORMAT);

$flags = [
    \QiwiClient\Qiwi::FLAG_SALE, // optional
    \QiwiClient\Qiwi::FLAG_BIND_PAYMENT_TOKEN, // optional
];

$account = 'string(64) - id';
$email = 'string(64) or null - email';
$phone = 'string(15) or null - phone';

$country = 'string(1000) or null';
$city = 'string(1000) or null';
$region = 'string(1000) or null';
$details = 'string(1000) or null';

$pan = 'string(19) or null';
$wallet = 'string(64) or null';
$inn = 'string(12) or null';
$phone = 'string(15) or null';
$bankAccount = 'string(20) or null';
$bic = 'string(9) or null';

$cf1 = 'string(256) or null';
$cf2 = 'string(256) or null';
$cf3 = 'string(256) or null';
$cf4 = 'string(256) or null';
$cf5 = 'string(256) or null';
$merchantThemeCode = 'string(256) or null';
$merchantContractId = 'string(256) or null';
$merchantBookingNumber = 'string(256) or null';
$merchantPhone = 'string(256) or null';
$merchantFullName = 'string(256) or null';
$invoiceCallbackUrl = 'string(256) or null';

/** @var array $cheque Данные чека для операции. */
$cheque = [/* ... */];

$request = PaySiteBillQuery::make($billId, $amount, $currency)
    ->setExpirationDateTime($expiration) // optional
    ->setFlags(...$flags) // optional
    ->setCustomer(
        $account,
        $email, // optional
        $phone // optional
    ) // optional
    ->setAddress(
        $country, // optional
        $city, // optional
        $region, // optional
        $details // optional
    ) // optional
    ->setReceiverData(
        $pan, // optional
        $wallet, // optional
        $inn, // optional
        $phone, // optional
        $bankAccount, // optional
        $bic // optional
    ) // optional
    ->setCustomFields(
        $cf1, // optional
        $cf2, // optional
        $cf3, // optional
        $cf4, // optional
        $cf5, // optional
        $merchantThemeCode, // optional
        $merchantContractId, // optional
        $merchantBookingNumber, // optional
        $merchantPhone, // optional
        $merchantFullName, // optional
        $invoiceCallbackUrl // optional
    ) // optional
    ->setCheque($cheque)
;
/* OR */
$request = [
    'billId' => $billId,
    'amount' => [
        'value' => $amount,
        'currency' => $currency,
    ],
    'expirationDateTime' => $expiration,
    'flags' => $flags,
    'customer' => [
        'account' => $account,
        'email' => $email,
        'phone' => $phone,
    ],
    'address' => [
        'country' => $country,
        'city' => $city,
        'region' => $region,
        'details' => $details,
    ],
    'receiverData' => [
        'pan' => $pan,
        'wallet' => $wallet,
        'inn' => $inn,
        'phone' => $phone,
        'bankAccount' => $bankAccount,
        'bic' => $bic,
    ],
    'customFields' => [
        'cf1' => $cf1,
        'cf2' => $cf2,
        'cf3' => $cf3,
        'cf4' => $cf4,
        'cf5' => $cf5,
        'merchantThemeCode' => $merchantThemeCode,
        'merchantContractId' => $merchantContractId,
        'merchantBookingNumber' => $merchantBookingNumber,
        'merchantPhone' => $merchantPhone,
        'merchantFullName' => $merchantFullName,
        'invoiceCallbackUrl' => $invoiceCallbackUrl,
    ],
    'cheque' => $cheque,
];

$response = $client->paySiteBill($request);
$response->getCode(); // Response code 200
$response->getBody(); // Response data array
/** @var \QiwiClient\Entities\Results\PaySiteBillResult $data */
$data = $response->parseData();

// ...
$billId = $data->getBillId();
// 1.01
$amount = $data->getAmountValue();
// RUB
$currency = $data->getAmountCurrency();
// 2000-00-00T00:00:00+00:00
$exp = $data->getExpirationDateTime();
// 00000000-0000-0000-0000-000000000000
$invoice = $data->getInvoiceUid();
// CREATED
$status = $data->getStatusValue();
// 2000-00-00T00:00:00+00:00
$statusChanged = $data->getStatusChangedDateTime();
// https://oplata.qiwi.com/form?invoiceUid=00000000-0000-0000-0000-000000000000
$url = $data->getPayUrl();

$response = $client->getSiteBillDetails('1663126085');
$response->getCode(); // Response code 200
$response->getBody(); // Response data array
/** @var \QiwiClient\Entities\Results\GetSiteBillDetailsResult $data */
$data = $response->parseData();

// ...
$billId = $data->getBillId();
// 1.01
$amount = $data->getAmountValue();
// RUB
$currency = $data->getAmountCurrency();
// CREATED
$status = $data->getStatusValue();
// 2000-00-00T00:00:00+00:00
$statusChanged = $data->getStatusChangedDateTime();
/* ... */
// https://oplata.qiwi.com/form?invoiceUid=00000000-0000-0000-0000-000000000000
$url = $data->getPayUrl();

/** @var \QiwiClient\Entities\Items\SiteBillPayment $payment */
$payment = $data->getPayments()[0];

// siteId
$siteId = $payment->getSiteId();
// ...
$billId = $payment->getBillId();
// 1.01
$amount = $payment->getAmountValue();
// RUB
$currency = $payment->getAmountCurrency();
// CREATED
$status = $payment->getStatusValue();
/* ... */
// []
$status = $payment->getCustomFields();

Доработка библиотеки

  1. В библиотеке присутствует Dockerfile, сбилдить образ докера можно так: docker build -t "qiwi-php-client" .
  2. Запускать докер-контейнер можно так: docker run -it -v $(pwd):/qiwi-php-client qiwi-php-client bash
  3. При первом запуске надо подтянуть зависимости, в контейнере выполнить: composer install
  4. Настроено тестовое окружение, для его работы неоходимо скопировать файл phpunit.xml.dist в phpunit.xml
  5. Запуск тестов в контейнере: ./vendor/bin/phpunit

Credits

License

The MIT License. Please see License File for more information.

You might also like...
🤖 Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.
🤖 Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.

Telegram Bot API - PHP SDK Telegram Bot PHP SDK lets you develop Telegram Bots in PHP easily! Supports Laravel out of the box. Telegram Bot API is an

Official PHP SDK for interacting with the Knock API.

Knock PHP library Documentation See the documentation for PHP usage examples

DigitalOcean API v2 client for Symfony and API Platform

DigitalOcean Bundle for Symfony and API Platform DunglasDigitalOceanBundle allows using the DigitalOcean API from your Symfony and API Platform projec

Nexmo REST API client for PHP. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.

Client Library for PHP Support Notice This library and it's associated packages, nexmo/client and nexmo/client-core have transitioned into a "Maintena

API client for ThePay - payment gate API
API client for ThePay - payment gate API

This is the official highly compatible public package of The Pay SDK which interacts with The Pay's REST API. To get started see examples below.

Code Quiz MonoRepo (API, API Client, App)

Code Quiz Welcome to the Code Quiz Open Source project from How To Code Well. This is an Open Source project that includes an API and an App for the d

Official repository of the AWS SDK for PHP (@awsforphp)

AWS SDK for PHP - Version 3 The AWS SDK for PHP makes it easy for developers to access Amazon Web Services in their PHP code, and build robust applica

Mailgun's Official SDK for PHP

Mailgun PHP client This is the Mailgun PHP SDK. This SDK contains methods for easily interacting with the Mailgun API. Below are examples to get you s

可能是基于 hyperf 的最优雅的支付宝、微信支付 SDK 了
可能是基于 hyperf 的最优雅的支付宝、微信支付 SDK 了

当前组件整体处于 beta 阶段 运行环境 php = 7.3 composer hyperf = 2.1 安装 composer require yansongda/hyperf-pay:~1.0.0 说明 发布配置文件 php bin/hyperf.php vendor:publish ya

Releases(v0.1.1)
Owner
Ivan Terentev
Backend Developer – @zorra-telecom
Ivan Terentev
An unofficial wrapper client for lknpd.nalog.ru API

Unofficial MoyNalog API client An unofficial wrapper client for lknpd.nalog.ru API Install Via Composer $ composer require shoman4eg/moy-nalog Usage S

Artem Dubinin 18 Dec 14, 2022
OSTicket Unofficial API

Welcome to the unofficial OSTicket API! The purpose of this API is to help the community and leverage the use of OSTicket. For more info, please go to

Bruno Vieira 17 Oct 11, 2022
The Universal Device Detection library will parse any User Agent and detect the browser, operating system, device used (desktop, tablet, mobile, tv, cars, console, etc.), brand and model.

DeviceDetector Code Status Description The Universal Device Detection library that parses User Agents and detects devices (desktop, tablet, mobile, tv

Matomo Analytics 2.4k Jan 9, 2023
Laravel Package for 1APP. Learn how to integrate our APIs to build a web or mobile integration to send and accept payments for your application and businesses.

1APP Laravel Library Learn how to integrate our APIs to build a web or mobile integration to accept payments, make payment of Bills and as well custom

O'Bounce Technologies 4 Jul 25, 2022
OpenAI API Client is a component-oriented, extensible client library for the OpenAI API. It's designed to be faster and more memory efficient than traditional PHP libraries.

OpenAI API Client in PHP (community-maintained) This library is a component-oriented, extensible client library for the OpenAI API. It's designed to b

Mounir R'Quiba 6 Jun 14, 2023
Google-api-php-client - A PHP client library for accessing Google APIs

Google APIs Client Library for PHP Reference Docs https://googleapis.github.io/google-api-php-client/main/ License Apache 2.0 The Google API Client Li

Google APIs 8.4k Dec 30, 2022
API SDK for OpenTrade Commerce API: Taobao, Alibaba, JD, 1688, Aliexpress, Ebay.

OtapiPhpClient Create Client $client = new OtClient($key, $secret, $lang); key (Access Key) secret (Secret for access key) language (2 symbol lang id

OpenTrade Commerce 5 Sep 20, 2022
PHP JSON-RPC 2.0 Server/Client Implementation with Automatic Client Class Generation via SMD

PHP JSON-RPC 2.0 Server/Client Implementation with Automatic Client Class Generation via SMD

Sergey Bykov 63 Feb 14, 2022
SDK for latest version of Telegram bots API

SDK for latest version of Telegram bots API (from April 24, 2020) Using Examples Installing composer require "DiyorbekUz/Telelib: dev-master" Init bot

Diyorbek 2 Sep 5, 2021
A PHP SDK for the GlobalSmartOTP API.

GlobalSmartOTP PHP SDK A PHP SDK for the GlobalSmartOTP API. Requirements PHP 7.4 or higher cURL Installation $ git clone [email protected]:GlobalSmartOT

GlobalSmartOTP 4 Oct 2, 2022