sadegh-pm/saman_bank

Saman bank transaction package

v1.0 2018-02-17 20:07 UTC

This package is auto-updated.

Last update: 2024-11-05 00:48:50 UTC


README

License: GPL v2

Saman bank payment package

Install

Install latest version using composer.

$ composer require sadegh-pm/saman_bank

Usage

Request payment:

<?php
use SadeghPM\SamanBank\Saman;
use SadeghPM\SamanBank\SamanStorageAdapterInterface;
//seller ID
$merchantId = 'xxxxxxxx';
//database storage adapter that implements SamanStorageAdapterInterface
$myStorageAdapter = new myImplimentedStorageAdapter();
$payment = new Saman($myStorageAdapter,$merchantId);

$amountInRial = 10000;
//return customer after payment
$callbackUrl = 'http://mysite.ir/callback';
//request payment and redirect user to saman payment page
echo $payment->payRequest($amountInRial,$callbackUrl)->getRedirectScript();

Response verify:

<?php
use SadeghPM\SamanBank\Saman;
use SadeghPM\SamanBank\SamanStorageAdapterInterface;
//seller ID
$merchantId = 'xxxxxxxx';
//database storage adapter that implements SamanStorageAdapterInterface
$myStorageAdapter = new myImplimentedStorageAdapter();
$payment = new Saman($myStorageAdapter,$merchantId);

try{
    $payment->getPayStat($_POST);
    echo 'Thanks...successful payment.';
}catch (\Throwable $throwable){
    echo "error :".$throwable->getMessage();
}