PHPackages                             gingerpayments/ginger-php - 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. gingerpayments/ginger-php

ActiveLibrary[Payment Processing](/categories/payments)

gingerpayments/ginger-php
=========================

The official Ginger Payments PHP SDK

2.3.1(9mo ago)829.2k↓30%4[1 PRs](https://github.com/gingerpayments/ginger-php/pulls)5MITPHPPHP &gt;=8.1CI passing

Since Mar 19Pushed 2mo ago4 watchersCompare

[ Source](https://github.com/gingerpayments/ginger-php)[ Packagist](https://packagist.org/packages/gingerpayments/ginger-php)[ Docs](https://github.com/gingerpayments/ginger-php)[ RSS](/packages/gingerpayments-ginger-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (21)Used By (5)

Ginger PHP bindings
===================

[](#ginger-php-bindings)

[![Build](https://github.com/gingerpayments/ginger-php/actions/workflows/workflow.yml/badge.svg)](https://github.com/gingerpayments/ginger-php/actions/workflows/workflow.yml)[![Packagist](https://camo.githubusercontent.com/31902b6f7090c42c34a8ffc4b0b7231097a0a491ddc07ac9de753fe615a2e428/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67696e6765727061796d656e74732f67696e6765722d706870)](https://packagist.org/packages/gingerpayments/ginger-php)[![MIT License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](https://github.com/gingerpayments/ginger-php/blob/master/LICENSE)

Requirements
------------

[](#requirements)

- PHP 8.1 or later
- JSON PHP extension
- cURL PHP extension

Installation
------------

[](#installation)

You can install the PHP bindings using composer:

```
composer require gingerpayments/ginger-php

```

You can also use the PHP bindings without using Composer by registering an autoloader function:

```
spl_autoload_register(
    function($fqcn) {
        if (substr($fqcn, 0, 7) === 'Ginger\\') {
            return;
        }

        $pathToGinger = __DIR__ . '/relative/path/to/ginger';
        $class = substr($fqcn, 7);
        $path = sprintf('%s/src/%s.php', $pathToGinger, str_replace('\\', '/', $class));

        if (is_file($path)) {
            require_once $path;
        }
    }
);
```

Or you could just include the composer generated autoloader:

```
require_once 'ginger-php/vendor/autoload.php';
```

Getting started
---------------

[](#getting-started)

First create a new API client with your API key and API endpoint:

```
use \Ginger\Ginger;

$client = Ginger::createClient('https://api.example.com', 'your-api-key');
```

### Initiating a payment

[](#initiating-a-payment)

You can start a new payment by creating a new order:

```
$order = $client->createOrder(
    [
        'merchant_order_id' => 'my-custom-order-id-12345',
        'currency' => 'EUR',
        'amount' => 2500, // Amount in cents
        'description' => 'Purchase order 12345',
        'return_url' => 'https://www.example.com',
        'transactions' => [
            [
                'payment_method' => 'credit-card'
            ]
        ]
    ]
);
```

Once you've created your order, a transaction is created and associated with it. You will need to redirect the user to the transaction's payment URL, which you can retrieve as follows:

```
$paymentUrl = $order['order_url'];
```

It is also recommended that you store the order's ID somewhere, so you can retrieve information about it later:

```
$orderId = $order['id'];
```

There is a lot more data related to an order. Please refer to the API documentation provided by your PSP to learn more about the various payment methods and options.

### Getting an order

[](#getting-an-order)

If you want to retrieve an existing order, use the `getOrder` method on the client:

```
$order = $client->getOrder($orderId);
```

This will return an associative array with all order information.

### Updating an order

[](#updating-an-order)

Some fields are not read-only and you are able to update them after order has been created. You can do this using the `updateOrder` method on the client:

```
$order = $client->getOrder($orderId);
$order['description'] = "New Order Description";
$updatedOrder = $client->updateOrder($orderId, $order);
```

### Initiating a refund

[](#initiating-a-refund)

You can refund an existing order by using the `refundOrder` method on the client:

```
$refundOrder = $client->refundOrder($orderId, ['amount' => 123, 'description' => 'My refund']);
```

### Capturing a transaction of an order

[](#capturing-a-transaction-of-an-order)

You can initiate a capture of an order's transaction by using the `captureOrderTransaction` method:

```
$client->captureOrderTransaction($orderId, $transactionId);

```

### Getting the currency list

[](#getting-the-currency-list)

You can use the following request to retrieve a list of available currencies in ISO 4217 format.

```
$currencies = $client->getCurrencyList();
```

For each available payment method for your account, you receive a list with available ISO 4217 currencies.

### Custom requests

[](#custom-requests)

You can send any request that the API accepts using the `send` method. E.g. instead of using the `createOrder` method you could also use the following:

```
$result = $client->send(
    'POST', // Request method
    '/orders', // API path
    $orderData // Data to send with the request; optional
);
```

The `$result` variable would then contain the decoded JSON returned by the API.

Using a different CA bundle
---------------------------

[](#using-a-different-ca-bundle)

If you need to use a different CA bundle than the one that comes with your system or cURL installation, you can provide custom cURL options indicating the location of your CA bundle as follows:

```
use \Ginger\Ginger;

$client = Ginger::createClient(
    'https://api.example.com',
    'your-api-key',
    [
        CURLOPT_CAINFO => '/path/to/ca-bundle.pem'
    ]
);
```

For more information on which cURL options to use, refer to the PHP cURL documentation.

Custom HTTP client
------------------

[](#custom-http-client)

This library ships with its own minimal HTTP client for compatibility reasons. If you would like to use a different HTTP client, you can do so by implementing the `Ginger\HttpClient\HttpClient` interface and then constructing your own client:

```
$myHttpClient = new MyHttpClient();
$client = new Ginger\ApiClient($myHttpClient);
```

Make sure your HTTP client prefixes the endpoint URL and API version to all requests, and uses HTTP basic auth to authenticate with the API using your API key.

API documentation
-----------------

[](#api-documentation)

For the complete API documentation please prefer to the resources provided by your PSP.

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance73

Regular maintenance activity

Popularity34

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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

Every ~272 days

Recently: every ~539 days

Total

15

Last Release

271d ago

Major Versions

0.1.0 → 1.1.02016-05-23

1.2.6 → 2.0.02019-09-24

PHP version history (3 changes)0.1.0PHP &gt;=5.4.0

2.0.0PHP &gt;=5.6.0

2.3.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/507a164e15ddb49dc91079df0f966de9cfb83f59133f9870278c979b95ab7462?d=identicon)[gingerpayments](/maintainers/gingerpayments)

![](https://www.gravatar.com/avatar/10433980df605a27da43db5a16ea916bfc25ad0c958b5ac34be377173397cf3e?d=identicon)[Denis-Tsyganok-Leasoft](/maintainers/Denis-Tsyganok-Leasoft)

---

Top Contributors

[![fvdb](https://avatars.githubusercontent.com/u/25526?v=4)](https://github.com/fvdb "fvdb (76 commits)")[![dmitrijev](https://avatars.githubusercontent.com/u/8693837?v=4)](https://github.com/dmitrijev "dmitrijev (70 commits)")[![Denis-Tsyganok-Leasoft](https://avatars.githubusercontent.com/u/80386578?v=4)](https://github.com/Denis-Tsyganok-Leasoft "Denis-Tsyganok-Leasoft (15 commits)")[![volgustleasoft](https://avatars.githubusercontent.com/u/60009810?v=4)](https://github.com/volgustleasoft "volgustleasoft (1 commits)")

---

Tags

paymentpaymerchante-commerce

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gingerpayments-ginger-php/health.svg)

```
[![Health](https://phpackages.com/badges/gingerpayments-ginger-php/health.svg)](https://phpackages.com/packages/gingerpayments-ginger-php)
```

###  Alternatives

[lokielse/omnipay-alipay

Alipay gateway for Omnipay payment processing library

587421.0k11](/packages/lokielse-omnipay-alipay)[sudiptpa/omnipay-nabtransact

National Australia Bank (NAB) Transact driver for the Omnipay payment processing library.

1017.2k](/packages/sudiptpa-omnipay-nabtransact)[lucassmacedo/omnipay-mercadopago

MercadoPago gateway for OmniPay

154.6k](/packages/lucassmacedo-omnipay-mercadopago)

PHPackages © 2026

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