Git Product home page Git Product logo

parsian's Introduction

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->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

parsian's People

Contributors

soltanihossein avatar sadeghpm avatar

Stargazers

reza abdolahi avatar Mohamad Talkhabi avatar SALEH MOMENZADEH avatar  avatar

Watchers

James Cloos avatar  avatar SALEH MOMENZADEH avatar

Forkers

eexbee

parsian's Issues

undefiendIndex OrderId

Hi , and Thanks for this package,
* $orderId = $response['orderId'];
should Change in Docs to * $orderId = $response['order_id'];

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.