PHP code example of xpat / tinkoffbundle

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

    

xpat / tinkoffbundle example snippets


// app/AppKernel.php

public function registerBundles()
{
    $bundles = [
        // ...
        new Xpat\TinkoffBundle\XpatTinkoffBundle(),
        // ...
    ];
}

use Xpat\TinkoffBundle\Service\PaymentParameterBuilder;
use Xpat\TinkoffBundle\Service\TinkoffPaymentService;



class InitController extends Controller
{
    
    public function indexAction(PaymentParameterBuilder $parameterBuilder, TinkoffPaymentService $service)
    { 
        $params = $this->parameterBuilder->build();
        $params->setOrderId($orderId);
        $params->setAmount($amount);
        //set another fields
        $result = $service->initPayment($params);
        // handle result
        return $this->redirect($result->getPaymentURL());
        
    }
}