This package is abandoned and no longer maintained. No replacement package was suggested.

PHP SDK to communicate with the Paylike HTTP API

2.0.0 2023-02-15 10:07 UTC

This package is auto-updated.

Last update: 2024-04-29 10:56:49 UTC


Paylike client (PHP)

You can sign up for a Paylike account at

Getting an API key

An API key can be obtained by creating a merchant and adding an app through Paylike dashboard.


PHP 5.3.3 and later.


You can install the package via Composer. Run the following command:

composer require paylike/php-api

If you don't use Composer, you can download the latest release and include the init.php file.



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

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.
If you don't want to use curl, you can create your own client to extend from HttpClientInterface and send that as a parameter when instantiating the Paylike class.


$paylike = new \Paylike\Paylike($private_api_key);
// fetch a card
$cards = $paylike->cards();
$card  = $cards->fetch($card_id);
// capture a transaction
$transactions = $paylike->transactions();
$transaction  = $transactions->capture($transaction_id, array(
    'amount'   => 100,
    'currency' => 'EUR'


$paylike = new \Paylike\Paylike($private_api_key);
$apps = $paylike->apps();
$merchants = $paylike->merchants();
$merchants->update($merchant_id, $args);
$all_merchants = $merchants->find($app_id,$args);
$some_merchants = $merchants->before($app_id,$before);
$some_merchants = $merchants->after($app_id,$before);
$all_lines = $merchants->lines()->find($merchant_id,$args);
$some_lines = $merchants->lines()->before($merchant_id,$before);
$some_lines = $merchants->lines()->after($merchant_id, $after);
$all_apps = $merchants->apps()->find($merchant_id,$args);
$cards = $paylike->cards();
$cards->create($merchant_id, $args);
$transactions = $paylike->transactions();
$transactions->create($merchant_id, $args);
$transactions->capture($transaction_id, $args);
$transactions->void($transaction_id, $args);
$transactions->refund($transaction_id, $args);
$all_transactions = $transactions->find($merchant_id,$args);
$some_transactions = $transactions->before($merchant_id,$before);
$some_transactions = $transactions->after($merchant_id,$before);

// explicit args
$limit = 10;
$after = '5b8e839d7cc76f04ecd3f733';
$before = '5b98deef882cf804f6108700';
$api_transactions = $transactions->find($merchant_id, array(
    'limit' => $limit,
    'after' => $after,
    'before' => $before,
    'filter' => array(
    	'successful' => true


The methods that return multiple merchants/transactions (find,after,before) use cursors, so you don't need to worry about pagination, you can access any index, or iterate all the items, this is handled in the background.

Error handling

The api wrapper will throw errors when things do not fly. All errors inherit from ApiException. A very verbose example of catching all types of errors:

$paylike = new \Paylike\Paylike($private_api_key);
try {
    $transactions = $paylike->transactions();
    $transactions->capture($transaction_id, array(
        'amount'   => 100,
        'currency' => 'EUR'
} catch (\Paylike\Exception\NotFound $e) {
    // The transaction was not found
} catch (\Paylike\Exception\InvalidRequest $e) {
    // Bad (invalid) request - see $e->getJsonBody() for the error
} catch (\Paylike\Exception\Forbidden $e) {
    // You are correctly authenticated but do not have access.
} catch (\Paylike\Exception\Unauthorized $e) {
    // You need to provide credentials (an app's API key)
} catch (\Paylike\Exception\Conflict $e) {
    // Everything you submitted was fine at the time of validation, but something changed in the meantime and came into conflict with this (e.g. double-capture).
} catch (\Paylike\Exception\ApiConnection $e) {
    // Network error on connecting via cURL
} catch (\Paylike\Exception\ApiException $e) {
    // Unknown api error

In most cases catching NotFound and InvalidRequest as client errors and logging ApiException would suffice.


Install dependencies:

composer install


Install dependencies as mentioned above (which will resolve PHPUnit), then you can run the test suite: