1. Go to this page and download the library: Download mgamal/paymob-laravel 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/ */
mgamal / paymob-laravel example snippets
use MG\Paymob\Paymob;
public function checkout(){
// Prepare order items
$orderItems = [
[
'name' => 'Product x',
'amount_cents' => 100,
'description' => 'Product description',
'quantity' => 1
]
];
// Prepare billing data: Fill empty keys with 'N/A'; => 'N/A',
'shipping_method' => 'N/A',
'country' => 'N/A',
'state' => 'N/A',
];
// Prepare order itself
$orderToPrepare['amount_cents'] = 10;
$orderToPrepare['merchant_order_id'] = 101;
$orderToPrepare['items'] = $orderItems;
$orderToPrepare['billing_data'] = $billingData;
// Get payment URL
$paymentUrl = $item->makePayment($orderToPrepare);
return $paymentUrl;
}