.NET SDK
Official package:
- Package:
PayIsland - Registry: NuGet
- GitHub: payisland-dotnet
Installation
dotnet add package PayIsland
Initialize a Transaction
using PayIsland;
var payIsland = new PayIslandClient(
Environment.GetEnvironmentVariable("PAYISLAND_SECRET_KEY")!
);
var response = await payIsland.Transactions.InitializeAsync(new Dictionary<string, object?>
{
["callback_url"] = "https://example.com/webhooks/payislands",
["payment_item_id"] = "6",
["transaction_reference"] = $"order_{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}",
["channel"] = "card",
["amount"] = "1000",
["customer_info"] = new Dictionary<string, object?>
{
["email"] = "ada@example.com",
["phone_number"] = "08011112222",
["first_name"] = "Ada",
["last_name"] = "Lovelace"
}
});
Console.WriteLine(response);
Redirect the customer to the returned data.authorization_url to complete payment.
Verify a Transaction
var verification = await payIsland.Transactions.VerifyAsync("order_12345");
var data = (Dictionary<string, object?>)verification["data"]!;
var status = data["payment_status"]?.ToString();
if (new[] { "paid", "successful", "success" }.Contains(status))
{
// Fulfill the order.
}
else if (new[] { "pending", "unpaid" }.Contains(status))
{
// 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
var isValid = payIsland.Webhooks.VerifySignature(
rawPayload,
signature,
Environment.GetEnvironmentVariable("PAYISLAND_WEBHOOK_SECRET")!
);
if (!isValid)
{
throw new InvalidOperationException("Invalid PayIsland webhook signature");
}
var verification = await payIsland.Transactions.VerifyAsync(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.