PHP code example of baselrabia / paymob

1. Go to this page and download the library: Download baselrabia/paymob library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

baselrabia / paymob example snippets


  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",
            ]);
        }
    );

  

  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,
          ];
      }
  }
  

  PayMob::refund(655, 10);
  
shell
  php artisan vendor:publish --provider="Basel\PayMob\PayMobServiceProvider"