PHP code example of dpsoft / mellat

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

    

dpsoft / mellat example snippets


try{
    $mellat = new \Dpsoft\Mellat\Mellat($terminalId, $userName, $userPassword);
    $response = $mellat->request($amount);
    
    //save $response info like token($response['token']) and orderId($response['order_id']) then redirect to bank
    echo "redirecting to bank...";
    $response->redirectToBank();
}catch(\Throwable $e){
    echo "error: ".$e->getMessage();
}

try{
    $mellat = new \Dpsoft\Mellat\Mellat($terminalId, $userName, $userPassword);
    $response = $mellat->verify();
    
    //successful payment. save $response info like reference id($response['reference_id'])
    echo "successful payment.Thanks...";
}catch(\Throwable $e){
    echo "error: ".$e->getMessage();
}