PHPackages                             asciisd/tap-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. [API Development](/categories/api)
4. /
5. asciisd/tap-php

ActiveLibrary[API Development](/categories/api)

asciisd/tap-php
===============

Tap Payment PHP Library

v2.2.2(1y ago)33081MITPHPPHP ^8.1|^8.2CI failing

Since Oct 16Pushed 1y ago1 watchersCompare

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

READMEChangelog (10)Dependencies (5)Versions (18)Used By (1)

Tap PHP bindings
================

[](#tap-php-bindings)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8391e33a9c3144d7df339c90c1a73c0599e13a4b41ea7acd952191156ac604df/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617363696973642f7461702d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/asciisd/tap-php)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/52c496915fbdd37a272616d2f92c63d061f474deddcb682108943ea7d736121c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f617363696973642f7461702d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/asciisd/tap-php)

The Tap PHP library provides convenient access to the Tap API from applications written in the PHP language. It includes a pre-defined set of classes for API resources that initialize themselves dynamically from API responses which makes it compatible with a wide range of versions of the Tap API.

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

[](#requirements)

PHP 7.3|8.0 and later.

Install
-------

[](#install)

You can install the bindings via [Composer](http://getcomposer.org/). Run the following command:

```
$ composer require asciisd/tap-php
```

To use the bindings, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading):

```
require_once('vendor/autoload.php');
```

Manual Installation
-------------------

[](#manual-installation)

If you do not wish to use Composer, you can download the [latest release](https://github.com/asciisd/tap-php/releases). Then, to use the bindings, include the `init.php` file.

```
require_once('/path/to/tap-php/init.php');
```

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

[](#dependencies)

The bindings require the following extensions in order to work properly:

- [`curl`](https://secure.php.net/manual/en/book.curl.php), although you can use your own non-cURL client if you prefer
- [`json`](https://secure.php.net/manual/en/book.json.php)
- [`mbstring`](https://secure.php.net/manual/en/book.mbstring.php) (Multibyte String)

If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that these extensions are available.

Usage
-----

[](#usage)

Simple usage looks like:

```
\Tap\Tap::setApiKey('sk_test_XKokBfNWv6FIYuTMg5sLPjhJ');
$charge = \Tap\Charge::create([
    'amount' => 2000,
    'currency' => 'usd',
    'source' => ['id' => 'tok_189fqt2eZvKYlo2CTGBeg6Uq'],
    'customer' => ['id' => 'cus_w4MN2720192134x9XB1510264']
]);
echo $charge;
```

Documentation
-------------

[](#documentation)

See the [PHP API docs](https://asciisd.com/tap/docs/api/php#intro).

Custom Request Timeouts
-----------------------

[](#custom-request-timeouts)

*NOTE:* We do not recommend decreasing the timeout for non-read-only calls (e.g. charge creation), since even if you locally timeout, the request on Tap's side can still complete. If you are decreasing timeouts on these calls, make sure to use [idempotency tokens](https://tap.com/docs/api/php#idempotent_requests) to avoid executing the same transaction twice as a result of timeout retry logic.

To modify request timeouts (connect or total, in seconds) you'll need to tell the API client to use a CurlClient other than its default. You'll set the timeouts in that CurlClient.

```
// set up your tweaked Curl client
$curl = new \Tap\HttpClient\CurlClient();
$curl->setTimeout(10); // default is \Tap\HttpClient\CurlClient::DEFAULT_TIMEOUT
$curl->setConnectTimeout(5); // default is \Tap\HttpClient\CurlClient::DEFAULT_CONNECT_TIMEOUT

echo $curl->getTimeout(); // 10
echo $curl->getConnectTimeout(); // 5

// tell Tap to use the tweaked client
\Tap\ApiRequestor::setHttpClient($curl);

// use the Tap API client as you normally would
```

### Configuring a Logger

[](#configuring-a-logger)

The library does minimal logging, but it can be configured with a \[`PSR-3` compatible logger\]\[psr3\] so that messages end up there instead of `error_log`:

```
\Tap\Tap::setLogger($logger);
```

### Accessing response data

[](#accessing-response-data)

You can access the data from the last API response on any object via `getLastResponse()`.

```
$charge = \Tap\Charge::create([
    'amount' => 2000,
    'currency' => 'usd',
    'source' => ['id' => 'tok_189fqt2eZvKYlo2CTGBeg6Uq'],
    'customer' => ['id' => 'cus_w4MN2720192134x9XB1510264']
]);
echo $charge->getLastResponse()->headers['Request-Id'];
```

### SSL / TLS compatibility issues

[](#ssl--tls-compatibility-issues)

Tap's API now requires that \[all connections use TLS 1.2\] . Some systems (most notably some older CentOS and RHEL versions) are capable of using TLS 1.2 but will use TLS 1.0 or 1.1 by default. In this case, you'd get an `invalid_request_error` with the following error message: "Tap no longer supports API requests made with TLS 1.0. Please initiate HTTPS connections with TLS 1.2 or later.".

The recommended course of action is to upgrade your cURL and OpenSSL packages so that TLS 1.2 is used by default, but if that is not possible, you might be able to solve the issue by setting the `CURLOPT_SSLVERSION` option to either `CURL_SSLVERSION_TLSv1` or `CURL_SSLVERSION_TLSv1_2`:

```
$curl = new \Tap\HttpClient\CurlClient([CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1]);
\Tap\ApiRequestor::setHttpClient($curl);
```

### Per-request Configuration

[](#per-request-configuration)

For apps that need to use multiple keys during the lifetime of a process, like one that uses \[Tap Connect\]\[connect\], it's also possible to set a per-request key and/or account:

```
\Tap\Charge::all([], [
    'api_key' => 'sk_test_...',
    'amount' => 2000,
    'currency' => 'usd',
    'source' => ['id' => 'tok_189fqt2eZvKYlo2CTGBeg6Uq'],
    'customer' => ['id' => 'cus_w4MN2720192134x9XB1510264']
]);

\Tap\Charge::retrieve("ch_18atAXCdGbJFKhCuBAa4532Z", [
    'api_key' => 'sk_test_...',
    'amount' => 2000,
    'currency' => 'usd',
    'source' => ['id' => 'tok_189fqt2eZvKYlo2CTGBeg6Uq'],
    'customer' => ['id' => 'cus_w4MN2720192134x9XB1510264']
]);
```

### Configuring CA Bundles

[](#configuring-ca-bundles)

By default, the library will use its own internal bundle of known CA certificates, but it's possible to configure your own:

```
\Tap\Tap::setCABundlePath("path/to/ca/bundle");
```

### Configuring Automatic Retries

[](#configuring-automatic-retries)

The library can be configured to automatically retry requests that fail due to an intermittent network problem:

```
\Tap\Tap::setMaxNetworkRetries(2);
```

\[Idempotency keys\]\[idempotency-keys\] are added to requests to guarantee that retries are safe.

### Request latency telemetry

[](#request-latency-telemetry)

By default, the library sends request latency telemetry to Tap. These numbers help Tap improve the overall latency of its API for all users.

You can disable this behavior if you prefer:

```
\Tap\Tap::setEnableTelemetry(false);
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Amr Emad](https://github.com/aemaddin)
- [Stripe](https://stripe.com) : this library is based on the stripe-php package infrastructure, so thanks Stripe.
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance43

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity79

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~122 days

Recently: every ~129 days

Total

17

Last Release

449d ago

Major Versions

v1.0.10 → v2.0.02023-04-15

PHP version history (3 changes)v1.0.0PHP &gt;=7.1.0

v1.0.10PHP ^7.3|^8.0

v2.0.0PHP ^8.1|^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/77636067?v=4)[ASCII SD](/maintainers/asciisd)[@asciisd](https://github.com/asciisd)

---

Top Contributors

[![aemaddin](https://avatars.githubusercontent.com/u/11630742?v=4)](https://github.com/aemaddin "aemaddin (28 commits)")

---

Tags

tap-apitap-phpapipayment processingasciisdtap-php

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/asciisd-tap-php/health.svg)

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

###  Alternatives

[ebanx/ebanx

EBANX PHP library

24648.5k](/packages/ebanx-ebanx)[pay-now/paynow-php-sdk

PHP client library for accessing Paynow API

18193.9k2](/packages/pay-now-paynow-php-sdk)[comgate/sdk

Comgate PHP SDK

13327.8k](/packages/comgate-sdk)[everypay/everypay-php

1742.0k](/packages/everypay-everypay-php)

PHPackages © 2026

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