Download the PHP package hos69shah/gateways without Composer

On this page you can find all versions of the php package hos69shah/gateways. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package gateways

See Documentation With Better UX Here

Composer Plugin To Support Following Gateways

Also other gateways will be implemented soon, or feel free to do it on your own and merge it


Package Installation

  1. Downloading Package:
    php composer.phar require hos69shah/gateways

  2. Require Package In Project
    If you already require global vendor/autoload.php step this part, otherwise:
    require_once 'path/to/vendor/autoload.php';

  3. Using Namespace
    Then you must use my namespace to access classes simply:
    use Hossein\Gateway as HG;

Mellat Documentation

See Live Usage Here

When you done with above steps, you can simply use package to connect to Mellat gateway using your credential info supplied by Behpardakht.

Starting Payment

First of all create an instantiate of Mellat class:
$mellat = new HG\Mellat();

Then you should supply some variables and credentials to start payment as below:

All variables are set now. Remember if any of these variables didn't set, you'll encounter an exception before starting payment.

Now all you need to do is starting payment:

Note 1
You should use try-catch block for this plugin as it will through an exception in case of failure.

Note 2
You should catch all exception through AllException type.

Note 3
We can use Language class to translate exception messages as we see above.
You can use it's static function get($index) to get human readable message.
To get more information just look at src/Language.php and it's lang_fa() function to see indexes and messages. Also feel free to change message as you want or try to add extra language to it.

Starting Callback

When payment done or failed in bank side, user will redirect to address you provided before through $mellat->callback.

Now assume that here is a page we consider as callback. First of all we should provide and set some credential limiter than previous:

After these you should call request handler and wait for its response:

Note 4
Same as note 1 to 3, read them carefully.

Note 5
If anything failed you can call $mellat->refund_payment() to return fee to use bank account if his/her balance decreased. Also this is optional and bank will do it automatically after some minutes.

Properties

All variables are accessible but not necessarily settable

$mode
Settable/Accessible When everything is ok to redirect to bank page you have a few option to handle situation:

$direct_delay
Settable/Accessible
Number of second when you are in direct-delay mode. (default: 3)

$terminal
Settable/Accessible
Terminal ID provided by Behpardakht

$username
Settable/Accessible
Username provided by Behpardakht

Password
Settable/Accessible
Password provided by Behpardakht

$order_id
Settable/Accessible
Unique ID for each transaction. You should generate and store this value in your database to use it during handling callback.

$amount
Settable/Accessible
Amount of transaction fee that should be set in Rials and more than 0.

$callback
Settable/Accessible
A link that user will be redirected from bank. you should set it as you can get user information from it and fetch transaction order ID from.

$reference_id
Just Accessible
A string that will be generated on payment start for specific transaction

$result_code
Just Accessible
A code that returned by bank after each step. Almost always 0 means success.

$sale_order_id
Just Accessible
Long integer returned by bank contains an ID that should be store for further consistency.

$sale_reference_id
Just Accessible
Long integer returned by bank contains an ID that should be store for further consistency.

$card_holder_info
Just Accessible
...

$card_holder_pan
Just Accessible
Contains first 6 digit and last 4 digit of card number that user use to pay transaction.

Methods

init($terminal, $username, $password, $order, $amount, $callback, $additional)
All are optional.
Use this function to set all variables at one instead of individually.

start_payment()
To begin transaction and redirect user to bank. Use it after initializing variables and credentials.

handle_payment
To handle payment after returning from bank. Use it on callback page and call it after initializing variables and credentials.

refund_payment
To return fee to user account sooner. Use this function is optional and it should be used on catch block only.


All versions of gateways with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
econea/nusoap Version 0.9.5.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package hos69shah/gateways contains the following files

Loading the files please wait ....