PHP code example of worldstream-labs / omnipay-paysafe-payment-hub

1. Go to this page and download the library: Download worldstream-labs/omnipay-paysafe-payment-hub 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/ */

    

worldstream-labs / omnipay-paysafe-payment-hub example snippets




mnipay\Omnipay;

$gateway = Omnipay::create('PaysafePaymentHub');
$gateway->setApiKey('yourApiKey');

// When deploying to production, don't forget to set test mode to false
$gateway->setTestMode(false);




mnipay\Omnipay;

$gateway = Omnipay::create('PaysafePaymentHub');
$gateway->setApiKey('yourApiKey');

$response = $gateway->purchase([
    'amount'         => 11.00,
    'currency'       => 'EUR',
    'successUrl'     => 'https://url/success',
    'failureUrl'     => 'https://url/failure',
    'returnUrl'      => 'https://url/return',
    'consumerId'     => '[email protected]',
    'merchantRefNum' => 'abcdefg',
    'description'    => 'description',
    'text'           => 'text',
    'paymentMethod'  => 'neteller',
])->send();

redirect($response->getRedirectUrl());




$gateway = Omnipay::create('PaysafePaymentHub');
$gateway->setApiKey('yourApiKey');

$response = $gateway->getPaymentHandle([
    'paymentHandleId' = $paymentHandleId,
])->send();

$paymentHandle = $response->getPaymentHandle();
if ($response->getPaymentHandle()->isPayable()) {
    $completePurchaseResponse = $gateway->completePurchase([
        'amount'             => 11.00,
        'currency'           => 'EUR',
        'paymentHandleToken' => $paymentHandle->getPaymentHandleToken(),
        'merchantRefNum'     => 'ref2',
        'dupCheck'           => false,
        'settleWithAuth'     => true,
        'customerIp'         => '172.0.0.1',
        'description'        => 'description',
    ])->send();
}




$gateway = Omnipay::create('PaysafePaymentHub');
$gateway->setApiKey('yourApiKey');

$response = $gateway->fetchTransaction([
    'transactionId' => $webhook['payload']['id'],
])->send();

if ($response->isComplete()) {
    // payment is complete
}