دیزاتک / transaction
v1.1.5
2024-07-05 22:49 UTC
Requires
- php: 7.1.*|7.2.*|7.3.*|7.4.*|^8.0.2
- dizatech/parsian_ipg: ^0.1.1
- dizatech/pasargad_ipg: ^1.0.0
- dizatech/zarinpal_ipg: ^1.0
- laravel/framework: 7.*|8.*|^9.0|^10.0
README
این یک پکج لاراول برای ادغام درگاه پرداخت است.
💎 لیست رانندگان موجود
چگونه پکج dizatech/transaction را نصب و تنظیم کنیم؟
⬇️ نصب
composer require dizatech/transaction
فایل تنظیمات را منتشر کنید
php artisan vendor:publish --tag=dizatech_transaction
جداول را مهاجرت کنید، تا جدول تراکنشها به پایگاه داده اضافه شود
php artisan migrate
📖 چگونه از رانندگان موجود در پکج استفاده کنیم
-
تنظیمات را در /config/dizatech_transaction.php تنظیم کنید
-
این کد نمونه را برای درخواست پرداخت استفاده کنید
<?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();
-
این کد نمونه را برای تأیید پرداخت استفاده کنید
<?php // 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(); });
-
این Trait را در مدل خود استفاده کنید (برای مثال Payment، Invoice، Order، ...) که تراکنشهای زیادی دارد و ارتباطی با مدل Transaction دارد
<?php // Use the Trait use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Dizatech\Transaction\Traits\HasTransaction; class Order extends Model { use HasFactory, HasTransaction; } // After add the Trait we can use this relations $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
-
پدر تراکنش را دریافت کنید یا ببینید که این تراکنش به چه مدلی تعلق دارد
<?php // Set the namespace of your model in /config/dizatech_transaction.php 'model' => 'App\Models\Order', // Use relation for get a parent of this transaction $transaction->parent;
-
دادهها و متدهای اضافی مدل تراکنش
<?php // 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
نیازها
- PHP v7.0 یا بالاتر
- Laravel v7.0 یا بالاتر