Download the PHP package paytabs/php-sdk without Composer

On this page you can find all versions of the php package paytabs/php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-sdk

PayTabs PHP SDK (v4)

Official PHP SDK for integrating with PayTabs Payment Gateway.

Requirements

The SDK targets PHP 8.1 so it can be embedded in e-commerce platform plugins that still run on older merchant hosting. Contributing to the SDK requires PHP 8.2 or newer — see CONTRIBUTING.md.

Before you start

You need a PayTabs merchant account. From the merchant dashboard, take:

Use a test/sandbox profile while integrating, and keep credentials in environment variables rather than in the repository.

Install

Quick Start

The payment is not finished when the shopper is redirected. Confirm the outcome in your return and IPN handlers, and verify the signature there before trusting anything: docs/usage/Webhooks.md.

Error Handling

Every exception the SDK throws implements PaytabsExceptionInterface, so one catch block covers all of them:

Catch a specific class when you need to react differently:

Exception Raised when Extends
HttpRequestException Transport failure (DNS, TLS, timeout), or a non-2xx response with an empty or non-JSON body \RuntimeException
GatewayFailureException The gateway refused the request and returned a code/message — authentication failure, invalid currency, duplicate request \RuntimeException
InvalidConfigurationException Required configuration is missing, such as a profile \RuntimeException
InvalidSignatureException assertGenuine() rejected a webhook or browser callback \RuntimeException
MissingResponseFieldException The gateway omitted a field the SDK needs \RuntimeException
UnknownResponseValueException Strict mapping mode hit an unrecognised enum value \RuntimeException
EndpointNotFoundException An unknown endpoint code was requested \InvalidArgumentException
UnexpectedResponseStageException A stage accessor was called out of turn, e.g. getFailure() without isFailure() \LogicException
UnsupportedPayloadOperationException A builder was asked for something its transaction type forbids, e.g. payment methods on an Own Form \BadMethodCallException

Because each class still extends the same SPL type as before, existing catch (\RuntimeException) code keeps working unchanged.

A declined payment is not an exception. It arrives as a normal response: check $response->isFailure(), then getFailure()->code and ->message.

Retries. PayTabs has no idempotency-key header, and cart_id is your own reference which the gateway does not enforce as unique. Retrying a timed-out payment request can therefore charge the shopper twice, so the SDK never retries automatically. After a timeout, query the transaction before resending.

Security Notes

See webhook verification guide: docs/usage/Webhooks.md

Logging Configuration

The SDK provides a default file logger helper:

You can also inject any custom Psr\Log\LoggerInterface instance via Http::setLogger() or Paytabs::setLogger().

Default log location. With no argument, PaytabsLogger writes a daily file to /var/log/paytabs-sdk/. Pass an explicit path to change it:

Log files are created 0600 and the directory 0700, because gateway payloads pass through them.

Redaction. All SDK loggers strip cardholder data and credentials before writing: PANs are masked to first-6/last-4, and CVV, Authorization headers and key-like fields are removed — including inside an already-serialised JSON body. If you inject your own logger it receives the same redacted context. Do not re-serialise the raw request payload yourself and log it through a different channel.

BrowserLog is for local debugging only. It writes into the HTTP response; never enable it in production.

Diagnostics during response mapping (for example an unrecognised transaction status) go through a separate logger that defaults to error_log(), so a full disk or an unwritable path can never fail a payment:

Strict Response Mapping Mode

By default, response payload mapping is tolerant. Unknown enum values (for example unseen transaction status/class/type) are mapped to Unknown and logged.

You can enable strict mode to throw a dedicated exception instead:

Documentation

Ask DeepWiki

Project Governance

Samples Setup

  1. Copy Samples/.env.sample to Samples/.env.
  2. Replace placeholder values with sandbox credentials.
  3. Run samples locally and expose callback URL when needed.

Keep the working copy out of your web docroot. Samples/.env holds a profile ID and server key in plaintext and is read with parse_ini_file(). If the checkout sits under a docroot (for example /var/www/html/…), a request to …/Samples/.env is served as plaintext by any server without a dotfile deny rule — no PHP execution required. Clone outside the docroot, or deny dotfiles:

Samples/.env is gitignored and must never be committed. If a real key has been exposed, rotate it in the PayTabs merchant dashboard.

Development Commands

Live gateway tests are opt-in only:

Versioning

This SDK follows semantic versioning. Breaking changes are introduced only in major versions.

Support

For integration support, use PayTabs official support channels. For security vulnerabilities, report via the PayTabs Bug Bounty Program and follow SECURITY.md. Public issues are intended for reproducible SDK bugs and enhancement requests.


All versions of php-sdk with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-curl Version *
ext-json Version *
netresearch/jsonmapper Version ^5.0
psr/log Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package paytabs/php-sdk contains the following files

Loading the files please wait ...