mykholy/laravel-paymob

paymob integration for laravel

1.0.0 2023-01-03 17:06 UTC

This package is auto-updated.

Last update: 2024-10-30 01:43:04 UTC


README

Laravel PayMob
Latest Stable Version Total Downloads

Paymob integration for laravel.

Currently Supported

Installation

  • install the package

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

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

Config


Setup

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

    Route::group([
        'prefix'     => 'orders',
        'as'         => 'order.',
        'middleware' => 'auth',
    ], function () {
        mykholy\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 mykholy\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

# 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 mykholy@protonmail.com.