Download the PHP package shetabit/multipay without Composer
On this page you can find all versions of the php package shetabit/multipay. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download shetabit/multipay
More information about shetabit/multipay
Files in shetabit/multipay
Package multipay
Short Description PHP Payment Gateway Integration Package
License MIT
Homepage https://github.com/shetabit/multipay
Informations about the package multipay
PHP Payment Gateway
This is a PHP Package for Payment Gateway Integration. This package supports PHP 8.4+.
Donate me if you like this package :sunglasses: :bowtie:
For Laravel integration you can use shetabit/payment package.
This package works with multiple drivers, and you can create custom drivers if you can't find them in the current drivers list (below list).
- داکیومنت فارسی
- English documents
- 中文文档
List of contents
- PHP 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
- Local driver (for development)
- 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:
- bajet (Bajet / JETPAY credit payment) :heavy_check_mark:
- behpardakht (mellat) :heavy_check_mark:
- bitpay :heavy_check_mark:
- daracard :heavy_check_mark:
- digify :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
- authorize
- 2checkout
- braintree
- skrill
- payU
- amazon payments
- wepay
- payoneer
- paysimple
you can create your own custom drivers if it doesn't exist in the list, read the
Create custom driverssection.
Install
Via Composer
Configure
a. Copy config/payment.php into somewhere in your project. (you can also find it in vendor/shetabit/multipay/config/payment.php path).
b. In the config file you can set the default driver to be used for all your payments and 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.
Then fill the credentials for that gateway in the drivers array.
c. Instantiate the Payment class and pass configs to it like the below:
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:
Available methods:
uuid: set the invoice unique idgetUuid: retrieve the invoice current unique iddetail: attach some custom details into invoicegetDetails: retrieve all custom detailsamount: set the invoice amountgetAmount: retrieve invoice amounttransactionId: set invoice payment transaction idgetTransactionId: retrieve payment transaction idvia: set a driver we use to pay the invoicegetDriver: 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. -
amount: you can set the invoice amount directly -
via: change driver on the fly -
config: set driver configs on the fly custom fileds: Use custom fields of gateway (Not all gateways support this feature) SEP gateway support up to 4 custom fields and you can set the value to a string up to 50 characters. These custom fields are shown only when viewing reports in the user's panel.
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.
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\Multipay\Abstracts\Driver.
Eg. You created a class: App\Packages\Multipay\Driver\MyDriver.
Once you create that class you have to specify it in the payment.php config file map section.
Note: You have to make sure that the key of the map array is identical to the key of the drivers array.
Events:
Notice 1: event listeners will be registered globaly for all payments.
Notice 2: if you want your listeners work correctly, you must subcribe them before the target event dispatches.
Its better to subcribe events in your app's entry point or main service provider, so events will be subcribed before any events dispatches.
You can listen for 3 events:
- purchase
- pay
- verify.
-
purchase: Occurs when an invoice is purchased (after purchasing invoice is done successfully).
-
pay: Occurs when an invoice is prepared to pay.
- verify: Occurs when an invoice is verified successfully.
Local driver
Local driver can simulate payment flow of a real gateway for development purpose.
Payment can be initiated like any other driver
Calling render() method will render a HTML form with Accept and Cancel buttons, which simulate corresponding action of real payment gateway. and redirects to the specified callback url.
transactionId parameter will allways be available in the returned query url.
Payment can be verified after receiving the callback request.
In case of succesful payment, $receipt will contains the following parameters
In case of canceled payment, PurchaseFailedException will be thrown to simulate the failed verification of gateway.
Driver functionalities can be configured via Invoice detail bag.
-
available parameters -
appearance
Appearance of payment form can be customized via config parameter of local driver in payment.php file.
Testing
Every pull request and every push to master is checked by GitHub Actions: the test suite runs on
PHP 8.4 and 8.5 (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 75%.
The drivers are tested without touching the network: the test suite answers their HTTP calls from a queue of prepared responses, and checks the requests they send along the way.
You can run the same checks locally. With PHP and Composer installed on your machine:
If you would rather not install PHP on your machine, the shipped Dockerfile and Makefile run everything inside a
container:
Another PHP version can be used with make test PHP_VERSION=8.5.
Change log
Please see CHANGELOG for more information on what has been changed recently.
Contributing
Please see CONDUCT for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Mahdi khanzadi
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of multipay with dependencies
ext-json Version *
chillerlan/php-cache Version ^5.1
guzzlehttp/guzzle Version ^7.8.2|^8.0
nesbot/carbon Version ^3.13
ramsey/uuid Version ^4.9