PHP code example of rahmatwaisi / zarinpal

1. Go to this page and download the library: Download rahmatwaisi/zarinpal 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/ */

    

rahmatwaisi / zarinpal example snippets

 
    
    /**
     * کد پذیرندگی
     * Merchant ID
     */

    'merchant_id' => 'INSERT_YOUR_KEY_HERE',

\Illuminate\Support\Facades\Route::any(
    // TODO change this path if you want
    //   so if you changed this path, open config/pol.php and edit  callback_route key.
    '/zarinpal/payments/callback'
    , [
        Http\Controllers\Zarinpal\PaymentCallbackController::class
        , 'callback'
    ]
);

// ابتدا فاساد پکیج را ایمپورت کنید
use RahmatWaisi\Zarinpal\Facade\Zarinpal;


/*
 | در کنترلر یا متد مورد نظر کدهای زیر را استفاده کنید
 */
 
$price = 6480000; // 648 هزار تومان
$description = 'some description'; // تا حداکثر 30 کاراکتر
$mobile = '09012345678';
$email = '[email protected]';

// درخواست توکن پرداخت
$authorityResponse  = Zarinpal::authority($price, $description,null,$mobile, $email);

// $code = $authorityResponse['code']; // کد پاسخ درگاه
// $message = $authorityResponse['message']; // پیغام درگاه
$authority = $authorityResponse['authority'];

// برای هدایت به صفحه پرداخت
Zarinpal::pay($authority);

// برای بررسی صحت تراکنش
Zarinpal::verify($price, $authority);

// برای اصلاحیه پرداخت ناموفق و درخواست لغو تراکنش و برگشت مبلغ به حساب دارنده کارت
Zarinpal::refund($authority);
shell

php artisan vendor:publish
# now choose: ZarinpalServiceProvider