PHP code example of reactmore / tripay-payment-gateway

1. Go to this page and download the library: Download reactmore/tripay-payment-gateway 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/ */

    

reactmore / tripay-payment-gateway example snippets




use Reactmore\Tripay\Main;

$data = new Main([
    'apiKey' => 'Your-Apikey',
    'privateKey' => 'Your-Private-Key',
    'merchantCode' => 'Your Merchant',
    'stage' => 'sandbox or Productions'
]);

$init = $data->init()->getPayment();

// Payload Must Array
$payload = ['code' => 'BRIVA'];

echo '<pre>';
print_r($init->getInstructions($payload));
echo '</pre>';



use Reactmore\Tripay\Main;

$data = new Main();

$init = $data->init()->initMerchant();

// Payload Must Array
$payload = ['code' => 'BRIVA'];

echo '<pre>';
print_r($init->instructions()->get($payload));
echo '</pre>';



eactmore\Tripay\Main;

$data = new Main();

$init = $data->initCallback();

if ($init->validateSignature()) {

    if ($init->callEvent() === 'payment_status') {
        // Response Callback
        $data = json_encode($init->get(), true);

        // Get Status From Data
        $status = $data['status'];

        if ($status === 'PAID') {
            // Your Logic
            echo $status;
        } elseif ($status === 'PAID') {
            // Your Logic
            echo $status;
        } elseif ($status === 'UNPAID') {
            // Your Logic
            echo $status;
        } elseif ($status === 'REFUND') {
            // Your Logic
            echo $status;
        } elseif ($status === 'EXPIRED') {
            // Your Logic
            echo $status;
        } else {
            // Your Logic
            echo $status; // Failed
        }
    }
    // IF ERROR FROM SYSTEM THROW IN THIS SECTIONS 

    // PUT RESPONSE CALLBACK TO CALLBACK-TRIPAY.JSON
    file_put_contents(__DIR__ . '/callback-tripay.json', $init->get() . PHP_EOL . PHP_EOL, FILE_APPEND | LOCK_EX);
} else {
    echo  'Invalid Signature! ';
    exit;
}