PHP SDK
Official package:
- Package:
payisland/payisland-php - Registry: Packagist
- GitHub: payisland-php
Installation
composer require payisland/payisland-php
Initialize a Transaction
use PayIsland\PayIsland;
$payIsland = new PayIsland([
'secretKey' => getenv('PAYISLAND_SECRET_KEY'),
]);
$response = $payIsland->transactions->initialize([
'callback_url' => 'https://example.com/webhooks/payislands',
'payment_item_id' => '6',
'transaction_reference' => 'order_' . time(),
'channel' => 'card',
'amount' => '1000',
'customer_info' => [
'email' => 'ada@example.com',
'phone_number' => '08011112222',
'first_name' => 'Ada',
'last_name' => 'Lovelace',
],
]);
echo $response['data']['authorization_url'];
Redirect the customer to $response['data']['authorization_url'] to complete payment.
Verify a Transaction
$verification = $payIsland->transactions->verify('order_12345');
$status = $verification['data']['payment_status'];
if (in_array($status, ['paid', 'successful', 'success'], true)) {
// Fulfill the order.
} elseif (in_array($status, ['pending', 'unpaid'], true)) {
// Wait for completion and verify again later.
} else {
// Treat as failed or not completed.
}
The SDK calls:
GET /api/v1/transactions/in/check-transaction-status/{reference}
Webhook Signature Verification
$isValid = $payIsland->webhooks->verifySignature(
$rawPayload,
$signature,
getenv('PAYISLAND_WEBHOOK_SECRET')
);
if (!$isValid) {
throw new RuntimeException('Invalid PayIsland webhook signature');
}
$payload = json_decode($rawPayload, true);
$verification = $payIsland->transactions->verify($payload['reference']);
Verify the transaction reference before fulfilling, even after a valid webhook signature.
Notes
- Use
PAYISLAND_SECRET_KEYonly on the server. - PayIsland chooses sandbox or live mode from the API key.
- The default API base URL is
https://ags.payislands.com. - Amounts are strings in the major currency unit.
"1000"means NGN 1,000.