PHP code example of xola / omnipay-bundle

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

    

xola / omnipay-bundle example snippets


// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new Xola\OmnipayBundle\OmnipayBundle(),
        // ...
    );
}

    // From within a controller. This will return an instance `\Omnipay\Stripe`. `stripe_default` is the key as
    // specified in the config.
    $gateway = $this->get('omnipay')->get('stripe_default');

    // From within a controller. This will return an instance of `\Omnipay\MyGateway` as specified in
    // `omnipay.my_custom_name.gateway`
    $gateway = $this->get('omnipay')->get('my_custom_name');

$formData = ['number' => '4242424242424242', 'expiryMonth' => '11', 'expiryYear' => '2018', 'cvv' => '123'];
$response = $gateway->purchase(['amount' => '10.00', 'currency' => 'USD', 'card' => $formData])->send();

if ($response->isSuccessful()) {
    // payment was successful: update database
    print_r($response);
} elseif ($response->isRedirect()) {
    // redirect to offsite payment gateway
    $response->redirect();
} else {
    // payment failed: display message to customer
    echo $response->getMessage();
}