dpsoft/parsian-payment

Parsian bank payment

v3.0 2024-08-07 07:10 UTC

This package is auto-updated.

Last update: 2024-12-07 07:51:18 UTC


README

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->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();
}

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);
	
        /**
          * 
          * @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();
}

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