xahmedtaha/paybridge

A versatile laravel package providing a consistent and easy-to-use interface for integrating with multiple payment gateways.

v0.1.3 2024-09-15 11:29 UTC

This package is auto-updated.

Last update: 2025-06-16 21:02:30 UTC


README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

A versatile laravel package providing a consistent and easy-to-use interface for integrating with multiple payment gateways.

Installation

You can install the package via composer:

composer require xahmedtaha/paybridge

You can publish the config file with:

php artisan vendor:publish --tag="paybridge-config"

Usage

You should typically use the package as follows:

use AhmedTaha\PayBridge\Data\ChargeData;
use AhmedTaha\PayBridge\Data\CustomerData;
use AhmedTaha\PayBridge\Data\Payment\CreditCardData;
use AhmedTaha\PayBridge\Enums\PaymentEnvironment;
use AhmedTaha\PayBridge\Enums\PaymentGateway;

$charge = new ChargeData('charge ID', 200, 'USD');
$customer = new CustomerData('customer ID', 'Ahmed', 'phone', 'email@test.com');
$paymentData = new CreditCardData('1234 1234 1234 1234', '24', '05', '123');

$result = PayBridge::setEnvironment(PaymentEnvironment::TESTING)
    ->gateway(PaymentGateway::FawryPay)
    ->pay($charge, $customer, $paymentData);

// $result = [
//  'success' => true,
//  'status' => PaymentStatus::PENDING,
//  'shouldRedirect' => true,
//  'redirectUrl' => 'fawry gateway url...',
//];

A callback url should be defined in the config files. Here is how the code for this route should typically be:

use PayBridge;
use AhmedTaha\PayBridge\Enums\PaymentGateway;
use AhmedTaha\PayBridge\Enums\PaymentEnvironment;
use Illuminate\Http\Request;

public function callbackRouteHandler(Request $request) {
    $result = PayBridge::setEnvironment(PaymentEnvironment::TESTING)
    ->gateway(PaymentGateway::FawryPay)
    ->callback($request);
    // Your additional app logic...
}

// $result = [
//  'success' => true,
//  'status' => PaymentStatus::PAID,
//  'charge' => ChargeData object,
//  'customer' => CustomerData object,
//  'referenceNumber' => 'fawry ref no',
//];

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.