PHPackages                             paysuper/paysuper-analytics-lib-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. paysuper/paysuper-analytics-lib-php

ActiveLibrary

paysuper/paysuper-analytics-lib-php
===================================

Library for push stat message to Compayer from php-based projects

2.0.0(5y ago)1133proprietaryPHPPHP &gt;=5.5CI failing

Since Feb 20Pushed 5y ago6 watchersCompare

[ Source](https://github.com/paysuper/paysuper-analytics-lib-php)[ Packagist](https://packagist.org/packages/paysuper/paysuper-analytics-lib-php)[ Docs](https://compayer.com)[ RSS](/packages/paysuper-paysuper-analytics-lib-php/feed)WikiDiscussions master Synced today

READMEChangelog (6)Dependencies (4)Versions (10)Used By (0)

Compayer PHP SDK
================

[](#compayer-php-sdk)

[![Latest Stable Version](https://camo.githubusercontent.com/3f41896135b9db9bd5218a13ecaecbbb4372943053b5bcd87290f449e907b1b7/68747470733a2f2f706f7365722e707567782e6f72672f636f6d70617965722f636f6d70617965722d6c69622d7068702f762f737461626c652e706e67)](https://packagist.org/packages/compayer/compayer-lib-php)[![Build Status](https://camo.githubusercontent.com/ae07a957290639f60002c320bfe1f19f379724bc4feea8e67f6510f52fd4cb23/68747470733a2f2f7472617669732d63692e6f72672f636f6d70617965722f636f6d70617965722d6c69622d7068702e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/compayer/compayer-lib-php)[![Code Coverage](https://camo.githubusercontent.com/5591d19653f6abd80bd5e737e347c69430d67bc30c577b313dbd1a36dd7c48af/68747470733a2f2f636f6465636f762e696f2f67682f636f6d70617965722f636f6d70617965722d6c69622d7068702f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/compayer/compayer-lib-php)[![Downloads](https://camo.githubusercontent.com/493810906d24f8d0a46634ff5ec0828705dbd6d427782b7d5823491775ed2ab2/68747470733a2f2f706f7365722e707567782e6f72672f636f6d70617965722f636f6d70617965722d6c69622d7068702f642f746f74616c2e706e67)](https://packagist.org/packages/compayer/compayer-lib-php)[![GitHub license](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://raw.githubusercontent.com/compayer/compayer-lib-php/master/LICENSE)

Compayer is a stat data preprocessor and web analytics service that tracks customer events in payment forms for financial and marketing reports.

Compayer PHP SDK library is designed to push stat messages to the Compayer analytics from the php-based projects.

Features
--------

[](#features)

- Creates and sends the Events of start, success, failure or refund payments to the Compare analytics.
- Helps to convert a response message from payment systems Yandex.Money, Xsolla and PaySuper to the Event message.

---

Table of Contents
-----------------

[](#table-of-contents)

- [Requirements](#requirements)
- [Getting Started](#getting-started)
- [Installation](#installation)
- [Usage](#usage)

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

[](#requirements)

- PHP &gt;= 5.5
- Required PHP extensions: *json*

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

[](#getting-started)

Register your account in [Compayer](https://compayer.com) analytics to get:

- CLIENT ID (the unique identifier for your client)
- SECRET KEY (the secret API key for your client)

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

[](#installation)

We recommend installing Compayer PHP SDK using [Composer](http://getcomposer.org).

```
$ cd /path/to/your/project
$ composer require compayer/compayer-lib-php
```

After installing, you need to require the Composer's autoloader:

```
require '/path/to/vendor/autoload.php';
```

Usage
-----

[](#usage)

To use analytics you need to send 2 events:

- The Event `start` when a user initiates a payment. The `start` event is optional, but we strongly recommend using it to track the entire payment chain.
- One of the Events `success`, `fail` or `refund` after the payment system responds about the result of the operation.

The Event tries automatically determine the user IP address and address of the payment initiation page based on the data from the server request. If the user’s request is not available to the script, you can set the payment initiation page or user IP address by yourself (this is necessary for the geolocation filters to work correctly).

To send an Event `start`, use the following example:

```
use Compayer\SDK\Client;
use Compayer\SDK\Config;
use Compayer\SDK\Event;
use Compayer\SDK\Exceptions\SdkException;

const CLIENT_ID = 'client_id';
const SECRET_KEY = 'secret_key';

// Create and configure a configuration object (including debug mode).
$config = new Config(CLIENT_ID, SECRET_KEY);
$config->setDebugMode(true);

// Create an SDK client for sending events.
$client = new Client($config);

// Create an instance of the Event class and set the maximum possible properties about a user and payment.
// All fields are optional, but it's important to fill out one of the fields: "userEmails", "userPhones" or "userAccounts"
// to identify the user made the payment.
$event = (new Event())
    ->setMerchantTransactionId('12345')
    ->setPaymentAmount(250.50)
    ->setPaymentCurrency('RUB')
    ->setUserLang('RUS')
    ->setUserEmails(['customer@compayer.com'])
    ->setUserAccounts(['54321'])
    ->setExtra(['my_property' => 'value']);

// You can also create an object with an event from an array,
// where names of the keys of the array match names of the Event properties.
$event = Event::fromArray([
    'merchantTransactionId' => '12345',
    'paymentAmount' => 250.50,
    'paymentCurrency' => 'RUB',
    'userLang' => 'RUS',
    'userEmails' => ['customer@compayer.com'],
    'userAccounts' => ['54321'],
    'extra' => ['my_property' => 'value'],
]);

try {
    // Send the generated event and get the response message with a transaction identifier and log.
    $response = $client->pushStartEvent($event);
} catch (SdkException $e) {
    print_r($e->getMessage());
}

// Use it to send "success", "fail" or "refund" events and to chain events.
// The transaction identifier is UUID string like 3677eb06-1a9a-4b6c-9d6a-1799cae1b6bb.
$transactionId = $response->getTransactionId();

// Show logs with the debug mode configuration.
print_r($response->getLog());
```

After a payment system has received a response about a payment result (`success`, `failure` or `refund`), you need to send an Event with the data that you received after the payment. You can form the response event as described in the Event `start`. If you received a transaction ID at the start step, set it to link the entire payment chain.

For `success`, `failure` or `refund` events a payment system response is required in its original form. The response should be written as a string with the key "response" in the property `extra`.

For example, if the answer received in the JSON format then use the construct: `setPaymentSystemResponse(json_encode($jsonPaymentSystemResponse))`.

```
use Compayer\SDK\Client;
use Compayer\SDK\Config;
use Compayer\SDK\Event;
use Compayer\SDK\Exceptions\SdkException;

const CLIENT_ID = 'client_id';
const SECRET_KEY = 'secret_key';

// Create and configure a configuration object (e.g. with debug mode).
$config = new Config(CLIENT_ID, SECRET_KEY);
$config->setDebugMode(true);

// Create SDK client for sending events.
$client = new Client($config);

// Transaction ID received on start event
$transactionId = '3677eb06-1a9a-4b6c-9d6a-1799cae1b6bb';

// Create an instance of the Event class and set the maximum possible properties about the user and payment
// All fields are optional, but you must fill out one of the fields: "userEmails", "userPhones" or "userAccounts"
// to identify the user who made the payment. If you have a transaction ID for the start event, specify it.
$event = (new Event())
    ->setTransactionId($transactionId)
    ->setMerchantTransactionId('12345')
    ->setPaymentAmount(250.50)
    ->setPaymentCurrency('RUB')
    ->setPayoutAmount(3.87)
    ->setPayoutCurrency('USD')
    ->setUserEmails(['customer@compayer.com'])
    ->setUserAccounts(['54321'])
    ->setExtra(['my_property' => 'value'])
    ->setPaymentSystemResponse('Payment system response as a string');

try {
    // Send the generated event
    // Or use $client->pushFailEvent($event) in case of payment failure
    // Or use $client->pushRefundEvent($event) in case of payment refund
    $client->pushSuccessEvent($event);
} catch (SdkException $e) {
    print_r($e->getMessage());
}
```

License
-------

[](#license)

The project is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor2

2 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 ~23 days

Recently: every ~33 days

Total

7

Last Release

2131d ago

Major Versions

1.0.5 → 2.0.02020-07-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/06b2226e1d2d23114e319485c78354d5684a2705ec68a4297c2e6e4c45366476?d=identicon)[sidmal](/maintainers/sidmal)

---

Top Contributors

[![snezhana-dorogova](https://avatars.githubusercontent.com/u/11545763?v=4)](https://github.com/snezhana-dorogova "snezhana-dorogova (16 commits)")[![pr0head](https://avatars.githubusercontent.com/u/7290631?v=4)](https://github.com/pr0head "pr0head (14 commits)")[![sidmal](https://avatars.githubusercontent.com/u/6396428?v=4)](https://github.com/sidmal "sidmal (12 commits)")[![EvgeniyStrigo](https://avatars.githubusercontent.com/u/46960275?v=4)](https://github.com/EvgeniyStrigo "EvgeniyStrigo (3 commits)")[![atlix](https://avatars.githubusercontent.com/u/6659875?v=4)](https://github.com/atlix "atlix (1 commits)")[![misterion](https://avatars.githubusercontent.com/u/196737?v=4)](https://github.com/misterion "misterion (1 commits)")

---

Tags

analyticscompayersdk-php

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/paysuper-paysuper-analytics-lib-php/health.svg)

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.6k509.9M17.0k](/packages/laravel-framework)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M647](/packages/sylius-sylius)[google/cloud

Google Cloud Client Library

1.2k16.2M54](/packages/google-cloud)[laravel/vapor-cli

The Laravel Vapor CLI

31310.7M8](/packages/laravel-vapor-cli)[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[getdkan/dkan

DKAN Open Data Catalog

385135.4k2](/packages/getdkan-dkan)

PHPackages © 2026

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