rez0sk / laravel-zarinpal
Laravel package for Zarinpal payment gateway.
Installs: 27
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 1
pkg:composer/rez0sk/laravel-zarinpal
Requires
- php: >=7.2
- ext-json: *
- guzzlehttp/guzzle: ^6.3
- illuminate/support: ~5.6.0|~5.7.0|~5.8.0|~5.9.0
Requires (Dev)
- mockery/mockery: ^1.0@dev
- orchestra/testbench: ^3.5
- phpro/grumphp: dev-master
- phpunit/phpunit: ^8.1@dev
Conflicts
This package is auto-updated.
Last update: 2022-07-13 03:59:27 UTC
README
Laravel package for Zarinpal payment gateway.
This package provides an interface (a laravel facade) that you can easily use and mock!
Features
- Mockability
- Dynamic MerchantID
- Supporting zarinpal's sandbox
Installation
composer require rez0sk/laravel-zarinpal
Configuration
In your config/services.php file add this config:
'zarinpal' => [ 'merchant_id' => env('ZARINPAL_MERCHANT_ID'), 'description' => 'Default description' // optional ]
then add ZARINPAL_MERCHANT_ID to your .env file.
Sandbox mode (Optional)
It's recomanded to enable sandbox mode in local environment.
If you wan't to do so, add these lines to your AppServiceProvider class's boot function.
public function boot() { if ($this->app->isLocal()) { Zarinpal::enableSandbox(); } }
Usage
Simply issue a payment-request and redirect user to Zarinpal with one shot!
use Zarinpal\Facades\Zarinpal; ... public function someControllerFunction () { return Zarinpal::pay(2000, route('paymnet.verify', $order->id))->redirect(); }
Or retrieve Authority code and redirect manually:
Zarinpal::pay(2000, 'http://callback.url/id')->payment->authority
There are some additional information you can provide for payment:
Zarinpal::pay(2000, 'http://callback.url/id', [ 'description' => 'This is such a dummy order!', 'email' => 'User's email address', 'phone' => 'User's phone number' ]);
Dynamic MerchantID
You can dynamically set MerchantID before each payment:
Zarinpal::setMerchantID('xxxxx-xxxx-xxx'); Zarinpal::pay(...)
Payment Verification
public function verifyOrderPayment (Order $order, Request $request) { $result = Zarinpal::verify($request, $order->TotalPrice); $result->status //Status code. 100 means success :) $result->RefID //Payment's unique ReferenceID $result->amount // Payment's amount in Tuman. (Always use Toman with Zarinpal) $result->description //Payment's description. }
TODO
- CI setup.
- Adding examples.
- Improve tests.
- Support wages.