Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AnyPay

AnyPay is a PHP and Laravel library that puts more than 40 payment gateways behind one unified API, for developers who need to support several providers without writing a separate integration for each.

Overview

Instead of learning a different SDK for every bank or PSP, you write the checkout flow once and switch providers by changing a driver name. Every gateway follows the same purchase → pay → verify sequence.

The package bundles drivers for the major Iranian bank and PSP gateways (Mellat, Melli/Sadad, Saman, Parsian, Pasargad, Saderat, Zarinpal, IDPay, Zibal and others), wallet and installment (BNPL) providers (Azki, Etebarino, Walleta, Digipay, Vandar, Toman), and international gateways such as PayPal and Bitpay. It ships with Laravel auto-discovery — service provider and facade — and also works in plain PHP projects.

Features

  • More than 40 payment gateways behind one driver-based interface.
  • The same purchase(), pay() and verify() flow regardless of gateway.
  • Dedicated exceptions for invalid payments, failed purchases, and missing drivers or invoices.
  • Configuration passed inline or loaded from a published config file.
  • Payment lifecycle events you can hook into.
  • Auto-registered Laravel service provider and Anypay facade; usable standalone.
  • Supports card gateways as well as BNPL and installment providers.

Supported gateways

The following drivers are bundled under src/Drivers/:

Aqayepardakht Asanpardakht Atipay Azki (installment)
Behpardakht (Mellat) Bitpay Digipay Etebarino (installment)
Fanavacard Gooyapay IDPay Irankish
Jibit Local Minipay Nextpay
Omidpay Parsian Pasargad Payfa
Pay.ir PayPal Payping Paystar
Poolam Rayanpay Sadad (Melli) Saman
SEP (Saman Electronic) Sepehr (Saderat) Sepordeh Sizpay
Toman Vandar Walleta (installment) Yekpay
Zarinpal Zibal

Tech stack

Component Technology
Language PHP >= 7.2
Framework Laravel (service provider and facade; works standalone)
HTTP client Guzzle
Utilities Carbon (dates), Ramsey UUID, chillerlan/php-cache
Install Composer (PSR-4: Morpheusadam\Anypay\)

Requirements

  • PHP 7.2 or higher
  • Composer

Installation

composer require morpheusadam/AnyPay

In Laravel, the service provider and Anypay facade are auto-discovered; no manual registration is required.

Usage

Create and pay an invoice

$config  = ['driver' => 'gatewayName', 'api_key' => 'your_api_key'];
$anypay  = new Morpheusadam\Anypay\Anypay($config);

$invoice = new Morpheusadam\Anypay\Invoice();
$invoice->amount(1000); // amount in Rials

$anypay->via('gatewayName')->purchase($invoice)->pay();

Quick pay with the payWith helper

$config  = ['api_key' => 'your_api_key'];
$gateway = 'gatewayName';
$amount  = 1000; // amount in Rials

try {
    $anypay   = new Morpheusadam\Anypay\Anypay($config);
    $response = $anypay->payWith($gateway, $amount, $config);
    echo $response->getContent(); // payment response details
} catch (Exception $e) {
    echo 'Payment error: ' . $e->getMessage();
}

Verify a payment on the callback

try {
    $anypay  = new Morpheusadam\Anypay\Anypay($config);
    $receipt = $anypay->verify();
    echo 'Payment confirmed. Transaction ID: ' . $receipt->getTransactionId();
} catch (Exception $e) {
    echo 'Verification error: ' . $e->getMessage();
}

Laravel facade with a published config

use Morpheusadam\Anypay\Facades\Anypay;

$invoice = (new Invoice)->amount(1000);

Anypay::via('driverName')->purchase($invoice, function ($driver, $transactionId) {
    // store $transactionId against the order
});

Contributing

Open an issue or submit a pull request to add a gateway driver, fix a bug, or improve the docs.

License

Distributed under the MIT License. See LICENSE for full terms.

Author

Morpheus Adam — web developer, PHP, Laravel, Go.

About

Unified PHP & Laravel payments library integrating 40+ gateways: Iranian banks/PSPs, wallets, BNPL, and global providers.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages