2017 © Pedro Peláez
 

library laravel-gopay-sdk

GoPay SDK integration with Laravel Framework

image

hazestudio/laravel-gopay-sdk

GoPay SDK integration with Laravel Framework

  • Wednesday, August 9, 2017
  • by DamianImrich
  • Repository
  • 2 Watchers
  • 4 Stars
  • 946 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 7 Versions
  • 3 % Grown

The README.md

Laravel GoPay SDK

Build Status Scrutinizer Latest Stable Version Total Downloads Packagist, (*1)

Docs

Installation

Step 1: Install package

Add the package in your composer.json by executing the command., (*2)

composer require hazestudio/laravel-gopay-sdk

This will both update composer.json and install the package into the vendor/ directory., (*3)

Next, add the service provider and facade to config/app.php, (*4)

Add the service provider to providers:, (*5)

'providers' => [
    ...
    HazeStudio\LaravelGoPaySDK\GopayServiceProvider::class,
    ...
]

And add the facade to aliases:, (*6)

'aliases' => [
    ...
    'GoPay' => HazeStudio\LaravelGoPaySDK\Facade::class,
    ...
]

Step 2: Configuration

First initialise the config file by running this command:, (*7)

php artisan vendor:publish

With this command, initialize the configuration and modify the created file, located under config/gopay.php., (*8)

Configuration

return [
    'goid' => 'YOUR_GOID',
    'clientId' => 'YOUR_CLIENT_ID',
    'clientSecret' => 'YOUR_CLIENT_SECRET',
    'defaultScope' => 'ALL', //GoPay\Definition\TokenScope Constants
    'languages' => [
        'en' => 'ENGLISH',
        'sk' => 'SLOVAK',
        'cs' => 'CZECH'
    ], //Map Laravel languages to GoPay\Definition\Language Constants
    'timeout' => 30
];

Features

Languages

\GoPay::lang(GoPay\Definition\Languages::SLOVAK)
//or just
\GoPay::lang('sk')
//or
\GoPay::lang('SLOVAK')->createPayment(...);

Scopes

\GoPay::scope(GoPay\Definition\TokenScope::ALL) //Override default scope
//or
\GoPay::scope('ALL')->createPayment(...);

Events

Name Class
PaymentCreated HazeStudio\LaravelGoPaySDK\Events\PaymentCreated

Example:, (*9)

Event::listen(\HazeStudio\LaravelGoPaySDK\Events\PaymentCreated::class, function ($event) {
    dd($event->payment);
});

Examples

Create standard payment

use GoPay;
use GoPay\Definition\Payment\Currency;
use GoPay\Definition\Payment\PaymentInstrument;
use GoPay\Definition\Payment\BankSwiftCode;

//This will log every http request to the GoPay api
GoPay::log(function($request, $response){
    \PC::gp_request($request); //PHP Console package
    \PC::gp_response($response); //PHP Console package
    //Or Laravel Log
    \Log::info("{$request->method} {$request->url} -> {$response->statusCode}");
});

$user = \Auth::user();
$response = GoPay::lang($user->locale)->scope('CREATE_PAYMENT')->createPayment([
    'payer' => [
        'default_payment_instrument' => PaymentInstrument::BANK_ACCOUNT,
        'allowed_payment_instruments' => [PaymentInstrument::BANK_ACCOUNT],
        'default_swift' => BankSwiftCode::FIO_BANKA,
        'allowed_swifts' => [BankSwiftCode::FIO_BANKA, BankSwiftCode::MBANK],
        'contact' => [
            'first_name' => 'Zbynek',
            'last_name' => 'Zak',
            'email' => 'test@test.cz',
            'phone_number' => '+420777456123',
            'city' => 'C.Budejovice',
            'street' => 'Plana 67',
            'postal_code' => '373 01',
            'country_code' => 'CZE',
        ],
    ],
    'amount' => 1000,
    'currency' => Currency::CZECH_CROWNS,
    'order_number' => '001',
    'order_description' => 'pojisteni01',
    'items' => [
        ['name' => 'item01', 'amount' => 50],
        ['name' => 'item02', 'amount' => 100],
    ],
    'additional_params' => [
        array('name' => 'invoicenumber', 'value' => '2015001003')
    ],
    'callback' => [
        'return_url' => 'http://www.your-url.tld/return',
        'notification_url' => 'http://www.your-url.tld/notify'
    ]
]);

if ($response->hasSucceed()) {
    $url = $response->json['gw_url'];
    echo $response;
}

The Versions

09/08 2017

dev-master

9999999-dev

GoPay SDK integration with Laravel Framework

  Sources   Download

MIT

The Requires

 

by Haze Studio

09/08 2017

v0.1.5

0.1.5.0

GoPay SDK integration with Laravel Framework

  Sources   Download

MIT

The Requires

 

by Haze Studio

07/03 2017

v0.1.4

0.1.4.0

GoPay SDK integration with Laravel Framework

  Sources   Download

MIT

The Requires

 

by Haze Studio

23/11 2016

v0.1.3

0.1.3.0

GoPay SDK integration with Laravel Framework

  Sources   Download

MIT

The Requires

 

by Haze Studio

23/11 2016

v0.1.2

0.1.2.0

GoPay SDK integration with Laravel Framework

  Sources   Download

MIT

The Requires

 

by Haze Studio

23/11 2016

v0.1.1

0.1.1.0

GoPay SDK integration with Laravel Framework

  Sources   Download

MIT

The Requires

 

by Haze Studio

22/11 2016

v0.1

0.1.0.0

GoPay SDK integration with Laravel Framework

  Sources   Download

MIT

The Requires

 

by Haze Studio