soltanihossein/saman-payment

Saman bank payment


License
GPL-3.0-only

Documentation

Saman bank payment package

License: GPL v3

Easily integrate PHP application with saman bank payment.

Installation

$ composer require soltanihossein/saman-payment

Implementation

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

Request payment

<?php 
use SoltaniHossein\Saman\Saman;

try{
    /**
    * @param int $merchantId (required) The Saman gateway merchant id 
    */
    $saman = new Saman($merchantId);
	
    /**
     * @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 request Return array contain transaction `token` and you can save.
     * $token = $response;
     *     
     */
    $response = $saman->request($amount, $callbackUrl, $invoiceId);
    
    /**
     * Redirect user to payment gateway
     */
     echo $saman->redirect();
   
}catch (\Throwable $exception){
    echo $exception->getMessage();
}

Verify transaction

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

verify:

<?php
use SoltaniHossein\Saman\Saman;

try{
        /**
         * @param int $merchantId (required) The Saman gateway merchant id
         */
        $saman = new Saman($merchantId);
	
        /**
          * 
          * @method $verify return array of  transaction data.
          *
          */
        $response = $saman->verify($amount);
        
        echo "Successful payment ...";
}catch (\Throwable $exception){
    echo $exception->getMessage();
}

License

License: GPL v3

Copyright (c) 2020