Introducing the Multipay Project
Overview
Multipay is a versatile PHP package designed for seamless payment gateway integration. It offers comprehensive support for PHP versions 7.2 and above. By leveraging this powerful package, developers can easily integrate multiple payment gateways into their PHP applications, regardless of whether they are building from scratch or working on an existing Laravel project. The package is flexible enough to support various drivers, and it even allows for the creation of custom drivers if the available options do not meet specific requirements.
Features and Benefits
1. Multiple Driver Support
Multipay comes with out-of-the-box support for a wide range of payment gateways. Some popular choices include:
- Aqayepardakht
- Asanpardakht
- Atipay
- Payir
- Paypal (upcoming)
- Zarinpal
This extensive list ensures that developers have the flexibility to choose a payment gateway that perfectly fits their needs.
2. Flexible Configuration
The package offers an easy way to configure and manage different payment gateways. By using a single configuration file, developers can set up the default driver and adjust settings as needed. This can be particularly useful for applications that require compatibility with multiple gateways simultaneously.
3. Seamless Integration
Installing Multipay via Composer is straightforward:
composer require shetabit/multipay
Once installed, the package can be customized to fit any project. Developers can choose the gateway to work with and define default settings, which simplifies the integration process significantly.
4. Comprehensive Invoice Management
Multipay provides robust tools for managing invoices. The Invoice
class helps to create and handle payment details systematically, offering methods to set amounts, attach details, and track transactions.
5. Custom Driver Creation
If the existing drivers do not meet specific requirements, developers can create custom drivers. This flexibility ensures that Multipay can adapt to any project, regardless of the payment platform's peculiarities.
How It Works
Working with Payments
To use Multipay, developers begin by creating an Invoice
object, specifying transaction details such as amount and description. Then, a payment can be processed by purchasing and paying the invoice. Finally, payments can be verified to ensure the transaction was successful. Here is an example workflow:
-
Create an Invoice:
use Shetabit\Multipay\Invoice; $invoice = new Invoice; $invoice->amount(1000);
-
Purchase and Pay:
use Shetabit\Multipay\Payment; $payment = new Payment($paymentConfig); // Purchase and pay the invoice return $payment->purchase($invoice, function($driver, $transactionId) { // Store transactionId })->pay()->render();
-
Verify Payment:
use Shetabit\Multipay\Exceptions\InvalidPaymentException; try { $receipt = $payment->transactionId($transaction_id)->verify(); echo $receipt->getReferenceId(); } catch (InvalidPaymentException $exception) { echo $exception->getMessage(); }
Development and Testing
For testing and development, Multipay includes a 'Local' driver that simulates the payment flow without interacting with real banks. This allows developers to test their payment processes thoroughly before going live.
Conclusion
Multipay is a robust and flexible payment integration solution for PHP applications. With its extensive support for multiple payment gateways, customizable features, and developer-friendly approach, it stands out as an essential tool for anyone looking to integrate payment processing into their PHP projects seamlessly.