PHP code example of dpsoft / parsian-payment

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


 
use Dpsoft\Parsian\Parsian;

try{
    /**
    * @param int $pin (mount ( after payment
     * @param int $orderId (optional) The unique order id, generate by package if value passed null
     * @param int $additionalData (optional) addition data
	 *
	 * @method payRequest Return array contain transaction `token` and `orderId` and you cat save.
     * $token = $response['token'];
     * $orderId = $response['orderId'];
     *     
     */
    $response = $parsian->request($amount, $callbackUrl, $orderId, $additionalData);
    
    /**
     * Redirect user to payment gateway
     */
     echo $parsian->redirect();
    
    /**
     * If you need to get payment url for application or another reason you can use this method  
     * 
     * $paymentUrl = $parsian->getPaymentUrl();
     * 
     */
}catch (\Throwable $exception){
    echo $exception->getMessage();
}


use Dpsoft\Parsian\Parsian;

try{
        /**
         * @param int $pin (        * @method $verify return array of  transaction data.
          * $token = $response['token'];
          * $orderId = $response['order_id'];
          * $RRN = $response['RRN'];
          * $hashCardNumber = $response['hash_card_number'];
          */
        $response = $parsian->verify();
        
        echo "Successful payment ...";
}catch (\Throwable $exception){
    echo $exception->getMessage();
}


use Dpsoft\Parsian\Parsian;

try{
        /**
         * @param int $pin (am int $pin (ssful ...";
       
}catch (\Throwable $exception){
    echo $exception->getMessage();
}