PHP code example of antonowano / qiwi-topup

1. Go to this page and download the library: Download antonowano/qiwi-topup library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

antonowano / qiwi-topup example snippets


use Antonowano\QiwiTopup\Constant\ErrorCodes;
use Antonowano\QiwiTopup\Factory\RequestFactory;
use Antonowano\QiwiTopup\QiwiTopup;

$qiwi = new QiwiTopup();
$requestFactory = new RequestFactory(123, 'password');
$request = $requestFactory->createForGetBalance();
$response = $qiwi->sendRequest($request);

if ($response->getResultCode() == ErrorCodes::NO_ERROR) {
    var_dump($response->getBalances());
}

use Antonowano\QiwiTopup\Constant\Currencies;
use Antonowano\QiwiTopup\Constant\PaymentStatuses;
use Antonowano\QiwiTopup\Factory\RequestFactory;
use Antonowano\QiwiTopup\QiwiTopup;

$qiwi = new QiwiTopup();
$requestFactory = new RequestFactory(123, 'password');
$request = $requestFactory->createForPayToCard();
$request
    ->setTransactionNumber(12345678)
    ->setFromCcy(Currencies::RUB)
    ->setToAmount(1115)
    ->setToCcy(Currencies::RUB)
    ->setToAccountNumber('4265111122334411')
;
$response = $qiwi->sendRequest($request);
$payment = $response->getPayment();

if ($payment->getStatus() == PaymentStatuses::EXECUTED) {
    echo $payment->getTransactionNumber();
}

use Antonowano\QiwiTopup\Constant\Currencies;
use Antonowano\QiwiTopup\Constant\PaymentStatuses;
use Antonowano\QiwiTopup\Factory\RequestFactory;
use Antonowano\QiwiTopup\QiwiTopup;

$qiwi = new QiwiTopup();
$requestFactory = new RequestFactory(123, 'password');
$request = $requestFactory->createForPayToQiwi();
$request
    ->setIncomeWireTransfer(1)
    ->setToAmount(15)
    ->setToCcy(Currencies::RUB)
    ->setFromCcy(Currencies::USD)
    ->setTransactionNumber(321456)
    ->setToAccountNumber('79181234567')
;
$response = $qiwi->sendRequest($request);
$payment = $response->getPayment();

if ($payment->getStatus() == PaymentStatuses::EXECUTED) {
    echo $payment->getTransactionNumber();
}

use Antonowano\QiwiTopup\Constant\PaymentStatuses;
use Antonowano\QiwiTopup\Factory\RequestFactory;
use Antonowano\QiwiTopup\QiwiTopup;

$qiwi = new QiwiTopup();
$requestFactory = new RequestFactory(123, 'password');
$request = $requestFactory->createForGetStatus();
$request
    ->setTransactionNumber(12345678)
    ->setToAccountNumber('79181234567')
;
$response = $qiwi->sendRequest($request);
$payment = $response->getPayment();

if ($payment->getStatus() == PaymentStatuses::EXECUTED) {
    echo $payment->getTransactionNumber();
}

use Antonowano\QiwiTopup\Factory\RequestFactory;
use Antonowano\QiwiTopup\QiwiTopup;

$qiwi = new QiwiTopup();
$requestFactory = new RequestFactory(123, 'password');
$request = $requestFactory->createForCheckDepositPossible();
$request
    ->setPhone('79031234567')
    ->setIncomeWireTransfer(1)
;
$response = $qiwi->sendRequest($request);
$exist = $response->getExist();
$possible = $response->getDepositPossible();