Looking to hire Laravel developers? Try LaraJobs

laravel-pagopar maintained by krugerdavid

Description
Laravel integration for Pagopar payment gateway
Author
Last update
2026/01/19 22:09 (dev-main)
License
Links
Downloads
2

Comments
comments powered by Disqus

Laravel Pagopar

Latest Version on Packagist GitHub Tests Action Status Total Downloads License

Laravel integration for Pagopar payment gateway.

Installation

You can install the package via composer:

composer require krugerdavid/laravel-pagopar

The service provider will automatically register itself.

You can publish the config file with:

php artisan vendor:publish --tag="pagopar-config"

Configuration

Add these variables to your .env file:

PAGOPAR_PUBLIC_KEY=your_public_token
PAGOPAR_PRIVATE_KEY=your_private_token

Usage

Creating a Payment

use KrugerDavid\Pagopar\Facades\Pagopar;
use KrugerDavid\Pagopar\DTOs\PagoparBuyer;
use KrugerDavid\Pagopar\DTOs\PagoparItem;
use KrugerDavid\Pagopar\DTOs\PagoparPaymentRequest;

$buyer = new PagoparBuyer(
    name: 'Juan Perez',
    email: 'juan@example.com',
    document: '1234567',
    phone: '+595981123456'
);

$items = [
    new PagoparItem(
        name: 'Producto de Prueba',
        price: 10000,
        quantity: 1
    )
];

$request = new PagoparPaymentRequest(
    orderId: 'ORDER-123',
    buyer: $buyer,
    items: $items,
    maxPaymentDate: now()->addDays(2)->format('Y-m-d H:i:s'),
    description: 'Descripción del pedido'
);

$response = Pagopar::createPayment($request);

if ($response['hash']) {
    $checkoutUrl = Pagopar::getCheckoutUrl($response['hash']);
    return redirect($checkoutUrl);
}

Checking Order Status

$status = Pagopar::getOrderStatus($hash);

if (!empty($status) && $status[0]['pagado']) {
    // El pedido ha sido pagado
}

Verifying Webhook Token

public function handleWebhook(Request $request)
{
    $hash = $request->input('resultado.0.hash_pedido');
    $token = $request->input('resultado.0.token');

    if (Pagopar::verifyWebhookToken($hash, $token)) {
        // Token válido, procesar el pago
    }
}

Security

If you discover any security related issues, please email david.kruger@duplaa.com instead of using the issue tracker.

License

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