Skip to content

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

License

Notifications You must be signed in to change notification settings

xahmedtaha/paybridge

Repository files navigation

PayBridge

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 protected]');
$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.

About

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

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages