PHP code example of dizatech / pasargad_ipg

1. Go to this page and download the library: Download dizatech/pasargad_ipg library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dizatech / pasargad_ipg example snippets


$args = [
    'username'          => '123',
    'password'          => '456',
    'terminal_number'   => '789',
]; //Replace arguments with your gateway actual values 
$ipg = new Dizatech\PasargadIpg\PasargadIpg($args);

$purchase = $ipg->purchase(
    amount: 20000,
    invoice_number: 1,
    invoice_date: '2024-06-29 10:20:30',
    redirect_address: 'http://myaddress.com/verify'
); //Replace arguments with your gateway actual values 
if ($purchase->status == 'success') {
    header("Location: {$purchase->payment_url}");
    exit;
}    

$inquiry = $ipg->inquiry(invoice_number: 1);
//Replace arguments with your gateway actual values 

//Replace arguments with your gateway actual values 
$inquiry = $ipg->inquiry(invoice_number: 1);
if ($inquiry->status == 'success' && $inquiry->payment_status == 'success') {
    $verification_result = $ipg->verify(
        invoice_number: 1,
        url_id: '2.................004497985'
    );
    if ($verification_result->status == 'success') {
        echo $inquiry->transaction_id . "<br>";
        echo $verification_result->reference_number . "<br>";
        echo $verification_result->pan . "<br>";
        echo $inquiry->url_id;
        die();
    } else {
        die('Failed');
    }
} elseif ($inquiry->status == 'success' && $inquiry->payment_status == 'refunded') {
    die('Refunded');
}

$refund = $ipg->refund(
    invoice_number: 1,
    url_id: '2.................004497985'
); //Replace arguments with your gateway actual values