PHP code example of mayoz / laravel-omnipay

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

    

mayoz / laravel-omnipay example snippets


    'providers' => [
        // Other service providers...

        Mayoz\Omnipay\OmnipayServiceProvider::class,
    ],

    'Omnipay' => Mayoz\Omnipay\Facades\Omnipay::class,

    'providers' => [
        'Stripe' => [
            'ApiKey'   => '',
            'testMode' => false,
        ],

        'Iyzico' => [
            'ApiKey'    => '',
            'ApiSecret' => '',
            'testMode'  => false,
        ]
    ],



    namespace App\Http\Controllers;

    use Omnipay;
    use Illuminate\Routing\Controller;

    class HomeController extends Controller
    {
        /**
         * Purchase.
         *
         * @return Response
         */
        public function purchase()
        {
            // Send purchase request
            $response = Omnipay::purchase([
                'amount' => '10.00',
                'currency' => 'USD',
                'card' => [
                    'number' => '4242424242424242',
                    'expiryMonth' => '6',
                    'expiryYear' => '2016',
                    'cvv' => '123'
                ]
            ])->send();

            // Process response
            if ($response->isSuccessful()) {

                // Payment was successful
                print_r($response);

            } elseif ($response->isRedirect()) {

                // Redirect to offsite payment gateway
                $response->redirect();

            } else {

                // Payment failed
                echo $response->getMessage();
            }
        }
    }