PHP code example of ilcleme / payum-tinkl

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

    

ilcleme / payum-tinkl example snippets



//config.php
yumBuilder;
use Payum\Core\Payum;
use Payum\Core\Model\Payment;

$paymentClass = Payment::class;

/** @var Payum $payum */
$payum = (new PayumBuilder())
    ->addDefaultStorages()
    ->addGatewayFactory('tinkl', function ($config, $coreGatewayFactory){
        return new \IlCleme\Tinkl\TinklGatewayFactory($config, $coreGatewayFactory);
    })
    ->addGateway('tinkl', [
        'factory' => 'tinkl',
        'clientId' => 'aClientId',
        'token' => 'aToken',
        'sandbox' => true, // switch to false to use in production environment
    ])
    ->getPayum();



// prepare.php
l';

/** @var \Payum\Core\Payum $payum */
$storage = $payum->getStorage($paymentClass);

$payment = $storage->create();
$payment->setNumber(uniqid());
$payment->setCurrencyCode('EUR');
$payment->setTotalAmount(500); // Price should be passed as integer but multiplied by 100
$payment->setDescription('A description');
$payment->setClientId('anId');
$payment->setClientEmail('[email protected]');
$payment->setDetails([
    'time_limit' => 60 // Value accepted in range from 60 to 900 (1 to 15 minutes), default to 900
]);

$storage->update($payment);
$captureToken = $payum->getTokenFactory()->createCaptureToken($gatewayName, $payment, 'done.php');
header("Location: ".$captureToken->getTargetUrl());