sinarajabpour1998 / gateway
v1.5.2
2021-12-22 14:30 UTC
Requires
- php: 7.1.*|7.2.*|7.3.*|7.4.*|8.*
- laravel/framework: 7.*|8.*
- maryamnbyn/vandar-laravel: 1.*
- sinarajabpour1998/parsian_gateway: 1.*
- sinarajabpour1998/pasargad_gateway: 1.*
README
A Laravel Package for Payment Gateway Integration.
💎 List of available drivers
How to install and config sinarajabpour1998/gateway package?
⬇️ Installation
composer require sinarajabpour1998/gateway
Publish Config file
php artisan vendor:publish --tag=gateway
Migrate tables, to add transactions table to database
php artisan migrate
📖 How to use exists drivers from package
-
Set the configs in /config/gateway.php
-
Use this sample code for Request Payment
<?php // Parsian Driver $transaction = Transaction::driver('parsian') ->amount(2000) ->orderId(2000) ->callbackUrl('callback_parsian') ->detail(['auto_redirect' => false]) // if we want to get {token, url} and not auto redirect to Bank Gateway. ->pay(); // Pasargad Driver $transaction = Transaction::driver('pasargad') ->amount(2000) ->orderId(2000) ->callbackUrl('callback_pasargad') ->detail(['auto_redirect' => false]) // if we want to get {token, url} and not auto redirect to Bank Gateway. ->pay(); // Vandar Driver $transaction = Transaction::driver('vandar') ->amount(2000) ->orderId(2000) ->callbackUrl('callback_vandar') ->detail(['auto_redirect' => false]) // if we want to get {token, url} and not auto redirect to Bank Gateway. ->pay();
-
Use this sample code for Verify Payment
// Parsian Driver, that use POST type Route::post('/callback_parsian', function () { $verify = Transaction::driver('parsian')->request(request()->all())->verify(); }); // Pasargad Driver, that use GET type Route::get('/callback_pasargad', function () { $verify = Transaction::driver('pasargad')->request(request()->all())->verify(); }); // Vandar Driver, that use GET type request()->merge(['transId' => $order->transaction->id]); $result = Transaction::driver('vandar')->request(request()->all())->verify();
-
-
-
Use this Trait in you'r Model (for example Payment, Invoice, Order, ...) that has many transactions and has relation with Transaction Model
// Use the Trait use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Sinarajabpour1998\Gateway\Traits\HasTransaction; class Order extends Model { use HasFactory, HasTransaction; } // After add the Trait we can use this relations $order->transaction; // get latest transaction from this order $order->transactions; // get the all transactions for this order $order->pendingTransactions; // get the pending transactions for this order $order->successfulTransactions; // get the successful transactions for this order $order->failedTransactions; // get the failed transactions for this order $order->refundedTransactions; // get the refunded transactions for this order
-
Get the parent of a transaction or this transaction belongs to which model
// Set the namespace of your model in /config/transaction.php 'model' => 'App\Models\Order', // Use relation for get a parent of this transaction $transaction->parent;
-
Transaction model's data and appends
// Default $transaction->id; $transaction->order_id; $transaction->amount; $transaction->driver; $transaction->status; $transaction->ref_no; $transaction->token; $transaction->created_at; $transaction->updated_at; // Appends $transaction->gateway; // Label of driver $transaction->toman; // Get price to taman (convert rial to toman) $transaction->status_label; // Label of status
Requirements:
- PHP v7.0 or above
- Laravel v7.0 or above
- parsian_gateway
- pasargad_gateway
- vandar-laravel