Git Product home page Git Product logo

tripay-payment-gateway's Introduction

Tripay Payment Gateway Client Library

Latest Stable Version License Total Downloads

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

API Method Endpoint Status
PAYMENT Method initPayment() instructions() OK
MERCHANT Method initMerchant() paymentchannel(), calculator(), transactions OK
TRANSACTIONS CLOSE initTransactions() transactions(), detail(), create() OK
TRANSACTIONS OPEN initTransactionsOpen() transactions(), detail(), create() OK
CALLBACK InitCallback() signature(), callbackSignature(), validateSignature(), CallEvent() OK
PPOB InitPPOB() Progress

For Handle Actions

CODE MESSAGE
408 Connection Timeout Error. Please check your internet connection and try again
400 Message From API Check Documentation
200 Valid

Validation Request Return Throw;

THROW What Is
Missing arguements exception. Content fields must be complete Request is Valid but you forgot pass Main Argument
Field {missingFields} is missing You must forget Field Require From API
Content type must be array All request make from Array so code not pass if not in array

License

Please see the LICENSE included in this repository for a full copy of the MIT license, which this project is licensed under.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.