PHP code example of solidpay / php-client

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

    

solidpay / php-client example snippets




use Solidpay\Solidpay;

try {

$api_key = 'YOUR_KEY';
$merchant_id = 'YOUR_MERCHANT_ID';

$client = new Solidpay($api_key, $merchant_id);

$form = array(
    'order_id' => 'YOUR_TRANSACTION_ID',
    'currency' => 'gbp',
    'amount' => '100',
    'capture' => false,
    'return_url' => 'https://yourstore.com/success/123456'
);

$payments = $client->request->post('/payments/', $form);

$status = $payments->httpStatus();

if ($status == 200){
    $payments = $payments->asArray();
    $paymentUrl = $payments['url'];
    $paymentId = $payments['id'];
}

} catch (Exception $e) {
    
}

// Get all payments
$payments = $client->request->get('/payments');

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

// Refund payment
$form = array(
    'amount' => '100',
);

$payments = $client->request->post('/payments/{id}/refund', $form);

// Capture payment
$form = array(
    'amount' => '100',
);

$payments = $client->request->post('/payments/{id}/capture', $form);