PHPackages                             apcopay/apcopay\_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. apcopay/apcopay\_php

ActiveLibrary[API Development](/categories/api)

apcopay/apcopay\_php
====================

The ApcoPay PHP library provides the functionality to process transactions with the ApcoPay payment gateway.

v1.0.1(6y ago)12.1k↑321.2%MITPHP

Since Nov 7Pushed 4y ago1 watchersCompare

[ Source](https://github.com/ApcoPay/apcopay_php)[ Packagist](https://packagist.org/packages/apcopay/apcopay_php)[ Docs](https://www.apcopay.eu)[ RSS](/packages/apcopay-apcopay-php/feed)WikiDiscussions master Synced 2d ago

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

ApcoPay PHP library
===================

[](#apcopay-php-library)

The ApcoPay PHP library provides the functionality to process financial transactions with the [ApcoPay](https://www.apcopay.eu/) gateway.

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

[](#requirements)

- The PHP extension cURL is required.
- A merchant account with ApcoPay. Send an email to  to set up a merchant account.

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

[](#installation)

The recommended method of installation is via [Packagist](https://packagist.org/) and [Composer](https://getcomposer.org/). Run the following command to install the package and add it as a requirement to your project's `composer.json`:

```
composer require apcopay/apcopay_php
```

Alternatively, the ApcoPay PHP library can also be used by copying the contents of this repository in the project folder and using PHP require on the files as shown [below](#PHP-require).

Description
-----------

[](#description)

The ApcoPay PHP library

### File loading

[](#file-loading)

The ApcoPay PHP library files can be loaded with the following options:

#### Composer autoloading

[](#composer-autoloading)

For more information about composer autoloading go to

> Skip this step if you already have composer autoloading set up

```
require __DIR__ . '/vendor/autoload.php';
```

#### PHP require

[](#php-require)

```
require __DIR__ . '/apcopay_php/src/ApcoPayGateway.php';
require __DIR__ . '/apcopay_php/src/Configuration.php';
require __DIR__ . '/apcopay_php/src/TransactionType.php';
require __DIR__ . '/apcopay_php/src/TransactionRequest.php';
require __DIR__ . '/apcopay_php/src/TransactionResponse.php';
require __DIR__ . '/apcopay_php/src/NotificationRequest.php';
require __DIR__ . '/apcopay_php/src/RedirectRequest.php';
```

### Initialization

[](#initialization)

The ApcoPayGateway configuration requires the following 5 parameters:

- Merchant id - The merchant id/code with ApcoPay
- Merchant password - The merchant password with ApcoPay
- Hashing secret - The hashing secret word with ApcoPay
- Notification url - The url that transaction status notifications are sent to. Should be processed as shown in the [notification request example](#Notification-request) below.
- Redirection url - The url the user is redirected to after a 3DS payment. Should be processed as shown in the [redirect request example](#Redirect-request) below.

#### Initialise ApcoPayGateway example

[](#initialise-apcopaygateway-example)

```
$gateway = new ApcoPay\ApcoPayGateway(
    new ApcoPay\Configuration(
        "1234",
        "dfnu2345b2354vbu",
        "3ui423ui4",
        "https://merchanturl.com/apcopay/notification",
        "https://merchanturl.com/apcopay/redirect"
    )
);
```

### Process transaction

[](#process-transaction)

#### TransactionRequest

[](#transactionrequest)

- `amount`
- `currency_code` - ISO 4217 numeric code
- `transaction_type` - Numeric code as defined [TransactionType](#Transaction-types) class
- `order_reference` - Merchant order reference. Must not contain ||
- `card_number`
- `card_cvv`
- `card_holder`
- `card_expiry_month`
- `card_expiry_year`
- `user_ip`
- `original_transaction_id` - The id of a prior transaction
- `user_defined_function` - Must not contain ||

##### TransactionRequest mandatory fields

[](#transactionrequest-mandatory-fields)

amountcurrency\_codetransaction\_typeorder\_referencecard\_numbercard\_cvvcard\_holdercard\_expiry\_monthcard\_expiry\_yearuser\_iporiginal\_transaction\_iduser\_defined\_functionPurchase**Mandatory****Mandatory****Mandatory**Recommended**Mandatory**Recommended**Mandatory****Mandatory****Mandatory**Void Purchase**Mandatory**Recommended**Mandatory**Authorisation**Mandatory****Mandatory****Mandatory**Recommended**Mandatory**Recommended**Mandatory****Mandatory****Mandatory**Capture**Mandatory****Mandatory****Mandatory**Recommended**Mandatory****Mandatory**Void Credit**Mandatory**Recommended**Mandatory**Void Capture**Mandatory**Recommended**Mandatory**Void Authorisation**Mandatory**Recommended**Mandatory**Repeat Purchase**Mandatory**Recommended**Mandatory**Partial Refund**Mandatory**Recommended**Mandatory**Original Credit**Mandatory**Recommended**Mandatory**Repeat Authorisation**Mandatory**Recommended**Mandatory**#### TransactionResponse

[](#transactionresponse)

- `result` - Transaction result indicating the status of the transaction
- `psp_id` - Id of the transaction from the ApcoPay gateway
- `bank_transaction_id` - Id of the transaction from the bank
- `date` - Date of transaction. Format: yyyyMMdd
- `time` - Time of transaction. Format: HHmmss
- `acquirer_reference`
- `authorization_code`
- `address_verification_response`
- `acquirer_code` - Processing bank code
- `user_ip`
- `user_defined_function`
- `extra_data`
- `card_country` - Card issuing country

#### Result codes

[](#result-codes)

Accepted transactions can have one of the following results:

- APPROVED
- CAPTURED
- VOIDED
- ENROLLED (Only Used when the Card is 3Dsecure Enrolled and needs verification with Visa/MasterCard)

Declined transaction results will vary between banks

#### Process transaction example

[](#process-transaction-example)

```
$transactionRequest = new ApcoPay\TransactionRequest();
$transactionRequest->amount = "2.40";
$transactionRequest->currency_code = "978";
$transactionRequest->order_reference = "1234";
$transactionRequest->transaction_type = ApcoPay\TransactionType::Purchase;

$transactionRequest->card_number = "4444444444444444";
$transactionRequest->card_cvv = "123";
$transactionRequest->card_holder = "John Doe";
$transactionRequest->card_expiry_month = "12";
$transactionRequest->card_expiry_year = "2023";

$transactionResponse = $gateway->processTransaction($transactionRequest);

if ($transactionResponse->result === "CAPTURED" || $transactionResponse->result === "APPROVED" || $transactionResponse->result === "VOIDED") {
    // Transaction successful
} else if ($transactionResponse->result == 'ENROLLED') {
    $redirectUrl = "https://www.apsp.biz/pay/3DSFP2/verify.aspx?id=" . $transactionResponse->psp_id;
    // Redirect to $redirectUrl
} else {
    // Transaction failed
}
```

### Notification request

[](#notification-request)

> **Note:** The notification response should always return HTTP status code 200 with content OK

#### Notification request example

[](#notification-request-example)

```
$request = $_POST["params"];
$request = urldecode($request);
if (!$gateway->verify($request)) {
    die("Hash mismatch");
    return;
}
$notificationRequest = $gateway->parseNotification($request);
if ($notificationRequest->result === "OK") {
    // TODO: update order to successful
} else {
    // TODO: update order to declined
}
echo 'OK';
header("HTTP/1.1 200 OK");
```

### Redirect request

[](#redirect-request)

#### Redirect request example

[](#redirect-request-example)

```
$request = $_GET["params"];
$request = str_replace("\\\"", "\"", $request);
if (!$gateway->verify($request)) {
    die("Hash mismatch");
    return;
}
$redirectRequest = $gateway->parseRedirect($request);
if ($redirectRequest->result === "OK") {
    echo 'Transaction successful';
    echo 'Order reference: ' . $redirectRequest->order_reference . '';
} else {
    echo 'Transaction failed';
    echo 'Order reference: ' . $redirectRequest->order_reference . '';
    echo 'Result: ' . $redirectRequest->result . '';
}
```

Process flow
------------

[](#process-flow)

### Normal transaction flow

[](#normal-transaction-flow)

[![Normal transaction flow](images/flow_normal_transaction.png)](images/flow_normal_transaction.png)

### 3DS transaction flow

[](#3ds-transaction-flow)

1. The Apco Pay web service will verify whether the card submitted is 3Dsecure ENROLLED

    1. If the card is not enrolled for 3ds, the web service will return a normal response described in the previous section
    2. If the card is enrolled the client needs to be redirected to the verification page  Where Id needs to be replaced with the value that was returned in the first response
2. The Client must continue the verification and submit his PIN
3. After a successful verification the client is redirected the redirection\_url in the configuration

[![3DS transaction flow](images/flow_3ds_transaction.png)](images/flow_3ds_transaction.png)

### Reference transaction flow

[](#reference-transaction-flow)

[![Reference transaction flow](images/flow_reference_transaction.png)](images/flow_reference_transaction.png)

Transaction types
-----------------

[](#transaction-types)

NameValueDescriptionPurchase1Transfers value from the cardholders accountVoid Purchase3Cancellation of a purchase transaction – Before end of dayAuthorisation4Reserve the specified value from the card holderCapture5Transfers a reserved value from the cardholders accountVoid Credit6Cancel a credit - Before end of dayVoid Capture7Cancel a capture - Before end of dayVoid Authorisation9Cancel an authorization - Before end of dayRepeat Purchase11Repeats a purchase by submitting the original PSPIDPartial Refund12Reverse a partial/full amount of the original transactionOriginal Credit13Pay out an amount greater than the amount of the original transactionRepeat Authorisation14Repeats an authorization by submitting the original PSPID### Transaction types in detail

[](#transaction-types-in-detail)

#### Authorisation

[](#authorisation)

Authorisation - Authorisation is the first part of a two-step process

If approved, the requested amount is reserved from the credit limit of the submitted card. The reservation process is therefore used if the capturing is to be completed at a later date.

**Important** - The authorisation (reservation) period is approx. 7 days for credit cards and 3 days for debit cards (we recommend that you check with the bank being used). Once the reservation period has expired, it is no longer possible to capture this transaction.

#### Capture

[](#capture)

Capturing is the second step of the two-step process mentioned above. A capture transaction must be preceded by an "Authorisation" transaction.

The amount to be captured must be less than or equal to the authorized amount. This also means, that partial amounts can be captured.

During the capture, an amount is debited from the customer account and credited to the merchant account.

#### Purchase

[](#purchase)

Purchase is a payment transaction done in a single step.

The purchase transaction handles both an authorisation and a capture at the same time.

If approved, the requested amount is debited from the customer account and credited to the merchant account.

#### Partial Refund

[](#partial-refund)

Refunds are transactions that return the payments to the customer. The refunded amount can be a part of the paid amount or the full paid amount. Refunds can relate to an existing Capture or to a Purchase. In the case of credit card payments, refunds are credited to your customer's credit card account.

**Important** - Refunds are not allowed for gaming merchants.

#### Original Credit

[](#original-credit)

The original credit is used to pay out an amount greater than the amount of the original transaction.

#### Void Purchase, Void Credit, Void Capture and Void Authorisation

[](#void-purchase-void-credit-void-capture-and-void-authorisation)

If a Void request is executed by 23:59 (bank’s time zone) of the original transaction date - the acquirer would be able to cancel this transaction.

Testing
-------

[](#testing)

Card NumberExpiry DateCVVNormal successful transaction4444 4444 4444 444412/yy where yy is the current year444Rejected normal transaction5555 5555 5555 555712/yy where yy is the current year444Successful 3DS transaction4444 4444 4444 222812/yy where yy is the current year444License
-------

[](#license)

The ApcoPay PHP library is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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 ~0 days

Total

2

Last Release

2431d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b38a20e04564c164b2ace35b5440d6db9abc9b5429e34ef51704319cc73aa5c0?d=identicon)[apcoadriancamilleri](/maintainers/apcoadriancamilleri)

---

Top Contributors

[![apcoadriancamilleri](https://avatars.githubusercontent.com/u/57354354?v=4)](https://github.com/apcoadriancamilleri "apcoadriancamilleri (1 commits)")

---

Tags

apilibrarypaymentintegrationcheckoutpayment gatewaycredit-cardapcopay

### Embed Badge

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

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

###  Alternatives

[checkout/checkout-sdk-php

Checkout.com SDK for PHP

563.6M13](/packages/checkout-checkout-sdk-php)

PHPackages © 2026

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