It provides a fluent syntax to make payments in Laravel with PagaloGT payment gateway.
To learn more about the package here the documentation site
You can install the package via composer:
composer require arielmejiadev/pagalogt
Its not necessary but you can publish the config file:
php artisan vendor:publish --tag=pagalogt-config
- Add your PagaloGT credentials on the app
.env
file:
You can get the credentials Here, you need to create an account and follow some steps with PagaloGT.
PAGALO_TEST_IDEN_EMPRESA='{TestPagaloIdenEmpresa}'
PAGALO_TEST_TOKEN='{TestPagaloToken}'
PAGALO_TEST_KEY_PUBLIC='{TestPagaloKeyPublic}'
PAGALO_TEST_KEY_SECRET='{TestPagaloKeySecret}'
PAGALO_ENVIRONMENT='test'
- For development and testing (to avoid real transactions):
$payment = new PagaloGT();
return $payment->add(1, 'Test transaction', 100.00)
->setClient('John', 'Doe', 'john@doe.com')
->withTestCard('John Doe')
->withTestCredentials()
->pay();
- Using the Facade
return PagaloGT::add(1, 'Test transaction', 100.00)
->setClient('John', 'Doe', 'john@doe.com')
->withTestCard('John Doe')
->withTestCredentials()
->pay();
- On production
PAGALO_IDEN_EMPRESA='{LivePagaloIdenEmpresa}'
PAGALO_TOKEN='{LivePagaloToken}'
PAGALO_KEY_PUBLIC='{LivePagaloKeyPublic}'
PAGALO_KEY_SECRET='{LivePagaloKeySecret}'
PAGALO_ENVIRONMENT='live'
return PagaloGT->add(1, 'Test transaction', 100.00)
->setClient('John', 'Doe', 'john@doe.com')
->setCard('JOHN JOSEPH DOE DULLIE', 'XXXX XXXX XXXX XXXX', 12, 2022, 742)
->pay();
The package provide constants to validate response you can do something like:
$response['decision'] === 'ACCEPT';
$response['reasonCode'] === 100;
To avoid magic numbers you can do something like this:
use \ArielMejiaDev\PagaloGT\PagaloGT;
// ...
$response = PagaloGT::add(1, 'Test transaction from Laravel 5.5', 100.00)
->setClient('John', 'Doe', 'john@doe.com')
->withTestCard('John Doe')
->withTestCredentials()
->pay();
if($response['decision'] === PagaloGT::APPROVE_DECISION &&
$response['reasonCode'] === PagaloGT::APPROVE_REASON_CODE ) {
// do something
}
You can use the old validation way (since Laravel 5.5 - 6.x)
In laravel 7 and 8 the library change response, so you can validate like this:
$response = PagaloGT::add(1, 'product', 100.00)->withTestCard()->withTestCredentials()->pay();
if($response->successful()) {
// do something
}
Other methods to validate:
$response->fail();
$response->successful();
$response->ok()
$response->header('single header');
$response->headers();
The library is ready to support cybersource transactions, it only needs to add a config variable:
PAGALO_USE_CYBERSOURCE=true
You need to add a script to generate the deviceFingerPrint
on your checkout form.
In the docs you can get scripts ready to use for:
- Blade file: Cybersource Script for blade files
- VueJS file: (pending)
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email arielmejiadev@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.