sroor / laravel-payment
laravel payemnts getawaies
v1.0.2
2023-06-19 12:10 UTC
README
This is a laravel package to facilate integartion with paymob apis Paymob docs.
Installation
1- You can install the package via composer:
composer require sroor/laravel-payment
2- Publish config file for editing if needed:
php artisan vendor:publish --tag=config --provider="Sroor\Payment\PaymentServiceProvider"
Usage
- Register new merchant account or login if you already have one (Register).
- Get Paymob credentials from Paymob Dashboard (How) and update
.env
file.
PAYMENT_PAYMOB_API_KEY =
PAYMENT_PAYMOB_CARD_INTEGRATION_ID =
PAYMENT_PAYMOB_CARD_IFRAME_ID =
PAYMENT_PAYMOB_HMAC_SECRET =
- Make payment and get iframe url from paymob
<?php use Illuminate\Support\Facades\Route; use Sroor\Payment\Facades\Paymob; Route::get('/test', function () { $orderData = [ "amount_cents"=> "100", // required, integer value in cents "currency"=> "EGP", // required "merchant_order_id"=> 1243, // optional, A unique alpha-numeric value for each transaction "expiration" => 3600, // required // optional fields in billing data, if it isn't available, please send it to be "NA", "billing_data" => [ "first_name" => "Kamal", // required "last_name" => "Sroor", // required "email" => "Kamal@mail.com", // required "phone_number" => "01234567890", // required "apartment" => "NA", // optional "floor" => "NA", // optional "street" => "NA", //optional "building" => "NA", // optional "shipping_method" => "NA", // optional "postal_code" => "NA", //optional "city" => "NA", // optional "country" => "NA", // optional "state" => "NA" // optional ], ]; // Get payment iframe URL $iframeUrl = Paymob::pay($orderData); return $iframeUrl; //redirect to ifram url // return redirect()->to($iframeUrl); });
-
Webhook transaction url:
POST Request: (https://yourdomain.com/paymob/webhook)
Replace your yourdomain.com with actual domain name
For testing callback, you can use tool like Ngrok
-
Add Paymob trasaction callback to integration card How