1. Go to this page and download the library: Download tohidplus/mellat library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Tohidplus\Mellat\Facades\Mellat;
class PaymentController extends Controller
{
public function redirectUserToBank()
{
//Mellat::setCallBackUrl(url('/verifyPayment'));
Mellat::set(100);
return Mellat::redirect(function($message){
// Do something if there was a problem while redirection
//dd($message);
});
}
public function verifyPayment(Request $request)
{
return Mellat::verify(
function ($log){
// The transaction is successfull
//dd($log);
},function ($log){
// The trasnsaction is unsuccessful
//dd($log);
});
}
}
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Tohidplus\Mellat\Models\MellatLog;
class MellatLogController extends Controller
{
public function index()
{
$successfulTransactions = MellatLog::successful()->get();
$unsuccessfulTransactions = MellatLog::unsuccessful()->get();
$pendingTransactions = MellatLog::pending()->get();
}
}