Skip to main content
This SDK is coming soon. Subscribe to our changelog to be notified when it’s released.
The official PHP SDK for FYATU API v3, compatible with Laravel, Symfony, and vanilla PHP.

Requirements

  • PHP 8.1 or higher
  • Composer

Installation

composer require fyatu/sdk

Quick Start

<?php

use Fyatu\Sdk\Fyatu;

$fyatu = new Fyatu([
    'appId' => 'your_app_id',
    'secretKey' => 'your_secret_key',
]);

// Create a collection
$collection = $fyatu->collections->create([
    'amount' => 10.00,
    'currency' => 'USD',
    'reference' => 'order_123',
    'description' => 'Payment for Order #123',
    'customer' => [
        'email' => '[email protected]',
        'name' => 'John Doe',
    ],
    'redirectUrl' => 'https://yoursite.com/payment/success',
    'webhookUrl' => 'https://yoursite.com/webhooks/fyatu',
]);

echo $collection->checkoutUrl;

Laravel Integration

Service Provider

Add the service provider to your config/app.php:
'providers' => [
    // ...
    Fyatu\Sdk\Laravel\FyatuServiceProvider::class,
],

Configuration

Publish the configuration file:
php artisan vendor:publish --provider="Fyatu\Sdk\Laravel\FyatuServiceProvider"
Add to your .env:
FYATU_APP_ID=your_app_id
FYATU_SECRET_KEY=your_secret_key

Usage with Facade

use Fyatu\Sdk\Laravel\Facades\Fyatu;

$collection = Fyatu::collections()->create([
    'amount' => 10.00,
    'currency' => 'USD',
    'reference' => 'order_123',
]);

Features

  • PHP 8.1+ Support - Modern PHP with full type declarations
  • Framework Agnostic - Works with any PHP framework
  • Laravel Integration - First-class Laravel support with Facade
  • Automatic Token Management - Handles JWT refresh automatically
  • PSR-18 Compatible - Use your preferred HTTP client

Configuration Options

$fyatu = new Fyatu([
    'appId' => 'your_app_id',
    'secretKey' => 'your_secret_key',

    // Optional configuration
    'baseUrl' => 'https://api.fyatu.com/api/v3',
    'timeout' => 30,
    'retries' => 3,
]);

Available Services

ServiceDescription
$fyatu->collectionsAccept payments via checkout
$fyatu->refundsManage refunds
$fyatu->payoutsSend money to recipients
$fyatu->cardholdersManage cardholders
$fyatu->cardsIssue and manage virtual cards
$fyatu->esimPurchase and manage eSIMs
$fyatu->accountAccess account information

Error Handling

use Fyatu\Sdk\Exceptions\FyatuException;
use Fyatu\Sdk\Exceptions\ValidationException;
use Fyatu\Sdk\Exceptions\AuthenticationException;

try {
    $payout = $fyatu->payouts->create([
        'amount' => 100,
        'currency' => 'USD',
        'recipientId' => 'invalid_id',
    ]);
} catch (ValidationException $e) {
    echo "Validation failed: " . print_r($e->getDetails(), true);
} catch (AuthenticationException $e) {
    echo "Authentication failed: " . $e->getMessage();
} catch (FyatuException $e) {
    echo "API error [{$e->getErrorCode()}]: " . $e->getMessage();
}

Webhook Verification

use Fyatu\Sdk\Webhook;

// Verify webhook signature
$payload = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_FYATU_SIGNATURE'] ?? '';

$isValid = Webhook::verifySignature(
    $payload,
    $signature,
    'your_webhook_secret'
);

if (!$isValid) {
    http_response_code(401);
    exit('Invalid signature');
}

$event = json_decode($payload, true);
echo "Received event: " . $event['type'];

Resources