PHPackages                             atlpay/php-sdk-v2 - 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. atlpay/php-sdk-v2

ActiveLibrary[API Development](/categories/api)

atlpay/php-sdk-v2
=================

ATLPay APIv2 Integration PHP SDK

v1.0(7y ago)0181MITPHP

Since Aug 1Pushed 6y agoCompare

[ Source](https://github.com/FinPayTech/atlpay-php-sdk-v2)[ Packagist](https://packagist.org/packages/atlpay/php-sdk-v2)[ RSS](/packages/atlpay-php-sdk-v2/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

ATLPay PHP SDK for APIv2
========================

[](#atlpay-php-sdk-for-apiv2)

PHP Wrapper for ATLPay API Version 2

[ATLPay APIv2 Documentation](http://atlpay.readthedocs.io)

Table of Contents
=================

[](#table-of-contents)

- [Requirements](#requirements)
- [Installation and Usage](#installation-and-usage)
- [Dependencies](#dependencies)
- [Getting Started](#getting-started)
- [Error Handling](#error-handling)
- [Tokens](#tokens)
- [Creating a Token](#creating-a-token)
- [Retrieving a Token](#retrieving-a-token)
- [Creating a Charge](#creating-a-charge)
- [Retrieving a Charge](#retrieving-a-charge)
- [Cancelling a Charge](#cancelling-an-authorized-charge)
- [Capturing a Charge](#capturing-a-charge)
- [Creating a Refund](#creating-a-refund)
- [Custom Request Timeouts](#custom-request-timeouts)
- [SSL / TLS compatibility issues](#ssl--tls-compatibility-issues)
- [Test Cards](#test-cards)

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

[](#requirements)

PHP 5.5.28 and later.

Installation and Usage
----------------------

[](#installation-and-usage)

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

```
composer require atlpay/php-sdk-v2
```

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

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

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

[](#dependencies)

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

- [`ext_curl`](https://secure.php.net/manual/en/book.curl.php), although you can use your own non-cURL client if you prefer
- [`ext_json`](https://secure.php.net/manual/en/book.json.php)
- [`ext_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.

Getting Started
---------------

[](#getting-started)

ATLPay APIv2 is synchronized API and provides instant confirmation thus it does not require notification url. Any status returned by API should be considered final. Simple usage looks like:

```
\ATLPay\ATLPay::setSecretKey('PLACE_YOUR_SECRET_KEY_HERE');
$token	=	new \ATLPay\Token();
$token->createToken('5555 5555 5555 4444', 12, 2020, '009', 'CARD_HOLDER_NAME' '192.168.1.1', 'USER SESSION ID', 'user@example.com');
if($token->isError()){
	//Error Happened
}else{
	// Everything went well
}
```

Error Handling
--------------

[](#error-handling)

ATLPay uses conventional HTTP response codes to indicate the success or failure of an API request. In general: Codes in the `2xx` range indicate success. Codes in the `4xx` range indicate an error that failed given the information provided (e.g., a required parameter was omitted, a charge failed, etc.). Codes in the `5xx` range indicate an error with ATLPay's servers (these are rare).

Some `4xx` errors that could be handled programmatically (e.g., a card is declined) include an error code that briefly explains the error reported.

#### HTTP status code summary

[](#http-status-code-summary)

HTTP Status CodeDescription200Everything worked as expected.400The request was unacceptable, often due to missing a required parameter.401No valid API key provided.402The parameters were valid but the request failed.403You are not authorized to perform this transaction.404The requested resource doesn't exist.500, 502, 503, 504Something went wrong on ATLPay's end. (These are rare.)Tokens
------

[](#tokens)

Tokenization is the process ATLPay uses to collect sensitive card or personally identifiable information (PII), directly from your customers in a secure manner. A token representing this information is returned to your server to use. You should use [ATLPay.js](https://www.atlpay.com/js/ATLPay.js) or our mobile libraries to perform this process, client-side. This ensures that no sensitive card data touches your server, and allows your integration to operate in a PCI-compliant way.

If you cannot use client-side tokenization, you can also create tokens using the API with secret API key. Keep in mind that if your integration uses this method, you are responsible for any PCI compliance that may be required, and you must keep your secret API key safe. Unlike with client-side tokenization, your customer's information is not sent directly to ATLPay, so we cannot determine how it is handled or stored.

Tokens cannot be stored or used more than once.

Creating a Token
----------------

[](#creating-a-token)

### Client Side

[](#client-side)

Creating token using ATLPay.js is described [here](http://atlpay.readthedocs.io).

### Server side

[](#server-side)

```
\ATLPay\ATLPay::setSecretKey('PLACE_YOUR_SECRET_KEY_HERE');
$token	=	new \ATLPay\Token('5555 5555 5555 4444', 12, 2020, '009', '192.168.1.1', 'USER SESSION ID', 'user@example.com');
$token->createToken();
if($token->isError()){
 	if(in_array($token->httpCode, [500, 502, 503, 504])){
		die("Something went wrong on ATLPay's end. (These are rare.)");
	}else if($token->httpCode == 400){
		if(isset($token->param) && $token->param == "card.name"){
			die("Problem with Cardholder's name : (".$token->code.") ".$token->message);
		}else if(isset($token->param) && $token->param == "card.number"){
			die("Problem with Card Number : (".$token->code.") ".$token->message);
		}else if(isset($token->param) && $token->param == "card.exp_month"){
			die("Problem with Card Expiry Month : (".$token->code.") ".$token->message);
		}else if(isset($token->param) && $token->param == "card.exp_year"){
			die("Problem with Card Expiry Year : (".$token->code.") ".$token->message);
		}else if(isset($token->param) && $token->param == "card.cvc"){
			die("Problem with Card CVC : (".$token->code.") ".$token->message);
		}else if(isset($token->param) && $token->param == "shopper.ip"){
			die("Problem with Shopper IP Address : (".$token->code.") ".$token->message);
		}else if(isset($token->param) && $token->param == "shopper.session_id"){
			die("Problem with Shopper Session ID : (".$token->code.") ".$token->message);
		}else if(isset($token->param) && $token->param == "shopper.email"){
			die("Problem with Shopper E-Mail : (".$token->code.") ".$token->message);
		}else{
			die("Problem : ".$token->message);
		}
	}else if($token->httpCode == 401){
		die("Check your API Key");
	}else if($token->httpCode == 402){
		die("You may encounter this error if you're not using TLS_1_2");
	}else if($token->httpCode == 403){
		die("Check your API Key");
	}
	//Since we are creating token, this request shall not be ended httpCode 404 i.e. Not Found
}else{
 	$tokenId	=	$token->getId();
	$cardBrand	=	$token->getCardBrand();
	$cardIssuerCountry	=	$token->getCardCountry();
	$cardFundingType	=	$token->getFundingType();
	$cardLast4	=	$token->getLast4Digits();
	$threeDRedirectStatus	=	$token->getRedirectStatus();
	$transactionMode	=	$token->getMode();
	// See Model/TokenModel.php for more Getter Methods
}
```

Retrieving a Token
------------------

[](#retrieving-a-token)

```
\ATLPay\ATLPay::setSecretKey('PLACE_YOUR_SECRET_KEY_HERE');
$token	=	new \ATLPay\Token();
$token->getToken($tokenId);
if($token->isError()){
 	if(in_array($token->httpCode, [500, 502, 503, 504])){
		die("Something went wrong on ATLPay's end. (These are rare.)");
	}else if($token->httpCode == 400){
		die($token->message);
	}else if($token->httpCode == 401){
		die("Check your API Key");
	}else if($token->httpCode == 402){
		die("You may encounter this error if you're not using TLS_1_2");
	}else if($token->httpCode == 403){
		die("Check your API Key");
	}else if($token->httpCode == 404){
		die("Token Not Found.");
	}
	//Since we are retrieving token, this request shall not be ended httpCode 402 i.e. BAD_REQUEST
}else{
 	$tokenId	=	$token->getId();
	$cardBrand	=	$token->getCardBrand();
	$cardIssuerCountry	=	$token->getCardCountry();
	$cardFundingType	=	$token->getFundingType();
	$cardLast4	=	$token->getLast4Digits();
	$threeDRedirectStatus	=	$token->getRedirectStatus();
	$transactionMode	=	$token->getMode();
	// See Model/TokenModel.php for more Getter Methods
}
```

Creating a Charge
-----------------

[](#creating-a-charge)

```
\ATLPay\ATLPay::setSecretKey('PLACE_YOUR_SECRET_KEY_HERE');
$charge	=	new \ATLPay\Charge(ATLPAY_TOKEN_ID, 50.00, EUR, ORDER_NUMBER, ORDER_DESCRIPTION, 'https://www.your-return-url.com');
//Here https://www.your-return-url.com is used as placeholder replace it with your url.
//After 3D Authorization is completed User will be redirected back this url and you can proceed with
//capturing or cancelling the charge. Refer to Handling 3DS or 3-D Security for more details
$charge->initialize();
if($charge->isError()){
 	if(in_array($charge->httpCode, [500, 502, 503, 504])){
		die("Something went wrong on ATLPay's end. (These are rare.)");
	}else if($charge->httpCode == 400){
		if(isset($charge->param) && $charge->param == "amount"){
			die("Problem with Charge Amount : (".$charge->code.") ".$charge->message);
		}else if(isset($charge->param) && $charge->param == "currency"){
			die("Problem with Charge Currency : (".$charge->code.") ".$charge->message);
		}else if(isset($charge->param) && $charge->param == "description"){
			die("Problem with Charge Description : (".$charge->code.") ".$charge->message);
		}else if(isset($charge->param) && $charge->param == "return_url"){
			die("Problem with Return URL : (".$charge->code.") ".$charge->message);
		}else{
			die("Problem : ".$charge->message);
		}
	}else if($charge->httpCode == 401){
		die("Check your API Key");
	}else if($charge->httpCode == 402){
		die("You may encounter this error if you're not using TLS_1_2");
	}else if($charge->httpCode == 403){
		die("Check your API Key");
	}
	//Since we are creating charge, this request shall not be ended httpCode 404 i.e. Not Found
}else{
 	$chargeId	=	$charge->getId();
	$chargeCurrency	=	$charge->getCurrency();
	$chargeAmount	=	$charge->getAmount();
	$atlpayFees	=	$charge->getFees();
	$token	=	$charge->token();
	// See Model/TokenModel.php for more Getter Methods
	$threeDRedirectUrl	=	$charge->getRedirectUrl();
	$threeDRedirectResult	=	$charge->get3DRedirectStatus();
	$transactionMode	=	$charge->getMode();
	// See Model/ChargeModel.php for more Getter Methods
	if( $token->getRedirectStatus() == "REQUIRED" ){
		header("Location:".$threeDRedirectUrl);
		exit;
	}else{
		//Capture the charge directly, See Capturing a Charge
	}
}
```

Retrieving a Charge
-------------------

[](#retrieving-a-charge)

```
\ATLPay\ATLPay::setSecretKey('PLACE_YOUR_SECRET_KEY_HERE');
$charge	=	new \ATLPay\Charge();
$charge->get($apChargeId);
if($charge->isError()){
 	if(in_array($charge->httpCode, [500, 502, 503, 504])){
		die("Something went wrong on ATLPay's end. (These are rare.)");
	}else if($charge->httpCode == 400){
		die($charge->message);
	}else if($charge->httpCode == 401){
		die("Check your API Key");
	}else if($charge->httpCode == 402){
		die("You may encounter this error if you're not using TLS_1_2");
	}else if($charge->httpCode == 403){
		die("Check your API Key");
	}else if($charge->httpCode == 404){
		die("Charge Not Found.");
	}
}else{
 	$chargeId	=	$charge->getId();
	$chargeCurrency	=	$charge->getCurrency();
	$chargeAmount	=	$charge->getAmount();
	$chargeStatus	=	$charge->getStatus();
	if($charge->isSuccess()){
		$atlpayFees	=	$charge->getFees();
	}else{
		$failureReason	=	$charge->getReason();
	}
	$token	=	$charge->token();
	// See Model/TokenModel.php for more Getter Methods
	$threeDRedirectUrl	=	$charge->getRedirectUrl();
	$threeDRedirectResult	=	$charge->get3DRedirectStatus();
	$transactionMode	=	$charge->getMode();
	// See Model/ChargeModel.php for more Getter Methods
}
```

Cancelling an Authorized Charge
-------------------------------

[](#cancelling-an-authorized-charge)

```
\ATLPay\ATLPay::setSecretKey('PLACE_YOUR_SECRET_KEY_HERE');
$charge	=	new \ATLPay\Charge();
$charge->cancel($apChargeId);
if($charge->isError()){
 	if(in_array($charge->httpCode, [500, 502, 503, 504])){
		die("Something went wrong on ATLPay's end. (These are rare.)");
	}else if($charge->httpCode == 400){
		die($charge->message);
	}else if($charge->httpCode == 401){
		die("Check your API Key");
	}else if($charge->httpCode == 402){
		die("You may encounter this error if you're not using TLS_1_2");
	}else if($charge->httpCode == 403){
		die("Check your API Key");
	}else if($charge->httpCode == 404){
		die("Charge Not Found.");
	}
}else{
	$chargeStatus	=	$charge->getStatus(); //CHARGE_FAILED
	$failureReason	=	$charge->getReason(); //CANCEL_USING_API
	$transactionMode	=	$charge->getMode();
	// See Model/ChargeModel.php for more Getter Methods
}
```

Capturing a Charge
------------------

[](#capturing-a-charge)

```
\ATLPay\ATLPay::setSecretKey('PLACE_YOUR_SECRET_KEY_HERE');
$charge	=	new \ATLPay\Charge();
$charge->get($apChargeId);
if($charge->isError()){
 	if(in_array($charge->httpCode, [500, 502, 503, 504])){
		die("Something went wrong on ATLPay's end. (These are rare.)");
	}else if($charge->httpCode == 400){
		die($charge->message);
	}else if($charge->httpCode == 401){
		die("Check your API Key");
	}else if($charge->httpCode == 402){
		die("You may encounter this error if you're not using TLS_1_2");
	}else if($charge->httpCode == 403){
		die("Check your API Key");
	}else if($charge->httpCode == 404){
		die("Charge Not Found.");
	}
}else{
 	$threeDRedirectUrl	=	$charge->getRedirectUrl();
	$threeDRedirectResult	=	$charge->get3DRedirectStatus();
	if($threeDRedirectResult == "CHARGEABLE"){
		$charge->capture();
		if($charge->isError()){
			if(in_array($charge->httpCode, [500, 502, 503, 504])){
				die("Something went wrong on ATLPay's end. (These are rare.)");
			}else if($charge->httpCode == 400){
				die($charge->message);
			}else if($charge->httpCode == 401){
				die("Check your API Key");
			}else if($charge->httpCode == 402){
				die("You may encounter this error if you're not using TLS_1_2");
			}else if($charge->httpCode == 403){
				die("Check your API Key");
			}else if($charge->httpCode == 404){
				die("Charge Not Found.");
			}
		}else{
			$chargeStatus	=	$charge->getStatus();
			if($charge->isSuccess()){
				$atlpayFees	=	$charge->getFees();
			}else{
				$failureReason	=	$charge->getReason();
			}
			$transactionMode	=	$charge->getMode();
		}
	}else if($threeDRedirectResult == "PENDING"){
		header("Location:".$threeDRedirectUrl);
		exit;
	}else{
		die("Charge Status : ".$chargeStatus." is not capturable.");
	}

}
```

Creating a Refund
-----------------

[](#creating-a-refund)

ATLPay lets you do partial and full refunds. It also allows you to process multiple partial refunds.

A) Creating partial refund

```
\ATLPay\ATLPay::setSecretKey('PLACE_YOUR_SECRET_KEY_HERE');
$refund	=	new \ATLPay\Charge();
$refund->refund($apChargeId, $amountToRefund);
if($refund->isError()){
 	if(in_array($refund->httpCode, [500, 502, 503, 504])){
		die("Something went wrong on ATLPay's end. (These are rare.)");
	}else if($refund->httpCode == 400){
		die($refund->message);
	}else if($refund->httpCode == 401){
		die("Check your API Key");
	}else if($refund->httpCode == 402){
		die("You may encounter this error if you're not using TLS_1_2");
	}else if($refund->httpCode == 403){
		die("Check your API Key");
	}else if($refund->httpCode == 404){
		die("Charge Not Found.");
	}
}else{
	$refundId		=	$refund->getId();
	$refundAmount	=	$refund->getAmount();
	$refundFees	=	$refund->getFees();
	$transactionMode	=	$refund->getMode();
}
```

B) Creating full refund

```
\ATLPay\ATLPay::setSecretKey('PLACE_YOUR_SECRET_KEY_HERE');
$refund	=	new \ATLPay\Charge();
$refund->refund($apChargeId);
if($refund->isError()){
 	if(in_array($refund->httpCode, [500, 502, 503, 504])){
		die("Something went wrong on ATLPay's end. (These are rare.)");
	}else if($refund->httpCode == 400){
		die($refund->message);
	}else if($refund->httpCode == 401){
		die("Check your API Key");
	}else if($refund->httpCode == 402){
		die("You may encounter this error if you're not using TLS_1_2");
	}else if($refund->httpCode == 403){
		die("Check your API Key");
	}else if($refund->httpCode == 404){
		die("Charge Not Found.");
	}
}else{
	$refundId		=	$refund->getId();
	$refundAmount	=	$refund->getAmount();
	$refundFees	=	$refund->getFees();
	$transactionMode	=	$refund->getMode();
}
```

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 ATLPay's side can still complete.

```
\ATLPay\ATLPay::setTimeout(15);
```

SSL / TLS compatibility issues
------------------------------

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

ATLPay'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 BAD\_REQUEST error with the following error message: "ATLPay 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`:

```
\ATLPay\ATLPay::setSSLVersion(CURL_SSLVERSION_TLSv1_2);
```

Test Cards
----------

[](#test-cards)

Following test cards can be used for testing ATLPay API

Card NumberBrandFunding TypeIssuer Country5555 5555 5555 4444MasterCardCreditGB5454 5454 5454 5454MasterCardDebitFR5555 5555 5555 4443MasterCardCreditGB5454 5454 5454 5453MasterCardDebitGB6759 6498 2643 8450MaestroDebitGB4444 3333 2222 1111VisaCreditFR4462 0300 0000 0000VisaDebitIN4444 3333 2222 1112VisaCreditFR4462 0300 0000 0001VisaDebitFR

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 64.3% 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

Unknown

Total

1

Last Release

2844d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2192ee223fd8ab3871cb5e785be6ac2a8e771aa9c54cca2c80d094c6a1d1e807?d=identicon)[atlpay](/maintainers/atlpay)

---

Top Contributors

[![FinPayTech](https://avatars.githubusercontent.com/u/25129982?v=4)](https://github.com/FinPayTech "FinPayTech (9 commits)")[![think-ai](https://avatars.githubusercontent.com/u/54765200?v=4)](https://github.com/think-ai "think-ai (4 commits)")[![adisaf](https://avatars.githubusercontent.com/u/8885923?v=4)](https://github.com/adisaf "adisaf (1 commits)")

### Embed Badge

![Health badge](/badges/atlpay-php-sdk-v2/health.svg)

```
[![Health](https://phpackages.com/badges/atlpay-php-sdk-v2/health.svg)](https://phpackages.com/packages/atlpay-php-sdk-v2)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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