PHP code example of setono / payum-quickpay

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

    

setono / payum-quickpay example snippets


use Setono\Payum\Quickpay\QuickpayGatewayFactory;

QuickpayGatewayFactory::NAME;   // 'quickpay'



use Payum\Core\GatewayFactoryInterface;
use Payum\Core\PayumBuilder;
use Setono\Payum\Quickpay\QuickpayGatewayFactory;

$payum = (new PayumBuilder())
    ->addDefaultStorages() // or your own token/payment storages
    ->addGatewayFactory(QuickpayGatewayFactory::NAME, static function (array $config, GatewayFactoryInterface $coreGatewayFactory): QuickpayGatewayFactory {
        return new QuickpayGatewayFactory($config, $coreGatewayFactory);
    })
    ->addGateway('quickpay', [
        'factory' => QuickpayGatewayFactory::NAME,
        'api_key' => 'your-api-key',
        'private_key' => 'your-private-key',
        // any of the options above, e.g.
        'order_prefix' => 'shop-',
    ])
    ->getPayum();

'payment_methods' => 'creditcard,!jcb,!visa-us',
// or
'payment_methods' => ['creditcard', '!jcb', '!visa-us'],



use Payum\Core\Request\Capture;

// Checkout, the common case: send the customer through Capture. In a framework this is Payum's
// capture controller (Sylius does it for you); standalone, mint a capture token and redirect to it.
$token = $payum->getTokenFactory()->createCaptureToken('quickpay', $payment, 'after-checkout.php');
header('Location: ' . $token->getTargetUrl());

// Authorize-then-settle instead: an authorize token at checkout…
$token = $payum->getTokenFactory()->createAuthorizeToken('quickpay', $payment, 'after-checkout.php');
// …and later — e.g. when the order ships — a programmatic Capture of what was authorized:
$payum->getGateway('quickpay')->execute(new Capture($payment->getDetails()));

$quickpay->execute(new Sync($model));   // updates `balance` and `state`

$model['refund_amount'] = 250;          // minor units, like every amount here
$quickpay->execute(new Refund($model));

$model['capture_amount'] = 250;
$quickpay->execute(new Capture($model));