PHP code example of quickpay / quickpay-php-client

1. Go to this page and download the library: Download quickpay/quickpay-php-client 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/ */

    

quickpay / quickpay-php-client example snippets

8

use QuickPay\QuickPay;

try {
    $client = new QuickPay();
} catch (Exception $e) {
    //...
}
8

use QuickPay\QuickPay;

try {
    $api_key = 'xxx';
    $client = new QuickPay(":{$api_key}");
} catch (Exception $e) {
    //...
}
8

use QuickPay\QuickPay;

try {
    $qp_username = 'xxx';
    $qp_password = 'xxx';
    $client = new QuickPay("{$qp_username}:{$qp_password}");
} catch (Exception $e) {
    //...
}
8
// Get all payments
$payments = $client->request->get('/payments');

// Get specific payment
$payments = $client->request->get('/payments/{id}');

// Create payment
$form = array(
    'order_id' => $order_id,
    'currency' => $currency,
    ...
);
$payments = $client->request->post('/payments', $form);
$status = $payments->httpStatus();
if ($status == 201) {
    // Successful created
}

8
$response = $client->request->get('/payments');
$status = $response->httpStatus();

if ($status == 200) {
    // Successful request
}
8
// Get the HTTP status code, headers and raw response body.
list($status_code, $headers, $response_body) = $client->request->get('/payments')->asRaw();

// Get the response body as an object
$response_body = $client->request->get('/payments')->asObject();

// Get the response body as an array
$response_body = $client->request->get('/payments')->asArray();

// Example usage
$payments = $client->request->get('/payments')->asArray();

foreach($payments as $payment) {
    //...
}

8
QuickPayAPI::$timeout = 30;
QuickPayAPI::$onTimeout ??= function () {
    event(new PaymentGatewayTimeout($this));

    throw new TimeoutException("No response from Quickpay within " . QuickPayAPI::$timeout . " seconds");
};

{
    "  "quickpay/quickpay-php-client": "2.0.*"
    }
}