Skip to content

AQuadic/laravel-paymob

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel PayMob
Latest Stable Version Total Downloads

Paymob integration for laravel.

Currently Supported

Installation

  • install the package

    composer require ctf0/laravel-paymob
  • publish the package assets with

    php artisan vendor:publish --provider="ctf0\PayMob\PayMobServiceProvider"

Config


Setup

  • add the package routes to your routes/web.php ex.

    Route::group([
        'prefix'     => 'orders',
        'as'         => 'order.',
        'middleware' => 'auth',
    ], function () {
        ctf0\PayMob\PayMobRoutes::routes();
    });
  • add Billable to 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 Illuminate\Database\Eloquent\Model;
    use ctf0\PayMob\Integrations\Contracts\Billable;
    
    class Client extends Model implements Billable
    {
        // ...
    
        public function getBillingData(): array
        {
            return [
                'email'        => $this->email,
                'first_name'   => $this->first_name,
                'last_name'    => $this->last_name,
                'street'       => $this->address,
                'phone_number' => $this->phone_number,
            ];
        }
    }

Usage

# Normal

  • update paymob.controller with your own controller, which should have 3 methods

    you can check DummyController for a more detailed overview.

    type @method return
    GET checkOut returns the view where the user will press the checkout btn
    POST process get the selected payment type & make a request to paymob server
    GET complete check for the transaction hmac & save it to your server, for more info check.

# Refund

  • all you need to is to call PayMob::refund and pass to it the transaction_id & amount_in_pounds that will be refunded, ex.

    for more info check

    PayMob::refund(655, 10);

Security

If you discover any security-related issues, please email [email protected].

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 96.8%
  • Blade 3.2%