Skip to content

About

A laravel wrapper for Paymongo API

Topics

Resources

Code of conduct

Contributing

Stars

81 stars

Watchers

12 watching

Forks

Repository files navigation

Paymongo for Laravel

Run tests Quality Score Latest Stable Version Total Downloads Monthly Downloads Daily Downloads License

A Laravel client for the PayMongo API. Typed responses, first-class webhooks, built-in testing fakes.

This package is not affiliated with PayMongo.

Requirements

  • PHP 8.2 or newer (Laravel 13 itself requires PHP 8.3+)
  • Laravel 11, 12, or 13

Installation

composer require luigel/laravel-paymongo:^3.0

Add your keys to .env (grab them from the PayMongo dashboard):

PAYMONGO_SECRET_KEY=sk_test_...
PAYMONGO_PUBLIC_KEY=pk_test_...
# The endpoint secret_key returned when you register a webhook.
PAYMONGO_WEBHOOK_SECRET=whsk_...

Optionally publish the config file to config/paymongo.php:

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

Example

use Luigel\Paymongo\Enums\PaymentIntentStatus;
use Luigel\Paymongo\Facades\Paymongo;

// 1. Create the intent. Amounts are integer centavos: 150050 = PHP 1,500.50.
$intent = Paymongo::paymentIntents()->create([
    'amount' => 150050,
    'currency' => 'PHP',
    'payment_method_allowed' => ['card'],
    'description' => 'Order #1234',
]);

// 2. Create a payment method (normally done client-side with your public key).
$method = Paymongo::paymentMethods()->create([
    'type' => 'card',
    'details' => [
        'card_number' => '4343434343434345',
        'exp_month' => 12,
        'exp_year' => 34,
        'cvc' => '123',
    ],
]);

// 3. Attach it to the intent to trigger the payment.
$intent = Paymongo::paymentIntents()->attach($intent->id, $method->id);

if ($intent->status === PaymentIntentStatus::Succeeded) {
    // Paid. $intent->payments holds the resulting Payment resources.
}

Documentation

Guides for every flow (Checkout Sessions, Payment Intents, Payment Links, QR Ph, refunds, subscriptions), webhooks, testing with Paymongo::fake(), and the full reference live at https://paymongo.rigelkentcarbonel.com/docs.

License

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

About

A laravel wrapper for Paymongo API

Topics

Resources

Code of conduct

Contributing

Stars

81 stars

Watchers

12 watching

Forks

Releases

Packages

Used by

Contributors

Languages