dpsoft/pay.ir

Pay.ir online payment - درگاه پرداخت آسان پرداخت به زبان PHP

v1.0 2020-07-07 12:54 UTC

This package is auto-updated.

Last update: 2024-10-28 07:53:09 UTC


README

Latest Version on Packagist Total Downloads

Installation

You can install the package via composer:

composer require dpsoft/pay.ir

Usage

copy sample directory to server. Open request.php in browser and bala balah ...

Request

try {
    $pay = new \Dpsoft\Pay\Pay($apiKey);
    $result = $pay->request($callbackUrl,$amount);
    //save amount and invoice id to forther use
    $_SESSION['amount']=$amount;
    $_SESSION['invoice_id']=$result['invoice_id'];

    $pay->redirectToBank();
    exit();
}catch (Throwable $exception){
    echo $exception->getMessage();
}

Response

try {
    $pay = new \Dpsoft\Pay\Pay();
    $result = $pay->verify($_SESSION['amount'],$_SESSION['invoice_id']);
    //save result. The keys are: card_number,transaction_id and token for example $result['token']
    echo "Successfull transaction.";
}catch (Throwable $exception){
    echo "Error in transaction: ";
}

Testing

composer test

Security

If you discover any security related issues, please email info@dpsoft.ir instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.