arielmejiadev/pagalogt

PagaloGT payment processing library that provides a fluent syntax, testing methods and has Cybersource implementation.

5.0.0 2021-02-22 00:34 UTC

This package is auto-updated.

Last update: 2024-04-23 09:47:48 UTC


README

Latest Version on Packagist Total Downloads

It provides a fluent syntax to make payments in Laravel with PagaloGT payment gateway.

To learn more about the package here the documentation site

Installation

You can install the package via composer:

composer require arielmejiadev/pagalogt

Publish config file

Its not necessary but you can publish the config file:

php artisan vendor:publish --tag=pagalogt-config

Usage

  • 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();

Validate response

In Laravel 5.5 to Laravel 6.x

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
    }

In Laravel 7 and 8

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();

Support Cybersource:

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:

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email arielmejiadev@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.