Skip to content
Parsian bank payment PHP package
PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
sample
src
tests
.gitignore
LICENSE
README.md
composer.json
composer.lock
phpunit.xml

README.md

Parsian bank payment package

License: GPL v3

Easily integrate PHP application with parsian bank payment.

Installation

$ composer require dpsoft/parsian-payment

Implementation

Attention: The Parsian Bank webservice just available with IP that allowed with Parsian Bank.

استفاده از درگاه بانک پارسیان در زبان Php

Request payment

<?php 
use Dpsoft\Parsian\Parsian;

try{
    /**
    * @param int $pin (required) The Parsian gateway pin code 
    */
    $parsian = new Parsian($pin);
	
    /**
     * @param int $amount (required) The amount that customer must pay
     * @param string $callbackUrl (required) The url that customer redirect to 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->payRequest($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();
}

Verify transaction or maybe reverse transaction in conditions

Customer redirect to callback url with all transaction data and you must verify or rollback transaction.

verify:

<?php
use Dpsoft\Parsian\Parsian;

try{
        /**
         * @param int $pin (required) The Parsian gateway pin code 
         */
        $parsian = new Parsian($pin);
	
        /**
          * @var $token (required) Your transaction token you need to verify
          * @var $amount (required) Your consider amount for compare with payment amount
          * 
          * @method $verify return array of  transaction data.
          * $token = $response['Token'];
          * $orderId = $response['OrderId'];
          * $terminalNo = $response['TerminalNo'];
          * $RRN = $response['RRN'];
          * $hashCardNumber = $response['HashCardNumber'];
          * $amount = $response['Amount'];
          */
        $response = $parsian->verify($token, $amount);
        
        echo "Successful payment ...";
}catch (\Throwable $exception){
    echo $exception->getMessage();
}

Reverse transaction

If you don't verify transaction you can reverse it.

<?php
use Dpsoft\Parsian\Parsian;

try{
        /**
         * @param int $pin (required) The Parsian gateway pin code 
         */
        $parsian = new Parsian($pin);
	
        /**
         * @param int $pin (required) The Parsian gateway pin code 
         */
        $parsian->reverse($token);
    	
        echo "Transaction reverse successful ...";
       
}catch (\Throwable $exception){
    echo $exception->getMessage();
}

License

License: GPL v3

Copyright (c) 2018 dpsoft.ir

You can’t perform that action at this time.