baselrabia / paymob
A Package to help with Paymob integration
Installs: 23
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/baselrabia/paymob
This package is auto-updated.
Last update: 2025-10-19 11:04:15 UTC
README
Laravel PayMob
Paymob integration for laravel.
Currently Supported
Installation
-
install the package
composer require baselrabia/paymob
-
publish the package assets with
php artisan vendor:publish --provider="Basel\PayMob\PayMobServiceProvider"
Config
- Update your
.envfile
ACCEPT_API_KEY= ACCEPT_MERCHANT_ID= ACCEPT_CARD_IFRAME_ID= ACCEPT_CARD_INTEGRATION_ID= ACCEPT_MW_INTEGRATION_ID=
Setup
-
add the package routes to your
routes/web.phpex.Route::group([ 'prefix' => 'orders', 'as' => 'order.', 'middleware' => 'auth', ], function () { Basel\PayMob\PayMobRoutes::routes(); }); // OR You Can Use your Own routes like this // I used the package in Apis to provide Payment with the mobile APP Route::group([ 'prefix' => 'payment', 'as' => 'order.', // 'middleware' => , ], function () { // ctf0\PayMob\PayMobRoutes::routes(); $controller = config('paymob.controller', '\Basel\PayMob\Controllers\DummyController'); // Route::get('checkout', [ // 'as' => 'checkout', // 'uses' => "$controller@checkOut", // ]); Route::post('process', [ 'as' => 'process', 'uses' => "$controller@process", ])->middleware(['auth:student', 'scopes:student']); Route::get('complete', [ 'as' => 'complete', 'uses' => "$controller@complete", ]); Route::get('failed', [ 'as' => 'failed', 'uses' => "$controller@failed", ]); } );
-
add
Billableto the model you will be billing. -
next add
getBillingData()which should return all the required fields for the order creation, check paymob requirements for more info.- all the optional fields has already been taken care of.
use Basel\PayMob\Integrations\Contracts\Billable; class Client implements Billable { // ... public function getBillingData(): array { return [ 'email' => $this->email, 'first_name' => $this->first_name, 'last_name' => $this->last_name, 'street' => $this->address ?? "NA", 'phone_number' => $this->phone_number, ]; } }
Usage
# Normal
-
update
controllerwith your own controller, which should have 3 methodsyou can check
DummyControllerOrApiDummyControllerfor a more detailed overview.type @method return GET checkOutreturns the view where the user will press the checkout btn POST processget the selected payment type & make a request to paymob server GET completecheck for the transaction hmac & save it to your server, for more info check. -
test Card
MasterCard
Key Value Card Number 2223000000000007 Cardholder Name Test Account Expiry Month 01 Expiry Year 39 CVV 100
# Refund
-
all you need to is to call
PayMob::refundand pass to it thetransaction_id&amount_in_poundsthat will be refunded, ex.for more info check
PayMob::refund(655, 10);