PHP code example of rasulian / laravel-zarinpal

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

    

rasulian / laravel-zarinpal example snippets


// config/app.php

'providers' => [
    // ...
    Rasulian\ZarinPal\ZarinPalServiceProvider::class,
];

php artisan vendor:publish --provider="Rasulian\ZarinPal\ZarinPalServiceProvider"

// config/zarinpal.php



return [
  'params' => [
    'merchant-id' => '',

    // Leave it empty if you're passing the callback url when doing the request
    'callback-url' => '',

    // A summary of your product or application, if needed
    'description' => '',
  ],

  // Set to true if you want to test the payment in sandbox mode
  'testing' => false
];



  use Rasulian\ZarinPal\Payment;

  class CheckoutConfirmOrderController extends Controller {


    /**
     * @param $zarinPal
     */
    protected $zarinPal;

    public function __construct(Payment $zarinPal)
    {
      ...
      $this->zarinPal = $zarinPal;
      ...
    }

  use Rasulian\ZarinPal\Payment;

  class CheckoutPaymentVerificationController extends Controller {


    /**
     * @param $zarinPal
     */
    protected $zarinPal;

    public function __construct(Payment $zarinPal)
    {
        ...
        $this->zarinPal = $zarinPal;
        ...
    }
    
    ...