PHP code example of vimeo / omnipay-bluesnap

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

    

vimeo / omnipay-bluesnap example snippets


// Set up the gateway
$gateway = \Omnipay\Omnipay::create('BlueSnap_HostedCheckout');
$gateway->setUsername('your_username');
$gateway->setPassword('y0ur_p4ssw0rd');
$gateway->setTestMode(false);

// Start the purchase process
$purchaseResponse = $gateway->purchase(array(
    'storeReference' => '12345',
    'planReference' => '1234567',
    'currency' => 'USD'
))->send();

if ($purchaseResponse->isSuccessful()) {
    $purchaseResponse->redirect();
} else {
    // error handling
}

// Now the user is filling out info on BlueSnap's hosted checkout page. Then they get
// redirected back to your site. If you set parameters in the return/callback URL, you
// can access those here.

// Once the transaction has been captured, you'll receive an IPN callback, which you can
// handle like so:

$ipnCallback = $gateway->parseIPNCallback($_SERVER['REQUEST_URI']);
if ($ipnCallback->isCharge()) {
    echo 'Transaction reference: ' . $ipnCallback->getTransactionReference() . PHP_EOL;
    echo 'Amount: ' . $ipnCallback->getAmount() . PHP_EOL;
    echo 'Currency: ' . $ipnCallback->getCurrency() . PHP_EOL;
} elseif ($ipnCallback->isCancellation()) {
    // etc.
}