PHP library for the GetLoy Payment Integration API.

1.0.3 2020-04-20 08:48 UTC

This package is auto-updated.

Last update: 2024-06-20 18:03:32 UTC


GetLoy Integration Library for PHP

Latest Stable Version Scrutinizer Code Quality Total Downloads License

The GetLoy Integration Library provides an easy way to access the GetLoy API from applications written in PHP.

The library currently supports the following payment methods:

  • iPay88 Cambodia (all supported payment methods)
  • Pi Pay
  • PayWay by ABA Bank (debit/credit card only, ABA Pay only, debit/credit card only, or both)


PHP 5.6.0 or later.


You can install the bindings via Composer. Run the following command:

composer require getloy/getloy-php

To use the bindings, use Composer's autoload:


Manual Installation

If you do not wish to use Composer, you can download the latest release. Then, to use the bindings, include the init.php file.


Getting Started

A simple usage example:

$gateway = new \Getloy\Gateway('YOUR GETLOY TOKEN');
        'testMode' => true,
        'merchantId' => 'YOUR PIPAY MERCHANT ID',
        'storeId' => 'YOUR PIPAY STORE ID',
        'deviceId' => 'YOUR PIPAY DEVICE ID',

$order = new \Getloy\TransactionDetails\OrderDetails(99.99, 'USD');
$payee = new \Getloy\TransactionDetails\PayeeDetails('John', 'Doe', '', '012345678');

echo $gateway->widgetHtml(

Passing additional order details

Most payment systems will display additional order details such as the order line items in the payment interface. This information can be provided in the widgetHtml() call.

$orderItems = new \Getloy\TransactionDetails\OrderItems();

    new \Getloy\TransactionDetails\OrderItem('Item 1', 2, 19.98, 9.99)
    new \Getloy\TransactionDetails\OrderItem('Item 2', 1, 12.50, 12.50)

$order = new \Getloy\TransactionDetails\OrderDetails(32.48, 'USD', null, $orderItems);

Callback validation

Getloy will make a POST request to the callback URL provided in the widgetHtml() call once the payment was confirmed, but before the user is redirected to the success URL.

The callback content is validated against a hash value that includes the (secret) GetLoy Token.

The following example, $order and lookupOrder() are placeholders for objects/methods provided by your application.

$gateway = new \Getloy\Gateway('YOUR GETLOY TOKEN');

    // unsupported request type

try {
    $callbackDetails = $gateway->readCallbackBodyAndParse();
} catch (Exception $exception) {
    // log invalid callback

if (Getloy\CallbackDetails::STATUS_SUCCESS !== $callbackDetails->status()) {
    // log invalid transaction status

// look up the order details using the transaction ID
$order = lookupOrder($callbackDetails->transactionId());

if (
    abs($order->amountPaid - $callbackDetails->amountPaid()) > 0.01
    || $order->currency !== $callbackDetails->currency()
) {
    // log transaction amount/currency mismatch

// update the order status to paid

If you are developing your application locally, you can use a service like ngrok to redirect callbacks from GetLoy to your local webserver.