ibehbudov / payment-gateways
Payment Gateways for Laravel
dev-master
2022-10-30 16:29 UTC
Requires
- php: >=8.0
- guzzlehttp/guzzle: *
- spatie/array-to-xml: *
This package is auto-updated.
Last update: 2024-10-29 06:06:30 UTC
README
PHP version
- PHP version >= 8.0
Installation
composer require ibehbudov/payment-gateways
Publish vendor files
php artisan vendor:publish --tag=payment-gateways
Add alias
'Payment' => Ibehbudov\PaymentGateways\Facades\Payment::class
Usage
KapitalBank usage
- Create order
use Ibehbudov\PaymentGateways\Facades\Payment; use Ibehbudov\PaymentGateways\Vendors\KapitalBank\Requests\CreateOrderRequest; class PaymentController extends Controller { public function createOrder() { $payment = Payment::setPaymentMethod(KapitalBank::class); $payment->setAmount(13.45); $payment->setDescription("Description"); $payment->setLocale(App::getLocale()); $payment->setBankRequest(new CreateOrderRequest()); $payment->getBankRequest()->exceptionWhenFailed(false); $payment->execute(); $orderId = $payment->getOrderId(); $redirectUrl = $payment->getBankRequest()->getRedirectUrl(); return $payment->redirectToPaymentPage(); } }
- Refund
$payment = Payment::setPaymentMethod(KapitalBank::class); $payment->setBankRequest(new RefundOrderRequest( orderId: 44516491, sessionId: "9FF55469ADFA786A0E082708E4406579", )); $payment->setAmount(10); $payment->setLocale(App::getLocale()); $payment->setDescription("Refund"); $payment->getBankRequest()->exceptionWhenFailed(false); $payment->execute(); if($payment->getBankRequest()->failed()) { echo "request is failed: "; } else { echo "request is success"; }
- Callback
$payment = Payment::setPaymentMethod(KapitalBank::class); $payment->callback($request->post('xmlmsg')); if($payment->isSuccess()) { // success code echo "success"; }
- PreAuth Order
$payment = Payment::setPaymentMethod(KapitalBank::class); $payment->setBankRequest(new PreAuthRequest()); $payment->setAmount(10); $payment->setDescription("Description text"); $payment->getBankRequest()->exceptionWhenFailed(true); $payment->execute(); $orderId = $payment->getOrderId(); return $payment->redirectToPaymentPage();
- Reverse Order
$payment = Payment::setPaymentMethod(KapitalBank::class); $payment->setBankRequest(new ReverseRequest( orderId: 44516491, sessionId: "9FF55469ADFA786A0E082708E4406579", )); $payment->setAmount(10); $payment->setDescription("Description text"); $payment->getBankRequest()->exceptionWhenFailed(false); $payment->execute(); if($payment->getBankRequest()->success()) { // code } if($payment->getBankRequest()->failed()) { // code }
Requests list
- CardRegistrationRequest
- CompletionRequest
- CreateOrderRequest
- CreateOrderWithCardUIDRequest (Not working properly)
- OrderStatusRequest
- PreAuthRequest
- RefundOrderRequest
- ReverseRequest
- TaksitRequest