overtrue/laravel-payment

Omnipay ServiceProvider for Laravel.
4,173 91
Install
composer require overtrue/laravel-payment
Latest Version:4.0.0
PHP:^8.3
Laravel:13
Older releases:5 – 8
License:MIT
Last Updated:Oct 10, 2026
Links: GitHub  ·  Packagist
Maintainer: overtrue

Laravel Payment

:credit_card: Omnipay ServiceProvider for Laravel.

Tests Latest Stable Version Total Downloads License composer.lock

Requirements

Version 4 requires PHP 8.3+ and Laravel 13.30+ (within Laravel 13). Laravel 12 and earlier are not supported by this major version.

Installing

composer require overtrue/laravel-payment:^4.0

The service provider and LaravelPayment facade alias are automatically discovered.

Publish the configuration before using the package:

php artisan vendor:publish --provider="Overtrue\LaravelPayment\ServiceProvider" --tag=config

configuration

// config/payments.php

    // The default gateway name which configured in `gateways` section.
    'default_gateway' => 'paypal',

    // The default options for every gateways.
    'default_options' => [
        'test_mode' => true,
        // ...
    ],

    /*
     * The gateways, you can config option by camel case or snake_case name.
     *
     * the option name is followed from gateway class, for example:
     *
     * $gateway->setMchId('overtrue');
     *
     * you can configured as:
     *  'mch_id' => 'overtrue',
     * or:
     *  'mchId' => 'overtrue',
     */
    'gateways' => [
        'paypal' => [
            'driver' => 'PayPal_Express',
            'options' => [
                'username' => env('PAYPAL_USERNAME'),
                'password' => env('PAYPAL_PASSWORD'),
                'signature' => env('PAYPAL_SIGNATURE'),
                'test_mode' => env('PAYPAL_TEST_MODE'),
            ],
        ],
        // other gateways
    ],

install payment gateways

You need to install the gateway you want to use: omnipay#payment-gateways

Usage

Gateway instance:

LaravelPayment::gateway('GATEWAY NAME'); // GATEWAY NAME is key name of `gateways` configuration.
LaravelPayment::gateway('alipay');
LaravelPayment::gateway('paypal');

Using default gateway:

LaravelPayment::purchase(...);

Example:

$formData = [
    'number' => '4242424242424242', 
    'expiryMonth' => '6', 
    'expiryYear' => '2030', 
    'cvv' => '123'
];

$response = LaravelPayment::purchase([
    'amount' => '10.00', 
    'currency' => 'USD', 
    'card' => $formData,
])->send();

if ($response->isRedirect()) {
    // redirect to offsite payment gateway
    $response->redirect();
} elseif ($response->isSuccessful()) {
    // payment was successful: update database
    print_r($response);
} else {
    // payment failed: display message to customer
    echo $response->getMessage();
}

For more use about Omnipay, please refer to Omnipay Official Home Page

Upgrading from 3.x

  • Upgrade your application to PHP 8.3+ and Laravel 13.30+ before installing 4.x.
  • The package now uses the Guzzle 7 adapter 1.1+ and Omnipay Common 3.5.1+. Check that your separately installed Omnipay gateways support these versions.
  • Existing gateway names, the payment container alias, facade, default-option precedence, and per-manager gateway caching are unchanged.
  • Array option values are still expanded into setter arguments. For a setter expecting a single array, wrap it in an outer array, for example 'settings' => [['key' => 'value']]. Use positional lists for multi-argument setters.
  • Unknown option setters are ignored as before. Publish and configure config/payments.php; publishing does not install a gateway driver.

Development

composer update
composer validate --strict
composer audit --locked
composer lint
composer test

Tests use an in-process dummy gateway and never send payments or require credentials. CI runs latest dependencies on PHP 8.3, 8.4 and 8.5, plus lowest secure dependencies on PHP 8.3. Upgrade dependencies on newer PHP versions; older transitive versions can emit upstream deprecations on PHP 8.4+. Use current Composer 2.10+ for the abandoned-package blocking policy. No security advisories are bypassed, and abandoned packages are blocked during resolution. The Laravel 13.30 floor excludes earlier vulnerable Laravel 13 releases (GHSA-jh5r-qr3c-85q8).

License

MIT

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

644,549,754 9,698
laravel/framework

The Laravel Framework.

593,882,149 34,959
laravel/tinker

Powerful REPL for the Laravel framework.

507,193,856 7,441
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

423,477,751 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

399,241,428 4,660

Version History

Version Released PHP Laravel License
4.0.0 ^8.3 ^13.30 MIT
3.0.0 >=7.0 ~5.0||~6.0||~7.0 || ^8.0 MIT
2.0.0 >=7.0 ~5.0||~6.0||~7.0 || ^8.0 MIT
1.0.7 >=7.0 ~5.0||~6.0||~7.0 MIT
1.0.5 >=7.0 ~5.0||~6.0 MIT