josan-br / laravel-galax-pay
Make requests to the Galax Pay API
Requires
- php: ^8.0.2
- guzzlehttp/guzzle: *
- illuminate/console: *
- illuminate/database: *
- illuminate/support: *
Requires (Dev)
- nunomaduro/collision: ^7.6
- orchestra/testbench: ^8.5
- phpunit/phpunit: ^10.2
This package is auto-updated.
Last update: 2024-10-23 18:11:47 UTC
README
A Galax Pay API wrapper for Laravel
Installation
Step 1. Add Laravel Galax Pay to your project:
composer require josan-br/laravel-galax-pay
Step 2. Register GalaxPayServiceProvider
:
-
In Laravel:
'providers' => [ // ... \JosanBr\GalaxPay\Providers\GalaxPayServiceProvider::class, ];
-
In Lumen, go to the
bootstrap/app.php
file and in the providers section add:$app->register(\JosanBr\GalaxPay\Providers\GalaxPayServiceProvider::class);
Step 3. Publish files:
php artisan galax-pay:publish
This command allows publishing the settings and migrations, before publishing the migrations publish the settings.
The command doesn't publish both at once because you might want to use other tables than the ones the package provides.
In this case, just go to config/galax_pay.php
and define the models you want to use and the referring columns.
// ... 'galax_pay_clients' => [ 'ref' => \JosanBr\GalaxPay\Models\GalaxPayClient::class, // Columns 'model_type' => 'model_type', 'model_id' => 'model_id', 'galax_id' => 'galax_id', 'galax_hash' => 'galax_hash', 'webhook_hash' => 'webhook_hash', ], 'galax_pay_sessions' => [ 'ref' => \JosanBr\GalaxPay\Models\GalaxPaySession::class, // Columns 'scope' => 'scope', 'expires_in' => 'expires_in', 'token_type' => 'token_type', 'access_token' => 'access_token', 'client_id' => 'galax_pay_client_id', ]
Step 4. add environment variables:
php artisan galax-pay:publish
and choose: environment variables
What will be published?:
[0] config
[1] environment variables
[2] migrations
> environment variables
Usage
Use the Galax Pay facades class
use JosanBr\GalaxPay\Facades\GalaxPay;
If using standard authentication, auth_as_partner = false
, just call an endpoint as static function:
$data = GalaxPay::listCustomers();
If you use auth_as_partner = true
partner authentication, you must pass the client's galax_id as an argument:
$data = GalaxPay::listCustomers([], ['client_galax_id' => $clientGalaxId]);
You can see the available endpoints here.
All endpoints receive a single array type function parameter, in the following format:
/** * GET example * * @var array|\JosanBr\GalaxPay\QueryParams $queryParams * @var array|\JosanBr\GalaxPay\Http\Options $options */ $res = GalaxPay::listCustomers($queryParams, $options); /** * POST example * * @var array|\JosanBr\GalaxPay\Abstracts\Model $data * @var array|\JosanBr\GalaxPay\Http\Options $options */ $res = GalaxPay::createCustomer($data, $options); /** * PUT example * * @var int|string $id * @var array|\JosanBr\GalaxPay\Abstracts\Model $data * @var array|\JosanBr\GalaxPay\Http\Options $options */ $res = GalaxPay::editCustomer($id, $data, $options); /** * DELETE example * * @var int|string $id * @var array|\JosanBr\GalaxPay\Http\Options $options */ $res = GalaxPay::deleteCustomer($id, $options);
The QueryParams class has only the common parameters between the data fetching endpoints, to see all the parameters that each endpoint accepts, consult the Galax Pay documentation.