PHPackages                             craftgate/craftgate - 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. craftgate/craftgate

ActiveLibrary[Payment Processing](/categories/payments)

craftgate/craftgate
===================

craftgate php client

1.0.53(4mo ago)29100.3k↓66.6%7[2 PRs](https://github.com/craftgate/craftgate-php-client/pulls)MITPHPPHP &gt;=5.3.0CI passing

Since Jan 20Pushed 4d ago12 watchersCompare

[ Source](https://github.com/craftgate/craftgate-php-client)[ Packagist](https://packagist.org/packages/craftgate/craftgate)[ Docs](https://craftgate.io)[ RSS](/packages/craftgate-craftgate/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (2)Versions (69)Used By (0)

Craftgate PHP Client
====================

[](#craftgate-php-client)

[![Build Status](https://github.com/craftgate/craftgate-php-client/actions/workflows/craftgate-build.yml/badge.svg?branch=master)](https://github.com/craftgate/craftgate-php-client/actions?query=branch%3Amaster)[![Latest Stable Version](https://camo.githubusercontent.com/ba8ccc10cd90f13b89ff8cac64c1e4c42fc6ce54faa2cd328d7007a29bda693c/68747470733a2f2f706f7365722e707567782e6f72672f6372616674676174652f6372616674676174652f762f737461626c652e737667)](https://packagist.org/packages/craftgate/craftgate)[![Total Downloads](https://camo.githubusercontent.com/90920b209b8f51777ca86e436e03b4127a3dbcc0f47b2559761b6082e600a088/68747470733a2f2f706f7365722e707567782e6f72672f6372616674676174652f6372616674676174652f646f776e6c6f6164732e737667)](https://packagist.org/packages/craftgate/craftgate)[![License](https://camo.githubusercontent.com/87f9636a3f206f104f809a099b4d2a98040d3b7982af603b2082d11922a76d25/68747470733a2f2f706f7365722e707567782e6f72672f6372616674676174652f6372616674676174652f6c6963656e73652e737667)](https://packagist.org/packages/craftgate/craftgate)[![Gitpod ready-to-code](https://camo.githubusercontent.com/c01324668ea00cd2b02dc9fbf541676fb30543b69ef99a070d62a110917126d0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f476974706f642d72656164792d2d746f2d2d636f64652d626c75653f6c6f676f3d676974706f64)](https://gitpod.io/#https://github.com/craftgate/craftgate-php-client)

This repo contains the PHP client for Craftgate API.

[![Open in Gitpod](https://camo.githubusercontent.com/6a4edb76a7e92e0faad09a11e42cba7c39803ee6723f8cb1b801f91113d59695/68747470733a2f2f676974706f642e696f2f627574746f6e2f6f70656e2d696e2d676974706f642e737667)](https://gitpod.io/#https://github.com/craftgate/craftgate-php-client)

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

[](#requirements)

- PHP 5.3 and later.

Dependencies
------------

[](#dependencies)

The following PHP extensions are required:

- curl
- json

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

[](#installation)

### Composer

[](#composer)

Download [Composer](https://getcomposer.org/download/) and run the following command under your project.

```
composer require craftgate/craftgate
```

### Manual Installation

[](#manual-installation)

You need to download the latest [release](https://github.com/craftgate/craftgate-php-client/releases) and copy to your project. Then, include the autoload file as shown below. This file will autoload all related classes into your project on-demand.

```
require '/path/to/craftgate-php-client/autoload.php';
```

Usage
-----

[](#usage)

To access the Craftgate API you'll first need to obtain API credentials (e.g. an API key and a secret key). If you don't already have a Craftgate account, you can signup at [https://craftgate.io/](https://craftgate.io)

Once you've obtained your API credentials, you can start using Craftgate by instantiating a `Craftgate\Craftgate` with your credentials.

```
$craftgate = new \Craftgate\Craftgate(array(
    'apiKey' => '',
    'secretKey' => '',
));
```

By default the Craftgate client connects to the production API servers at `https://api.craftgate.io`. For testing purposes, please use the sandbox URL `https://sandbox-api.craftgate.io`.

```
$craftgate = new \Craftgate\Craftgate(array(
    'apiKey' => '',
    'secretKey' => '',
    'baseUrl' => 'https://sandbox-api.craftgate.io',
));
```

Examples
--------

[](#examples)

Included in the project are a number of examples that cover almost all use-cases. Refer to [the `samples/` folder](./samples) for more info.

### Running the Examples

[](#running-the-examples)

If you've cloned this repo on your development machine and wish to run the examples you can run an example with the command `./vendor/bin/phpunit`

### Credit Card Payment Use Case

[](#credit-card-payment-use-case)

Let's quickly review an example where we implement a credit card payment scenario.

> For more examples covering almost all use-cases, check out the [examples in the `samples/` folder](./samples)

```
$craftgate = new \Craftgate\Craftgate(array(
    'apiKey' => '',
    'secretKey' => '',
    'baseUrl' => 'https://sandbox-api.craftgate.io',
));

$request = array(
    'price' => 100,
    'paidPrice' => 100,
    'walletPrice' => 0,
    'installment' => 1,
    'currency' => \Craftgate\Model\Currency::TL,
    'paymentGroup' => \Craftgate\Model\PaymentGroup::LISTING_OR_SUBSCRIPTION,
    'conversationId' => '456d1297-908e-4bd6-a13b-4be31a6e47d5',
    'card' => array(
        'cardHolderName' => 'Haluk Demir',
        'cardNumber' => '5258640000000001',
        'expireYear' => '2044',
        'expireMonth' => '07',
        'cvc' => '000'
    ),
    'items' => array(
        array(
            'externalId' => \Craftgate\Util\Guid::generate(),
            'name' => 'Item 1',
            'price' => 30
        ),
        array(
            'externalId' => \Craftgate\Util\Guid::generate(),
            'name' => 'Item 2',
            'price' => 50
        ),
        array(
            'externalId' => \Craftgate\Util\Guid::generate(),
            'name' => 'Item 3',
            'price' => 20
        )
    )
);

$response = $craftgate->payment()->createPayment($request);

var_dump($response);
```

Idempotency
-----------

[](#idempotency)

Mutating operations accept an optional idempotency key. Add a `headerOptions` entry to the request with an `idempotencyKey` inside it and the client sends it as the `x-idempotency-key` header, so a request can be safely retried (e.g. after a timeout) without the operation being performed twice — the server returns the result of the first request when it sees a repeated key.

`headerOptions` is a reserved request key, accepted on any request:

```
$response = $craftgate->payment()->createPayment(array(
    'price' => 100.0,
    'paidPrice' => 100.0,
    'currency' => Currency::TRY,
    'paymentGroup' => PaymentGroup::LISTING_OR_SUBSCRIPTION,
    'headerOptions' => array('idempotencyKey' => uniqid('', true)),
    // ... other fields
));
```

Operations whose parameters live in the URL path take a request array as well, so they can carry a key too:

```
$craftgate->payment()->expireCheckoutPayment(array(
    'token' => '456d1297-908e-4bd6-a13b-4be31a6e47d5',
    'headerOptions' => array('idempotencyKey' => uniqid('', true))
));
```

> Use a fresh key per distinct operation, and reuse the same key when retrying that operation.

> The API honours the key on `POST`, `PATCH` and `DELETE` only. It is ignored on `PUT` endpoints, so retrying one of those is not de-duplicated.

`headerOptions` is sent as headers only — it is removed from the request before it is signed and sent, so it never reaches the request body, the query string, or the signature. Your array is left intact, so the same array can be passed again to retry.

### Contributions

[](#contributions)

For all contributions to this client please see the contribution guide [here](CONTRIBUTING.md). By participating in this project, you agree to abide by our [Code of Conduct](CODE_OF_CONDUCT.md).

Security
--------

[](#security)

If you discover a security vulnerability, please review our [Security Policy](SECURITY.md) for how to report it responsibly.

License
-------

[](#license)

This project is licensed under the Apache License, Version 2.0 — see the [LICENSE](LICENSE) and [NOTICE](NOTICE.md) files for details.

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance89

Actively maintained with recent releases

Popularity43

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor4

4 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 ~35 days

Recently: every ~61 days

Total

55

Last Release

125d ago

Major Versions

0.0.1 → 1.0.02021-01-26

### Community

Maintainers

![](https://www.gravatar.com/avatar/21279ee80bd9ffd375ba40171565a3c8d4169559b6353a6575dd842248c9064d?d=identicon)[craftgate](/maintainers/craftgate)

---

Top Contributors

[![sotuzun](https://avatars.githubusercontent.com/u/335067?v=4)](https://github.com/sotuzun "sotuzun (56 commits)")[![AlicanAkkus](https://avatars.githubusercontent.com/u/6232654?v=4)](https://github.com/AlicanAkkus "AlicanAkkus (24 commits)")[![tuncaserhat](https://avatars.githubusercontent.com/u/35580464?v=4)](https://github.com/tuncaserhat "tuncaserhat (19 commits)")[![abalikci](https://avatars.githubusercontent.com/u/108258717?v=4)](https://github.com/abalikci "abalikci (16 commits)")[![MasterSlave](https://avatars.githubusercontent.com/u/7658348?v=4)](https://github.com/MasterSlave "MasterSlave (14 commits)")[![deryacakmak](https://avatars.githubusercontent.com/u/36774966?v=4)](https://github.com/deryacakmak "deryacakmak (14 commits)")[![onurpolattimur](https://avatars.githubusercontent.com/u/23136437?v=4)](https://github.com/onurpolattimur "onurpolattimur (13 commits)")[![beratallahverdi](https://avatars.githubusercontent.com/u/35176276?v=4)](https://github.com/beratallahverdi "beratallahverdi (12 commits)")[![semihshn](https://avatars.githubusercontent.com/u/57491762?v=4)](https://github.com/semihshn "semihshn (8 commits)")[![mozcan](https://avatars.githubusercontent.com/u/6410488?v=4)](https://github.com/mozcan "mozcan (6 commits)")[![beransantur](https://avatars.githubusercontent.com/u/65870162?v=4)](https://github.com/beransantur "beransantur (5 commits)")[![reywyn](https://avatars.githubusercontent.com/u/9061788?v=4)](https://github.com/reywyn "reywyn (5 commits)")[![byofficial](https://avatars.githubusercontent.com/u/28408826?v=4)](https://github.com/byofficial "byofficial (4 commits)")[![lemiorhan](https://avatars.githubusercontent.com/u/1199195?v=4)](https://github.com/lemiorhan "lemiorhan (3 commits)")[![ygunayer](https://avatars.githubusercontent.com/u/592318?v=4)](https://github.com/ygunayer "ygunayer (2 commits)")[![krmgns](https://avatars.githubusercontent.com/u/1508306?v=4)](https://github.com/krmgns "krmgns (2 commits)")[![omeraplak](https://avatars.githubusercontent.com/u/1110414?v=4)](https://github.com/omeraplak "omeraplak (2 commits)")[![ozmenfurkan](https://avatars.githubusercontent.com/u/235353373?v=4)](https://github.com/ozmenfurkan "ozmenfurkan (2 commits)")[![mtbrkrgn](https://avatars.githubusercontent.com/u/39336991?v=4)](https://github.com/mtbrkrgn "mtbrkrgn (1 commits)")[![ibo](https://avatars.githubusercontent.com/u/701367?v=4)](https://github.com/ibo "ibo (1 commits)")

---

Tags

client-librarycraftgatecraftgate-apipaymentpayment-gatewaypayment-orchestrationphpphp-clientphp-sdkcraftgatecraftgate.io

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[pagseguro/php

Biblioteca de integração com o PagSeguro

23260.3k6](/packages/pagseguro-php)

PHPackages © 2026

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