2017 © Pedro Peláez
 

library laravel-shop-gateway-omnipay

Omnipay gateway for Laravel Shop package.

image

amostajo/laravel-shop-gateway-omnipay

Omnipay gateway for Laravel Shop package.

  • Thursday, November 5, 2015
  • by amostajo
  • Repository
  • 1 Watchers
  • 6 Stars
  • 1,151 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 6 Versions
  • 1 % Grown

The README.md

# OMNIPAY GATEWAY (for Laravel Shop Package)

Latest Stable Version Total Downloads License, (*1)

Omnipay Gateway solution for Laravel Shop., (*2)

Enables multiple gateway payment, like PayPal, 2Checkout, Stripe and others. See the full list at Omnipay's page., (*3)

Gateways

This package comes with:, (*4)

  • Omnipay

Contents

Installation

Add, (*5)

"amostajo/laravel-shop-gateway-omnipay": "1.0.*"

to your composer.json. Then run composer install or composer update., (*6)

Then in your config/shop.php add, (*7)

'omnipay'           =>  Amostajo\LaravelShopGatewayOmnipay\GatewayOmnipay::class,

in the gateways array., (*8)

Gateway Usage

The following example will give you an idea of how use and access omnipay:, (*9)

// (1) - Set gateway
Shop::setGateway('omnipay');

// (2) - Indicate service to use
Shop::gateway()->create('PayPal_Rest');

// (3) - Initialize your service (varies from service)
Shop::gateway()->omnipay->initialize([
    'clientId' => '...',
    'secret'   => '...',
    'testMode' => true,
]);

// (4) - Add credit card for validation (optional depending service)
Shop::gateway()->setCreditCard([
    'number'            => '4111111111111111',
    'expiryMonth'       => '1',
    'expiryYear'        => '2019',
    'cvv'               => '123',
    'firstName'         => 'John',
    'lastName'          => 'Doe',
    'billingAddress1'   => '666 grand canyon',
    'billingCountry'    => 'US',
    'billingCity'       => 'TX',
    'billingPostcode'   => '12345',
    'billingState'      => 'TX',
]);

// (5) - Call checkout
if (!Shop::checkout()) {
  echo Shop::exception()->getMessage(); // echos: card validation error.
}

// (6) - Create order
$order = Shop::placeOrder();

// (7) - Review payment
if ($order->hasFailed) {

  echo Shop::exception()->getMessage(); // echos: payment error.

}

The lines may vary depending on the service chosen., (*10)

NOTE: Checkout and placing order shouldn't vary from standard Laravel Shop flow., (*11)

Accessing Omnipay

You can always access the omnipay object if you need to set or call any specific method required by a service:, (*12)

// (1) - Set gateway
Shop::setGateway('omnipay');
Shop::gateway()->create('Stripe');

// (2) - Setting method / calling specific method
Shop::gateway()->omnipay->setSpecific();

Adding Options

You can add more options, apart from amount, currency and card, to the authorization and purchase methods:, (*13)

// (1) - Set gateway
Shop::setGateway('omnipay');
Shop::gateway()->create('Stripe');

// (2) - Adding an option
Shop::gateway()->addOption('token', $stripetoken);

// (3) - Any operation that follows
Shop::checkout();

Callbacks

Use the following example when callbacks are needed:, (*14)

// (1) - Set gateway
Shop::setGateway('omnipay');
Shop::gateway()->create('PayPal_Express');

// (2) - Authentication
Shop::gateway()->omnipay->setUsername('...');
Shop::gateway()->omnipay->setPassword('...');

// (2) - Call checkout / OPTIONAL
Shop::checkout();

// (3) - Create order
$order = Shop::placeOrder();

// (4) - Review order and redirect to payment
if ($order->isPending) {

  // PayPal URL to redirect to proceed with payment
  $approvalUrl = Shop::gateway()->getApprovalUrl();

  // Redirect to url
  return redirect($approvalUrl);
}

// (5) - Callback
// You don't have to do anything.
// Laravel Shop will handle the callback and redirect the customer to the configured route.

Tested Services

  • PayPal
  • Stripe

License

This package is free software distributed under the terms of the MIT license., (*15)

Additional Information

This package uses Omnipay., (*16)

The Versions

05/11 2015

1.0.x-dev

1.0.9999999.9999999-dev

Omnipay gateway for Laravel Shop package.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel gateway omnipay 2checkout stripe authorize.net paypal laravel shop laravel-shop

05/11 2015

v1.0.2

1.0.2.0

Omnipay gateway for Laravel Shop package.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel gateway omnipay 2checkout stripe authorize.net paypal laravel shop laravel-shop

13/10 2015

dev-master

9999999-dev

Omnipay gateway for Laravel Shop package.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel gateway omnipay 2checkout stripe authorize.net paypal laravel shop laravel-shop

13/10 2015

v0.0.9

0.0.9.0

Omnipay gateway for Laravel Shop package.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel gateway omnipay 2checkout stripe authorize.net paypal laravel shop laravel-shop

13/10 2015

v1.0.1

1.0.1.0

Omnipay gateway for Laravel Shop package.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel gateway omnipay 2checkout stripe authorize.net paypal laravel shop laravel-shop

13/10 2015

v1.0.0

1.0.0.0

Omnipay gateway for Laravel Shop package.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel gateway omnipay 2checkout stripe authorize.net paypal laravel shop laravel-shop