PHP code example of johnluxor / qiwi-payment

1. Go to this page and download the library: Download johnluxor/qiwi-payment 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/ */

    

johnluxor / qiwi-payment example snippets





namespace Acme\QiwiServiceProvider\Command;

use Fruitware\QiwiServiceProvider\Model\Method\Check\CheckRequest;
use Fruitware\QiwiServiceProvider\Model\Method\Check\CheckResponse;

class CheckCommand extends CheckRequest
{
    /**
     * Internal logic processing
     *
     * @return CheckResponse
     */
    public function process()
    {
        // some your logic here
    
        /**
         * @var CheckResponse $response
         */
        $response = $this->getResponse();

        return $response
            ->setOsmpTxnId($this->getTxnId()) // 




namespace Acme\QiwiServiceProvider\Command;

use Fruitware\QiwiServiceProvider\Model\Method\Pay\PayRequest;
use Fruitware\QiwiServiceProvider\Model\Method\Pay\PayResponse;

class PayCommand extends PayRequest
{
    /**
     * Internal logic processing
     *
     * @return PayResponse
     */
    public function process()
    {
        // some your logic here
    
        /**
         * @var PayResponse $response
         */
        $response = $this->getResponse();

        return $response
            ->setOsmpTxnId($this->getTxnId()) // 




/**
 * Get ips from the contract!
 */
$validIps = array(
    '127.0.0.1', // for the test gate interface
//    '127.0.0.2', // for the production gate interface
);

$service = new \Fruitware\QiwiServiceProvider\Service($validIps, [
    'check' => 'Acme\QiwiServiceProvider\Command\CheckCommand',
    'pay' => 'Acme\QiwiServiceProvider\Command\PayCommand',
]);

/**
 * @var \Fruitware\QiwiServiceProvider\Model\Request\RequestInterface $method
 */
$method = $service->handleRequest($_GET);
$xmlResponseString = $method->process()->xml()->asXML();

echo $xmlResponseString;