reactmore / tripay-payment-gateway
Client API Tripay Unofficial
2.0.0
2021-09-01 14:26 UTC
Requires
- php: ^7.0 | ^8.0
- guzzlehttp/guzzle: ^6.5 || ^7.0
- symfony/http-foundation: ^5.3
- vlucas/phpdotenv: ^4.2 || ^5.0
Requires (Dev)
README
For details please visit Official Documentation.
Instalation
composer require reactmore/tripay-payment-gateway
Configuration
require __DIR__ . '/vendor/autoload.php'; 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>';
If you are using Dot ENV you can add a Field in env.example and only need to call the main class
require __DIR__ . '/vendor/autoload.php'; 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>';
Callback Handler
<?php require __DIR__ . '/vendor/autoload.php'; use Reactmore\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; }
Method
For Handle Actions
Validation Request Return Throw;
License
Please see the LICENSE included in this repository for a full copy of the MIT license, which this project is licensed under.