Package Data | |
---|---|
Maintainer Username: | dena-a |
Package Create Date: | 2016-11-02 |
Package Last Update: | 2024-08-13 |
Home Page: | https://iran-payment.oneapp.ir/ |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-11 15:02:11 |
Package Statistics | |
---|---|
Total Downloads: | 2,353 |
Monthly Downloads: | 2 |
Daily Downloads: | 0 |
Total Stars: | 27 |
Total Watchers: | 4 |
Total Forks: | 16 |
Total Open Issues: | 3 |
a Laravel package to handle Internet Payment Gateways for Iran Banking System
You can install the package via composer:
$ composer require dena-a/iran-payment
This service provider must be installed.
// config/app.php
'providers' => [
...
Dena\IranPayment\IranPaymentServiceProvider::class
];
Add aliases:
// config/app.php
'aliases' => [
...
'IranPayment' => Dena\IranPayment\IranPayment::class,
];
Publish the config-file and migration with:
php artisan vendor:publish --provider="Dena\IranPayment\IranPaymentServiceProvider"
After the migration has been published you can create the transactions-tables by running the migrations:
php artisan migrate
//default gateway
$payment = new IranPayment();
// OR one of ['zarinpal', 'saman', 'payir']
$payment = new IranPayment('zarinpal');
// OR test gateway (Only works on debug mode)
$payment = new IranPayment('test');
$payment->build()
->setUserId($user->id)
->setAmount($data['amount'])
->setCallbackUrl(route('bank.callback'))
->ready();
return $payment->redirectView();
$payment = new IranPayment();
$payment->build()->verify($transaction);
$trackingCode = $payment->getTrackingCode();
$statusText = $payment->getTransactionStatusText();
use Dena\IranPayment\Providers\BaseProvider;
use Dena\IranPayment\Providers\GatewayInterface;
class NewGateway extends BaseProvider implements GatewayInterface {
public function getName() {
return 'new-gateway';
}
public function payRequest() {
$code = rand(1, 10000);
$this->setReferenceNumber($code);
$this->transactionPending([
'reference_number' => intval($code)
]);
}
public function verifyRequest() {
$this->transactionVerifyPending();
$code = rand(1, 10000);
$this->setTrackingCode($code);
$this->transactionSucceed(['tracking_code' => $code]);
}
public function redirectView() {
return view('welcome')->with([
'transaction' => $this->getTransaction()
]);
}
public function payBack() {
}
}
$payment = new IranPayment();
$payment->extends(NewGateway::class);
The MIT License (MIT). Please see License File for more information.