PHPackages                             lesterchan/gp-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. lesterchan/gp-php-sdk

ActiveLibrary

lesterchan/gp-php-sdk
=====================

The GP SDK for PHP provides a native interface to the GP API.

0153PHP

Since Aug 16Pushed 6y ago1 watchersCompare

[ Source](https://github.com/lesterchan/gp-php-sdk)[ Packagist](https://packagist.org/packages/lesterchan/gp-php-sdk)[ RSS](/packages/lesterchan-gp-php-sdk/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

GP PHP SDK
==========

[](#gp-php-sdk)

The GP SDK for PHP provides a native interface to the GP API. This is still a work in progress (WIP) project and hence it will be on the master branch.

Installation
============

[](#installation)

```
composer require lesterchan/gp-php-sdk
```

Usage
=====

[](#usage)

OAuth
-----

[](#oauth)

### Generate a web URL that provides a web interface for OAuth authentication.

[](#generate-a-web-url-that-provides-a-web-interface-for-oauth-authentication)

This helps the end-user login or register for GP.

```
/**
 * @param string $codeVerifier Code verifier
 * @param string $requestToken Request token
 * @param string $redirectUri Redirect URI
 * @param string $scope Scope (payment.one_time_charge or payment.recurring_charge)
 */
$gp->getOauthAuthorizeUrl($codeVerifier, $requestToken, $redirectUri, $scope);
```

### Generate the oauth token by passing ​code​ received in the return URL from GP.

[](#generate-the-oauth-token-by-passing-code-received-in-the-return-url-from-gp)

```
/**
 * @param string $code Code
 * @param string $redirectUri Redirect URI
 * @param string $codeVerifier Code verifier
 */
$gp->getAccessToken($code, $redirectUri, $codeVerifier);
```

One-Time Charge
---------------

[](#one-time-charge)

### Initialise.

[](#initialise)

```
/**
 * @param string $partnerId Partner ID
 * @param string $partnerSecret Partner Secret
 * @param string $clientId Client ID
 * @param string $clientSecret Client Secret
 * @param string $merchantId Merchant ID
 */
$gp = new GP\OneTimeCharge($partnerId, $partnerSecret, $clientId, $clientSecret, $merchantId);
```

### Set up the details required to initiate a one-time payment.

[](#set-up-the-details-required-to-initiate-a-one-time-payment)

```
/**
 * @param string $txId order ID
 * @param string $groupTxId partner transaction ID
 * @param int $amount ​Transaction amount as integer
 * @param string $description description of the charge (optional)
 */
$gp->initCharge($txId, $groupTxId, $amount, $description);
```

### Complete the payment authorised by the user.

[](#complete-the-payment-authorised-by-the-user)

```
/**
 * @param string $accessToken OAuth access token
 * @param string $partnerTxId partner transaction ID
 */
$gp->completeCharge($accessToken, $partnerTxId);
```

Tokenization
------------

[](#tokenization)

### Initialise.

[](#initialise-1)

```
/**
 * @param string $partnerId Partner ID
 * @param string $partnerSecret Partner Secret
 * @param string $clientId Client ID
 * @param string $clientSecret Client Secret
 * @param string $merchantId Merchant ID
 */
$gp = new GP\Tokenization($partnerId, $partnerSecret, $clientId, $clientSecret, $merchantId);
```

### Initiate the binding process with customer credits.

[](#initiate-the-binding-process-with-customer-credits)

```
/**
 * @param string $txId order ID
 */
$gp->bind($txId);
```

### Charge a customer who has completed the bind process with GP.

[](#charge-a-customer-who-has-completed-the-bind-process-with-gp)

```
/**
 * @param string $accessToken OAuth access token
 * @param string $txId order ID
 * @param string $groupTxId partner transaction ID
 * @param int $amount ​Transaction amount as integer
 * @param string $description description of the charge (optional)
 */
$gp->charge($accessToken, $txId, $groupTxId, $amount, $description);
```

### Deactivate the token generated during the binding process.

[](#deactivate-the-token-generated-during-the-binding-process)

```
/**
 * @param string $accessToken OAuth access token
 * @param string $txId order ID
 */
$gp->unbind($accessToken, $txId);
```

### View the wallet balance of the bound user.

[](#view-the-wallet-balance-of-the-bound-user)

```
/**
 * @param string $accessToken OAuth access token
 */
$gp->getWalletInfo($accessToken);
```

Status/Refunds
--------------

[](#statusrefunds)

### Check the status of a transaction.

[](#check-the-status-of-a-transaction)

```
/**
 * @param string $accessToken OAuth access token
 * @param string $txId order ID
 */
$gp->checkChargeStatus($accessToken, $txId);
```

### Refund a full or partial refunds for a specific transaction.

[](#refund-a-full-or-partial-refunds-for-a-specific-transaction)

```
/**
 * @param string $accessToken OAuth access token
 * @param string $txId order ID
 * @param string $groupTxId partner transaction ID
 * @param string $originTxID original partner transaction ID
 * @param int $amount ​Transaction amount as integer
 * @param string $description description of the charge (optional)
 */
$gp->refund($accessToken, $txId, $groupTxId, $originTxID, $amount, $description);
```

### Check the status of a refund transaction.

[](#check-the-status-of-a-refund-transaction)

```
/**
 * @param string $accessToken OAuth access token
 * @param string $txId order ID
 */
$gp->checkRefundStatus($accessToken, $txId);
```

POS
---

[](#pos)

### Initialise.

[](#initialise-2)

```
/**
 * @param string $partnerId Partner ID
 * @param string $partnerSecret Partner Secret
 * @param string $merchantId Merchant ID
 * @param string $terminalId Terminal ID
 */
$gp = new GP\Pos($partnerId, $partnerSecret, $merchantId, $terminalId);
```

### Creates a payment order and returns a QR code.

[](#creates-a-payment-order-and-returns-a-qr-code)

```
/**
 * @param string $txId order ID
 * @param int $amount ​Transaction amount as integer
 */
$gp->createMerchantPresentQrCode($txId, $amount);
```

### Performs a payment transaction which charges from the wallet associated with the request QR code.

[](#performs-a-payment-transaction-which-charges-from-the-wallet-associated-with-the-request-qr-code)

```
/**
 * @param string $txId order ID
 * @param int $amount ​Transaction amount as integer
 * @param string $qrCode QR code being scanned
 */
$gp->performConsumerPresentQrCode($txId, $amount, $qrCode);
```

### Returns details for a payment transaction or refund transaction.

[](#returns-details-for-a-payment-transaction-or-refund-transaction)

```
/**
 * @param string $txId order ID
 */
$gp->qrCodeInquiry($txId);
```

### Cancels a pending payment.

[](#cancels-a-pending-payment)

```
/**
 * @param string $origTxID Original order ID
 */
$gp->cancelTransaction($origTxID);
```

### Refunds a previously successful payment.

[](#refunds-a-previously-successful-payment)

```
/**
 * @param string $txID order ID
 * @param string $origTxID Original order ID
 * @param int $amount ​Transaction amount as integer
 */
$gp->refundTransaction($txID, $origTxID, $amount);
```

Others
------

[](#others)

### By default, the SDK will be using Staging URL. To switch to Production URL, use:

[](#by-default-the-sdk-will-be-using-staging-url-to-switch-to-production-url-use)

```
$gp->useProduction();
```

### Defaults to SG. Accepted values are SG, MY, VN, PH, and TH.

[](#defaults-to-sg-accepted-values-are-sg-my-vn-ph-and-th)

```
/**
 * @param string $countryCode Country code (alpha-2)
 */
$gp->setCountryCode($countryCode);
```

### Defaults to SGD. Accepted values are SGD, MYR, VND, PHP, and THB.

[](#defaults-to-sgd-accepted-values-are-sgd-myr-vnd-php-and-thb)

```
/**
 * @param string $currency Currency
 */
$gp->setCurrency($currency);
```

### Generate nonce.

[](#generate-nonce)

```
/**
 * @param int $length Length
 */
$gp->generateNonce($length);
```

Please refer to the [GP PHP SDK Sample Code Repository](https://github.com/lesterchan/gp-php-sdk-sample) for some sample codes.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/e04a2a5a55fe8c1287bc241b164dbcdb044740a5b52a773fd846102060c1c08b?d=identicon)[lesterchan](/maintainers/lesterchan)

---

Top Contributors

[![lesterchan](https://avatars.githubusercontent.com/u/355829?v=4)](https://github.com/lesterchan "lesterchan (5 commits)")

---

Tags

gpphp-sdk

### Embed Badge

![Health badge](/badges/lesterchan-gp-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/lesterchan-gp-php-sdk/health.svg)](https://phpackages.com/packages/lesterchan-gp-php-sdk)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
