Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

payment

> 后端框架
Open source

simple laravel payment package , supports multiple drivers

948 stars0 likes1 views
WebsiteGitHub

About

simple laravel payment package , supports multiple drivers

Laravel Payment Gateway

![Software License][ico-license] [![Latest Version on Packagist][ico-version]][link-packagist] [![Total Downloads on Packagist][ico-download]][link-packagist] [![Tests][ico-tests]][link-tests] [![Code Style][ico-code-style]][link-code-style] [![Static Analysis][ico-static-analysis]][link-static-analysis] [![Code Coverage][ico-coverage]][link-coverage]

This is a Laravel Package for Payment Gateway Integration. This package requires PHP 8.4+ and supports Laravel 12+.

Donate me if you like this package :sunglasses: :bowtie:

For PHP integration you can use shetabit/multipay package.

This packages works with multiple drivers, and you can create custom drivers if you can't find them in the current drivers list (below list).

  • [داکیومنت فارسی][link-fa]
  • [English documents][link-en]
  • [中文文档][link-zh]

List of contents

  • Laravel Payment Gateway
  • List of contents
  • List of available drivers
    • Install
    • Configure
    • How to use
      • Working with invoices
      • Purchase invoice
      • Pay invoice
      • Verify payment
      • Useful methods
      • Create custom drivers:
      • Events
    • Testing
    • Change log
    • Contributing
    • Security
    • Credits
    • License

List of available drivers

  • aqayepardakht :heavy_check_mark:

  • asanpardakht :heavy_check_mark:

  • atipay :heavy_check_mark:

  • azkiVam (Installment payment) :heavy_check_mark:

  • behpardakht (mellat) :heavy_check_mark:

  • bitpay :heavy_check_mark:

  • daracard :heavy_check_mark:

  • digipay :heavy_check_mark:

  • etebarino (Installment payment) :heavy_check_mark:

  • fanavacard :heavy_check_mark:

  • gooyapay :heavy_check_mark:

  • irandargah :heavy_check_mark:

  • irankish :heavy_check_mark:

  • jibit :heavy_check_mark:

  • local :heavy_check_mark:

  • minipay :heavy_check_mark:

  • nextpay :heavy_check_mark:

  • novinopay :heavy_check_mark:

  • omidpay :heavy_check_mark:

  • panapal :heavy_check_mark:

  • parsian :heavy_check_mark:

  • parspal :heavy_check_mark:

  • pasargad :heavy_check_mark:

  • payfa :heavy_check_mark:

  • paypal (will be added soon in next version)

  • payping :heavy_check_mark:

  • paystar :heavy_check_mark:

  • pna :heavy_check_mark:

  • poolam :heavy_check_mark:

  • rayanpay :heavy_check_mark:

  • refah :heavy_check_mark:

  • sadad (melli) :heavy_check_mark:

  • saman :heavy_check_mark:

  • sep (saman electronic payment) Keshavarzi & Saderat :heavy_check_mark:

  • sepehr (saderat) :heavy_check_mark:

  • sepordeh :heavy_check_mark:

  • shepa :heavy_check_mark:

  • sizpay :heavy_check_mark:

  • snapppay :heavy_check_mark:

  • stripe :heavy_check_mark:

  • toman :heavy_check_mark:

  • torobpay (Installment payment) :heavy_check_mark:

  • vandar :heavy_check_mark:

  • xendit :heavy_check_mark:

  • yekpay :heavy_check_mark:

  • zarinpal :heavy_check_mark:

  • zibal :heavy_check_mark:

  • Others are under way.

Help me to add the gateways below by creating pull requests

  • stripe
  • authorize
  • 2checkout
  • braintree
  • skrill
  • payU
  • amazon payments
  • wepay
  • payoneer
  • paysimple

you can create your own custom drivers if it does not exist in the list, read the Create custom drivers section.

Install

Via Composer

bash
composer require shetabit/payment

Publish Vendor Files

  • publish configuration files:
bash
php artisan vendor:publish --tag=payment-config
  • publish views for customization:
bash
php artisan vendor:publish --tag=payment-views

Configure

The service provider and the Payment alias are registered by Laravel's package discovery, so there is nothing to add to config/app.php (or to bootstrap/providers.php).

In the config file you can set the default driver to use for all your payments. But you can also change the driver at runtime.

Choose what gateway you would like to use in your application. Then make that as default driver so that you don't have to specify that everywhere. But, you can also use multiple gateways in a project.

php
// Eg. if you want to use zarinpal.
'default' => 'zarinpal',

Then fill the credentials for that gateway in the drivers array.

php
'drivers' => [
    'zarinpal' => [
        // Fill in the credentials here.
        'apiPurchaseUrl' => 'https://www.zarinpal.com/pg/rest/WebGate/PaymentRequest.json',
        'apiPaymentUrl' => 'https://www.zarinpal.com/pg/StartPay/',
        'apiVerificationUrl' => 'https://www.zarinpal.com/pg/rest/WebGate/PaymentVerification.json',
        'merchantId' => '',
        'callbackUrl' => 'http://yoursite.com/path/to',
        'description' => 'payment in '.config('app.name'),
    ],
    ...
]

How to use

your Invoice holds your payment details, so initially we'll talk about Invoice class.

Working with invoices

before doing any thing you need to use Invoice class to create an invoice.

In your code, use it like the below:

php
// At the top of the file.
use Shetabit\Multipay\Invoice;
...

// Create new invoice.
$invoice = new Invoice;

// Set invoice amount.
$invoice->amount(1000);

// Add invoice details: There are 4 syntax available for this.
// 1
$invoice->detail(['detailName' => 'your detail goes here']);
// 2 
$invoice->detail('detailName','your detail goes here');
// 3
$invoice->detail(['name1' => 'detail1','name2' => 'detail2']);
// 4
$invoice->detail('detailName1','your detail1 goes here')
        ->detail('detailName2','your detail2 goes here');

available methods:

  • uuid: set the invoice unique id
  • getUuid: retrieve the invoice current unique id
  • detail: attach some custom details into invoice
  • getDetails: retrieve all custom details
  • amount: set the invoice amount
  • getAmount: retrieve invoice amount
  • transactionId: set invoice payment transaction id
  • getTransactionId: retrieve payment transaction id
  • via: set a driver we use to pay the invoice
  • getDriver: retrieve the driver

Purchase invoice

In order to pay the invoice, we need the payment transactionId. We purchase the invoice to retrieve transaction id:

…

Pay invoice

After purchasing the invoice, we can redirect the user to the bank payment page:

…

Verify payment

When user has completed the payment, the bank redirects them to your website, then you need to verify your payment in order to ensure the invoice has been paid.

…

Useful methods

  • callbackUrl: can be used to change callbackUrl on the runtime.
    php
    // At the top of the file.
    use Shetabit\Multipay\Invoice;
    use Shetabit\Payment\Facade\Payment;
    ...
    
    // Create new invoice.
    $invoice = (new Invoice)->amount(1000);
    
    // Purchase the given invoice.
    Payment::callbackUrl($url)->purchase(
        $invoice, 
        function($driver, $transactionId) {
        // We can store $transactionId in database.
        }
    );
  • amount: you can set the invoice amount directly
    php
    // At the top of the file.
    use Shetabit\Multipay\Invoice;
    use Shetabit\Payment\Facade\Payment;
    ...
    
    // Purchase (we set invoice to null).
    Payment::callbackUrl($url)->amount(1000)->purchase(
        null, 
        function($driver, $transactionId) {
        // We can store $transactionId in database.
        }
    );
  • via: change driver on the fly
    php
    // At the top of the file.
    use Shetabit\Multipay\Invoice;
    use Shetabit\Payment\Facade\Payment;
    ...
    
    // Create new invoice.
    $invoice = (new Invoice)->amount(1000);
    
    // Purchase the given invoice.
    Payment::via('driverName')->purchase(
        $invoice, 
        function($driver, $transactionId) {
        // We can store $transactionId in database.
        }
    );
  • config: set driver configs on the fly
…

Create custom drivers:

First you have to add the name of your driver, in the drivers array and also you can specify any config parameters you want.

php
'drivers' => [
    'zarinpal' => [...],
    'my_driver' => [
        ... // Your Config Params here.
    ]
]

Now you have to create a Driver Map Class that will be used to pay invoices. In your driver, You just have to extend Shetabit\Payment\Abstracts\Driver.

Eg. You created a class: App\Packages\PaymentDriver\MyDriver.

…

Once you create that class you have to specify it in the payment.php config file map section.

php
'map' => [
    ...
    'my_driver' => App\Packages\PaymentDriver\MyDriver::class,
]

Note:- You have to make sure that the key of the map array is identical to the key of the drivers array.

Events

You can listen for 2 events

  • InvoicePurchasedEvent: Occurs when an invoice is purchased (after purchasing invoice is done successfully).
  • InvoiceVerifiedEvent: Occurs when an invoice is verified successfully.

Both events expose the driver and the invoice they were dispatched for as readonly properties, and the verification event exposes the receipt as well:

php
public function handle(InvoiceVerifiedEvent $event): void
{
    $event->receipt->getReferenceId();
    $event->invoice->getTransactionId();
    $event->driver->getInvoice();
}

Testing

Every pull request and every push to master is checked by [GitHub Actions][link-actions]: the test suite runs on PHP 8.4 and 8.5, against Laravel 12 and 13 and against both the lowest and the highest supported dependencies, the coding style is checked with PHP_CodeSniffer, the sources are analysed with PHPStan and the code coverage of the test suite is measured and has to stay above 95%.

You can run the same checks locally. With PHP and Composer installed on your machine:

bash
composer install

composer test           # run the test suite
composer test-coverage  # run the test suite and report code coverage
composer check-style    # check the coding style
composer fix-style      # fix the coding style where possible
composer analyse        # run static analysis
composer ci             # run all of the checks above

If you would rather not install PHP on your machine, the shipped Dockerfile and Makefile run everything inside a container:

bash
make test              # run the test suite
make coverage          # run the test suite and report code coverage
make check-style       # check the coding style
make fix-style         # fix the coding style where possible
make analyse           # run static analysis
make ci                # run all of the checks above
make s

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHPlaravel-paymentlaravel-payment-gatepaymentpayment-gateway

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category后端框架
PricingOpen source

> Related tools

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架