PHP code example of payisland / payisland-php

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

    

payisland / payisland-php example snippets


use PayIsland\PayIsland;

$payIsland = new PayIsland([
    'secretKey' => getenv('PAYISLAND_SECRET_KEY'),
]);

$payIsland = new PayIsland([
    'secretKey' => getenv('PAYISLAND_SECRET_KEY'),
    'baseURL' => 'https://ags.payislands.com',
    'timeout' => 30,
]);

$response = $payIsland->transactions->initialize([
    'callback_url' => 'https://example.com/webhooks/payislands',
    'payment_item_id' => getenv('PAYISLAND_PAYMENT_ITEM_ID'),
    'transaction_reference' => 'order_' . time(),
    'channel' => 'card',
    'amount' => '1000',
    'customer_info' => [
        'email' => '[email protected]',
        'phone_number' => '08011112222',
        'first_name' => 'Ada',
        'last_name' => 'Lovelace',
    ],
]);

echo $response['data']['authorization_url'];

$response = $payIsland->transactions->verify('order_123');

$isValid = $payIsland->webhooks->verifySignature(
    $rawPayload,
    $signature,
    $webhookSecret
);

$payload = json_decode($rawPayload, true);
$verification = $payIsland->transactions->verify($payload['reference']);

use PayIsland\Exceptions\PayIslandApiException;

try {
    $response = $payIsland->transactions->verify('order_123');
} catch (PayIslandApiException $exception) {
    echo $exception->getStatusCode();
    print_r($exception->getResponseData());
}
bash
composer 
bash
php examples/initialize-payment.php
php examples/verify-payment.php order_123
php examples/webhook-verification.php