A versatile laravel package providing a consistent and easy-to-use interface for integrating with multiple payment gateways.
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"
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',
//];
composer test
Please see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.