Laravel v10 PayMob online payment gateway package
engalirock/laravel-paymob is a Laravel package for laravel v10 paymob online payment gateway package.
It currently has 0 GitHub stars and 25 downloads on Packagist (latest version 5.2).
Install it with composer require engalirock/laravel-paymob.
Discover more Laravel packages by engalirock
or browse all Laravel packages to compare alternatives.
Last updated
A modern, lightweight Laravel package for integrating PayMob (Accept) Payment Gateway in Egypt and other supported regions. Fully compatible with Laravel 10+ and PHP 8.2+.
PayMobController template for callbacks.You can install the package via Composer:
composer require engalirock/laravel-paymob
[!NOTE] Laravel 10+ supports package auto-discovery, so you do not need to add the ServiceProvider or Facade manually to your
config/app.php.
If you are running an older setup or want to register it manually:
In config/app.php:
'providers' => [
...
engalirock\PayMob\PayMobServiceProvider::class,
...
];
'aliases' => [
...
'PayMob' => engalirock\PayMob\Facades\PayMob::class,
...
];
Publish the config file using:
php artisan vendor:publish --provider="engalirock\PayMob\PayMobServiceProvider"
This will create a config/paymob.php file. Fill in your credentials:
return [
'username' => env('PAYMOB_USERNAME', ''),
'password' => env('PAYMOB_PASSWORD', ''),
'api_key' => env('PAYMOB_API_KEY', ''),
'integration_id' => env('PAYMOB_INTEGRATION_ID', ''),
'iframe_id' => env('PAYMOB_IFRAME_ID', ''),
// IP resolution setting to bypass SSL Handshake Issues (Default: force IPv4)
'ip_resolve' => defined('CURL_IPRESOLVE_V4') ? CURL_IPRESOLVE_V4 : 1,
];
Make sure to set up your Processed Callback and Response Callback URLs in your PayMob dashboard pointing to your application routes.
PayMob's new Intentions API simplifies payment flow integration by reducing multiple backend steps into a single intention.
use engalirock\PayMob\Facades\PayMob;
$auth = PayMob::authPaymob();
$token = $auth->token;
Use the intention method to build the payment request payload:
$data = [
'amount' => 15000, // Amount in cents/piasters (e.g. 150.00 EGP)
'currency' => 'EGP',
'payment_methods' => [12345, 67890], // Array of integration IDs (Card, Wallet, etc.)
'billing' => [
'email' => '[email protected]',
'first_name' => 'John',
'last_name' => 'Doe',
'phone_number' => '+201000000000',
'city' => 'Cairo',
'country' => 'EG',
],
'customer' => [
'first_name' => 'John',
'last_name' => 'Doe',
'email' => '[email protected]',
]
];
$intention = PayMob::intention($token, $data);
Generate the client checkout URL to redirect the user to the unified checkout page:
$checkoutUrl = PayMob::unifiedcheckout($publicKey, $intention->client_secret);
return redirect()->away($checkoutUrl);
$auth = PayMob::authPaymob();
$paymobOrder = PayMob::makeOrderPaymob(
$auth->token,
$auth->profile->id,
$order->totalCost * 100, // Total amount in cents
$order->id // Your order ID
);
$paymentKey = PayMob::getPaymentKeyPaymob(
$integrationId, // Card integration ID
$auth->token,
$order->totalCost * 100,
$paymobOrder->id,
$user->email,
$user->firstname,
$user->lastname,
$user->phone,
$city->name,
$country->name
);
Use the token from the payment key payload inside the iframe:
<iframe src="https://accept.paymob.com/api/acceptance/iframes/{{ config('paymob.iframe_id') }}?payment_token={{ $paymentKey->token }}"></iframe>
If a request fails, you can inspect the response status code, curl errors, and response headers:
use engalirock\PayMob\Facades\PayMob;
$response = PayMob::authPaymob();
if (!$response || isset($response->detail)) {
Log::error('PayMob Auth Failed', [
'http_code' => PayMob::last_http_code,
'curl_error' => PayMob::last_curl_error,
'headers' => PayMob::last_response_headers,
]);
}
A pre-built controller template PayMobController.php is published inside your app directory to handle response callbacks.
Update the processedCallback and invoice routes on your PayMob dashboard integration page.
Verify payment details using a PayMob order ID:
$inquiry = PayMob::transaction_inquiry($token, $orderId);
$orders = PayMob::getOrders($token, $page = 1);
$order = PayMob::getOrder($token, $orderId);
$transactions = PayMob::getTransactions($token, $page = 1);
$transaction = PayMob::getTransaction($token, $transactionId);
$capture = PayMob::capture($token, $transactionId, $amountCents);
Laravel PayMob is open-sourced software licensed under the MIT license.