ompay/paymentgateway

A PHP library for integrating with the Ompay payment gateway to process online payments.

v1.0.0 2025-06-17 09:24 UTC

This package is auto-updated.

Last update: 2025-06-17 10:09:28 UTC


README

Ompay Payment Gateway is a PHP library that provides an easy-to-use interface for interacting with the Ompay payment gateway API. This library allows you to create orders, check order statuses, and manage transactions securely and efficiently.

Installation

You can install the package via Composer. Run the following command:

composer require ompay/paymentgateway

Features

  • Order Management: Create and manage orders through Ompay.
  • Transaction Management: Handle transactions with ease.
  • Secure Authentication: Uses secure basic authentication for API requests.
  • System Information: Attaches system and server information to each request for better tracking and security.

Requirements

- PHP 8.2 or higher
- Composer
- cURL extension enabled
- Ompay API credentials (Client ID and Client Secret)

Usage

Initialization

require 'vendor/autoload.php';

use Ompay\OmpayPaymentGateway;
use Ompay\Resources\OrderAPI;

// Initialize the payment gateway
$clientId = 'your-client-id';
$clientSecret = 'your-client-secret';
$gateway = new OmpayPaymentGateway($clientId, $clientSecret);

// Initialize the OrderAPI
$orderAPI = new OrderAPI($gateway);

Creating an Order

$orderData = [
    'receiptId' => 'RE_YOURRECEIPT123',
    'amount' => 500, // Amount in smallest currency unit
    'currency' => 'INR',
    'description' => 'Test Payment',
    'customerFields' => [
        'name' => 'John Doe',
        'email' => 'john.doe@example.com',
        'phone' => '9876543210'
    ],
    'uiMode' => 'checkout'
];

try {
    $orderResponse = $orderAPI->createOrder($orderData);
    echo "Order Response: " . $orderResponse;
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}

Checking Order Status

try {
    $orderId = 'your-order-id'; // Replace with an actual order ID
    $statusResponse = $orderAPI->checkStatus($orderId);
    echo "Order Status: " . $statusResponse;
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}

Project Structure

src/
├── Config.php            # Contains API endpoints and configurations
├── OmpayPaymentGateway.php  # Handles HTTP requests
└── resources/
    ├── OrderAPI.php      # Methods for order operations
    └── TransactionAPI.php # Placeholder for future enhancements

Contributing

Contributions are welcome! Feel free to submit issues or pull requests to enhance the library.