PHP code example of hans-thomas / zarinpal

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

    

hans-thomas / zarinpal example snippets


merchantID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
sandbox=true
zarinGate=false

'zarinpal' => [
    'merchantID' => env( 'merchantID', 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' ),
    'zarinGate'  => env( 'zarinGate', false ),
    'sandbox'    => env( 'sandbox', false ),
],

use Zarinpal\Laravel\Facade\Zarinpal;

$results = Zarinpal::request(
    "example.com/call_back",               //call back url is ed also
    'metadata' => [
        '[email protected]',                  // email is optional
        '09000000000',                     //phone number is optional
    ]
    
);
// save $results['authority'] for verifying step
Zarinpal::redirect(); // redirect to zarinpal

// after that verify transaction by that $results['authority']
Zarinpal::verify(1000,$results['authority']);