1. Go to this page and download the library: Download tohidplus/zarrinpal 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/ */
return [
'merchantId'=>'XXXXX XXXXX XXXXX',
'callBackUrl'=>'http://yourwebsite.com/verifyPayment',
'description'=>'Some text here',
];
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Tohidplus\Zarrinpal\Facades\Zarrinpal;
class PaymentController extends Controller
{
public function redirectUserToBank()
{
Zarrinpal::setData(100,'[email protected]','09XXXXXXXXX','Some descripion','another/callback/url');
return Zarrinpal::redirect(function($status){
// Do something if there was a problem while redirection
});
}
public function verifyPayment(Request $request)
{
return Zarrinpal::verify($request,
function ($refId){
// The transaction is successfull
},function ($message,$status=null){
// The trasnsaction is unsuccessful
// if message was canceled it means user has canceled transaction them self
// if message was unsuccessful it means an error has occurred
});
}
}
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Tohidplus\Zarrinpal\Models\ZarrinpalLog;
class ZarrinpalLogController extends Controller
{
public function index()
{
$successfulTransactions = ZarrinpalLog::successful()->get();
$unsuccessfulTransactions = ZarrinpalLog::unsuccessful()->get();
$successfulTransactions = ZarrinpalLog::canceled()->get();
$pendingTransactions = ZarrinpalLog::pending()->get();
}
}