PHP SDK

Integrate Noxipay into your PHP applications

PHP SDK Installation

The Noxipay PHP SDK provides a simple interface for integrating payment processing into your PHP applications.

Installation via Composer

Terminal
composer require noxipay/noxipay-php

Basic Usage

PHP Code
<?php require_once 'vendor/autoload.php'; use Noxipay\Noxipay; // Initialize the client $noxipay = new Noxipay('pk_live_your_api_key_here'); // Create a payment $payment = $noxipay->payments()->create([ 'amount' => 2500, 'currency' => 'EUR', 'description' => 'Payment for order #123', 'redirect_url' => 'https://yoursite.com/success' ]); echo $payment->payment_url;

Payment Methods

Create Payment

PHP Code
$payment = $noxipay->payments()->create([ 'amount' => 2500, 'currency' => 'EUR', 'description' => 'Payment for order #123', 'customer' => [ 'email' => 'customer@example.com', 'name' => 'John Doe' ], 'redirect_url' => 'https://yoursite.com/success' ]);

Get Payment

PHP Code
$payment = $noxipay->payments()->get('pay_1234567890');

List Payments

PHP Code
$payments = $noxipay->payments()->list([ 'limit' => 10, 'status' => 'completed' ]);

Error Handling

PHP Code
try { $payment = $noxipay->payments()->create($data); } catch (Noxipay\Exception\ApiException $e) { echo "API Error: " . $e->getMessage(); } catch (Noxipay\Exception\InvalidRequestException $e) { echo "Invalid Request: " . $e->getMessage(); }

Webhooks

Handle webhook notifications in your PHP application:

PHP Code
$payload = file_get_contents('php://input'); $signature = $_SERVER['HTTP_X_NOXIPAY_SIGNATURE']; if ($noxipay->webhooks()->verify($payload, $signature)) { $event = json_decode($payload, true); if ($event['type'] === 'payment.completed') { // Handle successful payment $paymentId = $event['data']['id']; // Update your database, send confirmation email, etc. } }