PHP code example of travansoft / ezeepluspay

1. Go to this page and download the library: Download travansoft/ezeepluspay 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/ */

    

travansoft / ezeepluspay example snippets

 php

ansoft\EzeePlusPay\Client;

$client = new Client([
    'api_key' => 'YOUR_API_KEY',
    'secret'     => 'YOUR_SECRET_KEY',
    'base_url'    => 'https://secure.example.in/'
]);
 php
$merchantTransactionId$ = "ORD" . time();

$response = $client->createPayment([
    'merchant_tid'   => $merchantTransactionId,
    'amount'     => 49900,    
    'callback_url' => "https://yourdomain.com/payment/redirect.php",
    'metadata'   => [
        'customer'   => 'John Doe',
        'mobile' => '9876543210',
        'email'  => '[email protected]'
    ]
]);

echo "Redirect user to: " . $response['payment_url'];
 php
header("Location: " . $response['payment_url']);
exit;
 php
 
$result = $client->processPaymentCallback();

if (!$result->isValid()) {
    http_response_code(400);
    exit("Callback Error: " . $result->getError());
}

$data = $result->getData();

 php

$result = $client->handleCallback($signedPayload, $signature);

if ($result->isValid()) {
    $data = $result->getData();
} else {
    echo $result->getError();
}
 php


$result = $client->processWebhook();

if (!$result->isValid()) {
    http_response_code(400);
    exit("Callback Error: " . $result->getError());
}

$data = $result->getData();
$merchantTransactionID = $data['merchant_tid'];
$status  = $data['status'];
 php

$response = $client->fetchTransactionStatus($aggregatorTid);

if ($response['status'] === 'success') {
    $event = $response['event'];
    echo "Payment Status: " . $event['status'];
} else {
    echo "Transaction is still pending";
}

 php


$response = $client->fetchTransactionStatus($aggregatorTid, true);

if ($response['status'] === 'success') {
    $event = $response['event'];

    /*
     * Event payload structure:
     * [
     *   'aggregator_tid',
     *   'merchant_tid',
     *   'psp_tid',
     *   'amount',
     *   'status',        // SUCCESS | FAILED | REFUNDED
     *   'message',
     *   'psp',
     *   'raw_response',
     *   'timestamp'
     * ]
     */
} else {
    echo "Transaction still pending at payment gateway";
}