PHP code example of paylike / php-api

1. Go to this page and download the library: Download paylike/php-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

paylike / php-api example snippets




$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();
$apps->create($args);
$apps->fetch();
 
$merchants = $paylike->merchants();
$merchants->create($args);
$merchants->fetch($merchant_id);
$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);
$merchants->lines()->add($merchant_id,$app_id);
$merchants->lines()->revoke($merchant_id,$app_id);
 
$cards = $paylike->cards();
$cards->create($merchant_id, $args);
$cards->fetch($card_id);
 
$transactions = $paylike->transactions();
$transactions->create($merchant_id, $args);
$transactions->fetch($transaction_id);
$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
    )
));

$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
}
bash
composer