PHP code example of janwebdev / symfony-omnipay-bundle

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

    

janwebdev / symfony-omnipay-bundle example snippets


// ...
Janwebdev\OmnipayBundle\OmnipayBundle::class => ['all' => true],

// ...
private function getCustomGateway(OmnipayManager $omnipay): GatewayInteface
{
    return $omnipay->get('CustomGateway');
}
// ...

$omnipay->getDefaultGateway();



// App/Omnipay/MyService.php

namespace App\Omnipay;

use App\Payment\Processing\Gateway\CardSavingInterface;
use Janwebdev\OmnipayBundle\Manager\OmnipayManager as BaseOmnipay;
use Omnipay\Common\GatewayInterface;

class MyService extends BaseOmnipay
{
    /**
     * @return CardSavingInterface[]
     */
    public function getCardSavingGateways(): array
    {
        return array_filter($this->registeredGateways, function (GatewayInterface $gateway) {
            return $gateway instanceof CardSavingInterface;
        });
    }
}

// ...
foreach ($omnipay->getCardSavingGateways() as $gateway) {
    $gateway->saveCreditCard($creditCard); // assuming saveCreditCard is a part of CardSavingInterface interface
}
// ...
 php


// ...

public function makePayment(OmnipayManager $omnipay)
{
    $stripe = $omnipay->get('Stripe');
    $paypal = $omnipay->get('PayPal_Express');
// ...