laravel-payments maintained by hansalscripts
Description
Payment helper for Paypal, Paymob, Kashier, Hyperpay and Fawry
Author
Last update
2024/10/21 02:23
(dev-main)
License
Downloads
9
Laravel Payment Gateways
Payment Helper of Payment Gateways ( PayPal - Paymob - Fawry - Thawani - WeAccept - Kashier - Hyperpay - Tap - Opay - Paytabs - Vodafone Cash - Orange Money - Meza Wallet - Etisalat Cash)
Supported gateways
- PayPal
- PayMob
- WeAccept
- Kashier
- Fawry
- HyperPay
- Thawani
- Tap
- Opay
- Paytabs
- Binance
- PerfectMoney
- NowPayments
- Payeer
- Telr
- Clickpay
- Coinpayments
- BigPay
- Enot
- PAYCEC
- PayPal Credit Cards
- Payrexx
- Creptomus
- E Wallets (Vodafone Cash - Orange Money - Meza Wallet - Etisalat Cash)
Installation
composer require hansalscripts/laravel-payments
Publish Vendor Files
php artisan vendor:publish --tag="laravel-payments"
laravel-payments.php file
<?php
return [
#PAYMOB
'PAYMOB_API_KEY' => env('PAYMOB_API_KEY'),
'PAYMOB_INTEGRATION_ID' => env('PAYMOB_INTEGRATION_ID'),
'PAYMOB_IFRAME_ID' => env('PAYMOB_IFRAME_ID'),
'PAYMOB_HMAC' => env('PAYMOB_HMAC'),
'PAYMOB_CURRENCY'=> env('PAYMOB_CURRENCY',"EGP"),
.....
];
Web.php MUST Have Route with name “verify-payment”
Route::get('/payments/verify/{payment?}',[FrontController::class,'payment_verify'])->name('verify-payment');
How To Use
use HansalScripts\Payments\Classes\PaymobPayment;
$payment = new PaymobPayment();
//pay function
$payment->pay(
$amount,
$user_id = null,
$user_first_name = null,
$user_last_name = null,
$user_email = null,
$user_phone = null,
$source = null
);
//or use
$payment->setUserId($id)
->setUserFirstName($first_name)
->setUserLastName($last_name)
->setUserEmail($email)
->setUserPhone($phone)
->setCurrency($currency)
->setAmount($amount)
->pay();
//pay function response
[
'payment_id'=>"", // refrence code that should stored in your orders table
'redirect_url'=>"", // redirect url available for some payment gateways
'html'=>"" // rendered html available for some payment gateways
]
//verify function
$payment->verify($request);
//outputs
[
'success'=>true,//or false
'payment_id'=>"PID",
'message'=>"Done Successfully",//message for client
'process_data'=>""//payment response
]
Factory Pattern Use
you can pass only method name without payment key word like (Fawry,Paymob,Opay ...etc) and the factory will return the payment instance for you , use it as you want ;)
$payment = new \HansalScripts\Payments\Factories\PaymentFactory();
$payment=$payment->get(string $paymentName)->pay(
$amount,
$user_id = null,
$user_first_name = null,
$user_last_name = null,
$user_email = null,
$user_phone = null,
$source = null
);;