dann95 / g2a-sdk
G2A SDK
Requires
- guzzlehttp/guzzle: ^6.3
- ocramius/generated-hydrator: ^2.2
Requires (Dev)
- phpunit/phpunit: ^6.4
This package is auto-updated.
Last update: 2024-10-20 03:46:49 UTC
README
This SDK is an unofficial software with no warranties by G2A PAY ®, you can check more about G2A in: https://www.g2a.com/
Contents
- Requirements
- Installation
- Available resources
- Getting started
- Laravel integration
- Project goals/todo
- Contribute
Requirements
- PHP 7.0 and later.
- Guzzle 6
Composer
You can install the sdk via Composer. Run the following command:
composer require dann95/g2a-sdk
To use the bindings, use Composer's autoload:
require_once('vendor/autoload.php');
Available resources
Due some API limitations from G2A, this SDK is restricted to few operations, see the table below to know what this SDK can do. API means that this is available on this SDK
EMAIL means that is only available by e-mail contact
DASHBOARD means that is only available in merchant dashboard
Payments
Subscriptions
Getting Started
Normal Integration
Setting up credentials be like:
$hash = '485d733d-7937-414a-8d42-6781397b1c0a'; $mail = 'merchant@my-test-store.com'; $secret = 'pSO_-N%GZDGfpLu!a5qOUnA>T7QqOro?4?z~Lt5u@LKgg>X247PYvZX8gwy~YY=c'; $env = 'SANDBOX'; $sdk = new \G2A\Sdk( $hash, $mail, $secret, $env );
Laravel integration (optional integration)
Insert the provider into providers array in config/app.php
'providers' => [ // previous providers \G2A\Integrations\Laravel\G2aServiceProvider::class, // next providers ]
Then run the following command:
php artisan vendor:publish --tag=g2a
Edit the file configs/g2a.php, you will have something like this
prefer use env() helper instead of strings to save your credentials
<?php /** * to obtain hash and secret, go to: * https://www.test.pay.g2a.com/setting/merchant (in case of SANDBOX) * https://www.pay.g2a.com/setting/merchant (in case of PRODUCTION) * email is your account e-mail. */ return [ 'hash' => '', 'secret' => '', 'email' => '', 'environment' => 'SANDBOX', // SANDBOX || PRODUCTION ];
Now when you do, it will give you a fresh instance of SDK using settings on config/g2a.php:
$sdk = app('G2A');
Or, when inside a Controller/any part of Laravel where Auto Dependency Injection is available:
class FooBarController extends Controller { public function checkout(\G2A\Sdk $sdk) { dd($sdk); } }
Goals/Todo
- 100% Unit coverage
- Use abstraction of HttpClient instead of Guzzle
- Do a Legacy version, for php 5.4+
- Full error detailed Exceptions and Entities
- Release first stable version (1.0.0)
Contribute
Feel free to contribute to this repository.