Skip to content

Laravel AbacatePayPayments that feel like Laravel

A typed, expressive SDK for AbacatePay v2. Less boilerplate, more Laravel — with full v2 API coverage.

Why use it?

Compare the same flow without and with the package.

Transparent PIX

php
use Illuminate\Support\Facades\Http;

$response = Http::withToken(config('abacatepay.api_key'))
    ->post('https://api.abacatepay.com/v2/transparents/create', [
        'method' => 'PIX',
        'data' => [
            'amount' => 10000,
            'description' => 'Order #123',
            'expires_in' => 3600,
            'metadata' => ['order_id' => 'ORDER-123'],
        ],
    ]);

if ($response->failed()) {
    throw new RuntimeException($response->json('error.message') ?? 'AbacatePay error');
}

$brCode = $response->json('data.brCode');
php
use Cavalheri\LaravelAbacatePay\Facades\AbacatePay;

$charge = AbacatePay::transparentCheckouts()->pix(10000, [
    'description' => 'Order #123',
    'metadata' => ['order_id' => 'ORDER-123'],
]);

$brCode = $charge->brCode;

Webhook + HMAC verification

php
use Illuminate\Support\Facades\Http;

Http::withToken(config('abacatepay.api_key'))
    ->post('https://api.abacatepay.com/v2/webhooks/create', [
        'name' => 'Payments',
        'endpoint' => route('webhooks.abacatepay'),
        'secret' => config('abacatepay.webhook_secret'),
        'events' => ['checkout.completed', 'checkout.expired'],
    ]);

$secret = $request->query('webhookSecret');
$signature = $request->header('X-Webhook-Signature');
$expected = hash_hmac('sha256', $request->getContent(), $secret);

if (! hash_equals($expected, (string) $signature)) {
    abort(401);
}
php
use Cavalheri\LaravelAbacatePay\Facades\AbacatePay;

AbacatePay::webhooks()
    ->checkoutEvents()
    ->at(route('webhooks.abacatepay'))
    ->named('Payments')
    ->create();

$isValid = AbacatePay::webhooks()->verify(
    rawBody: $request->getContent(),
    signature: $request->header('X-Webhook-Signature'),
    secret: $request->query('webhookSecret'),
);

See all comparisons →

Requirements

RequirementVersion
PHP8.3+
Laravel13.x
AbacatePay APIv2

Install in seconds

bash
composer require cavalheri/laravel-abacatepay
php artisan vendor:publish --tag=abacatepay-config

Then set ABACATEPAY_API_KEY in your .env and you're ready.

Read the full guide →

Maintainer

Open source created and maintained by Lucas Cavalheri.

Learn more about the creator: Portfolio · GitHub · LinkedIn