Skip to main content

Overview

The Navio PHP SDK provides a modern, type-safe interface for integrating Navio payments into your PHP applications. Built with PHP 8.1+ features and best practices.

Type Safe

Full PHP 8.1+ type hints and return types

Composer Ready

PSR-4 autoloading and easy installation

Simple API

Clean, intuitive interface

Error Handling

Custom exceptions for different error types

Requirements

  • PHP 8.1 or higher
  • Composer
  • ext-json extension
  • ext-curl extension

Installation

Install via Composer:
Or add to your composer.json:

Quick Start

1. Initialize SDK

Store your API key in environment variables, never in code

3. Check Payment Status

Complete E-commerce Example

Here’s a complete flow for an e-commerce checkout:

Background Job for Status Polling

Set up a cron job or background worker:
Add to crontab:

API Reference

OCPay Class

Main SDK entry point.

Constructor

Parameters:
  • $accessToken: Your API access token
  • $options: Optional Guzzle client configuration
    • timeout: Request timeout in seconds (default: 30)

Methods

createLink(CreateLinkRequest $request): CreateLinkResponse Creates a payment link. checkPayment(string $paymentRef): CheckPaymentResponse Checks payment status.

Data Transfer Objects (DTOs)

ProductInfo

CreateLinkRequest

Fee Mode Constants:
  • CreateLinkRequest::FEE_MODE_NO_FEE - Merchant pays (default)
  • CreateLinkRequest::FEE_MODE_SPLIT_FEE - 50/50 split
  • CreateLinkRequest::FEE_MODE_CUSTOMER_FEE - Customer pays

CreateLinkResponse

CheckPaymentResponse

Exception Handling

All exceptions extend OCPayException: All exceptions provide:

Important Notes

Merchant Validation Required

Complete merchant validation at app.oneclickdz.com before using the API

Amount Limits

  • Minimum: 500 DZD
  • Maximum: 500,000 DZD
  • Must be whole numbers (integers)

Fee Structure

Low Fees: 0% on balance, only 1% withdrawal fee
Links expire 20 minutes after creation if payment not initiated.

Payment Status Flow

  1. PENDING - Payment in progress → Poll again later
  2. CONFIRMED - Payment successful → Fulfill order
  3. FAILED - Payment declined/expired → Mark order failed

Laravel Integration

For Laravel projects, see the complete integration example in the GitHub repository. Includes:
  • Service provider setup
  • Payment service class
  • Controller examples
  • Database migrations
  • Background job for polling
  • Error handling

Testing

Using Sandbox

The API automatically uses sandbox mode for test accounts:

Unit Tests

Best Practices

Store paymentRef immediately after creating the link. You need it to check payment status.
Set up a background job to check payment status every 20 minutes for pending orders.
Catch and handle all exception types appropriately. Log errors for debugging.
Store API keys in environment variables, never commit them to version control.
Always use HTTPS for redirect URLs and your application endpoints.

Support & Resources

GitHub Repository

Source code, examples, and issues

API Documentation

Detailed API reference

Laravel Example

Complete Laravel integration

Contact Support

Get help from our team

Next Steps

Navio Best Practices

Learn production-ready tips and security best practices