PHPackages                             davismiculis/g2apay - 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. [Payment Processing](/categories/payments)
4. /
5. davismiculis/g2apay

Abandoned → [frontlabs/g2apay](/?search=frontlabs%2Fg2apay)Library[Payment Processing](/categories/payments)

davismiculis/g2apay
===================

G2APay PHP library for creating and sending payments.

v1.1.4(6y ago)34.8k6[1 issues](https://github.com/Frontlabs/G2APay/issues)MITPHPPHP &gt;=7.0.0

Since Jun 13Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Frontlabs/G2APay)[ Packagist](https://packagist.org/packages/davismiculis/g2apay)[ RSS](/packages/davismiculis-g2apay/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

G2APay PHP Library
==================

[](#g2apay-php-library)

[![G2APay](https://camo.githubusercontent.com/e8152238a191c8fb087528f057158ac97fcba8867f5df0302a7a9bb0f8afe84f/68747470733a2f2f7777772e6732612e636f2f6275696c642f696d672f6c6f676f732f6732612d7061792d663864326630353563372e706e67)](https://pay.g2a.com)

Create and send payments using G2APay payment gateway.

### Installation

[](#installation)

Run `composer require frontlabs/g2apay` to install through **Composer**.

### Usage

[](#usage)

**NOTE:** If variables / parameters in following code examples looks confusing to you, you can take a look at official [G2APay Documentation](https://pay.g2a.com/documentation#method-2-variables).

#### Initialization

[](#initialization)

Initialize G2APay library and set required parameters:

```
use G2APay\G2APay;

// Set required variables
$hash = 'your-api-hash'; // Get it from G2APay
$secret = 'your-api-secret'; // Get it from G2APay
$email = 'mail@example.com'; // Your G2APay store email
$success = 'http://example.com/success/'; // URL for successful callback;
$fail = 'http://example.com/failed/'; // URL for failed callback;
$order = 2234; // Choose your order id or invoice number, can be anything

// Optional
$currency = 'USD'; // Pass currency, if no given will use "USD"

// Create payment instance
$payment = new G2APay($hash, $secret, $email, $success, $fail, $order, $currency);
```

#### Adding Items

[](#adding-items)

Add item to your payment:

```
// Set item parameters
$sku = 1; // Item number (In most cases $sku can be same as $id)
$name = 'My Game';
$quantity = 1; // Must be integer
$id = 1; // Your items' identifier
$price = 9.95; // Must be float
$url = 'http://example.com/my-game/';

// Optional
$extra = '';
$type = '';

// Add item to payment
$payment->addItem($sku, $name, $quantity, $id, $price, $url, $extra, $type);
```

You can chain methods, and add multiple items:

```
$payment->addItem(114, 'Game', 1, 114, 9.95, 'http://example.com/i/game/')
        ->addItem(115, 'Gift', 2, 115, 1.50, 'http://example.com/i/gift/')
        ->addItem(116, 'Key', 1, 116, 9.50, 'http://example.com/i/key/');
```

#### Finalizing Payment

[](#finalizing-payment)

Create payment and send it to G2APay:

```
$orderId = 1; // Generate or save in your database
$extras = []; // Optional extras passed to order (Please refer G2APay docs)
// Create payment against G2APay
$response = $payment->createOrder($orderId, $extras);

// Or if you want to create sandbox payment (for testing only)
$response = $payment->test()->createOrder($orderId, $extras);
```

There can be two responses:

```
// Success
[
    'success' => true,
    'url' => 'https://checkout.pay.g2a.com/index/gateway?token=abc123'
]

// Fail
[
    'success' => false,
    'message' => 'Generic error message.',
]

```

#### Redirecting to G2APay site

[](#redirecting-to-g2apay-site)

After recieving `$response` you can now check if it was successful and redirect user to recieved G2APay website URL.

Simple code example:

```
// Check if successful
if ($response['success']) {
    header('Location: '.$response['url']); // redirect
} else {
    echo $response['message']; // print out error message
}
```

#### Callback

[](#callback)

**TODO:** When user successfuly pays or cancels, G2APay will redirect you back to your previously given callback urls.

### License

[](#license)

MIT

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2524d ago

### Community

---

Tags

composerg2apaypaymentphp

### Embed Badge

![Health badge](/badges/davismiculis-g2apay/health.svg)

```
[![Health](https://phpackages.com/badges/davismiculis-g2apay/health.svg)](https://phpackages.com/packages/davismiculis-g2apay)
```

###  Alternatives

[omnipay/paypal

PayPal gateway for Omnipay payment processing library

3156.8M53](/packages/omnipay-paypal)[eduardokum/laravel-boleto

Biblioteca com boletos para o laravel

626351.9k2](/packages/eduardokum-laravel-boleto)[tbbc/money-bundle

This is a Symfony bundle that integrates moneyphp/money library (Fowler pattern): https://github.com/moneyphp/money.

1961.9M](/packages/tbbc-money-bundle)[2checkout/2checkout-php

2Checkout PHP Library

83740.3k2](/packages/2checkout-2checkout-php)[smhg/sepa-qr-data

Generate QR code data for SEPA payments

61717.2k5](/packages/smhg-sepa-qr-data)[omnipay/dummy

Dummy driver for the Omnipay payment processing library

271.2M33](/packages/omnipay-dummy)

PHPackages © 2026

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