Download the PHP package tarfin-labs/moka without Composer
On this page you can find all versions of the php package tarfin-labs/moka. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tarfin-labs/moka
More information about tarfin-labs/moka
Files in tarfin-labs/moka
Package moka
Short Description Laravel package for Moka Payment integration with 3D Secure support
License MIT
Informations about the package moka
Moka Payment Integration for Laravel
This package provides an easy way to integrate Moka Payment system into your Laravel application.
Installation
You can install the package via composer:
Configuration
Publish the config file:
Add your Moka credentials to your .env
file:
Usage
Creating a 3D Payment
Handling the 3D Callback
The package automatically sets up a callback route at POST /moka-callback
(named moka-callback.handle3D
) to handle the 3D payment result. The callback will:
- Validate the payment
- Update the payment status
- Redirect to your success/failure URL with the payment result
You can configure the success and failure URLs in your .env
file:
The callback will redirect to these URLs with the following session data:
Events Fired After Payment
The package includes an event system to help you manage payment outcomes. When a 3D Secure payment is processed, one of the following events will be dispatched:
Listening for Payment Events
To react to these events, you can create listeners in your application. There are multiple ways to register event listeners in Laravel.
Then create your listener classes:
Dynamic Redirect URLs
You can specify custom success and failure URLs for each payment by adding them as query parameters to the return URL:
With this approach, you can dynamically specify different URLs for each payment transaction. The callback handler will:
- Check for
success_url
orfailure_url
parameters in the request - Redirect to these URLs if present
- Fall back to the configured
MOKA_PAYMENT_SUCCESS_URL
orMOKA_PAYMENT_FAILURE_URL
if not specified
This is useful for applications that require different redirect destinations based on the payment context, such as returning users to specific order pages or application sections.
Calculating Payment Amount
You can calculate the payment amount including commission rates and bank card details using the MokaPaymentAmount
service:
The service will return an array containing detailed payment information:
If there's an error with the calculation, the service will throw a MokaException
with the error code and message.
Storing Failed Payments
By default, failed payments are not stored in the database. If you want to store them, set this in your .env
:
BIN Inquiry
You can use the BIN inquiry service to get information about a credit card based on its BIN number (first 6 digits):
The BIN inquiry service provides information about:
- Bank details (name and code)
- Card type (MASTER/VISA)
- Credit type (CreditCard/DebitCard)
- Card logos and templates
- Product category and group name
If the BIN inquiry fails, a MokaException
will be thrown with the error message and code from Moka.
Payment Table
You can get payment table information including installment options and commission rates using the MokaPaymentTable
service:
The service will return an array containing available installment options and commission rates:
Payment Detail List
You can retrieve detailed information about a payment and its transactions using the PaymentDetailList
service:
The service will return an array containing both the main payment record and transaction details:
You must provide either the paymentId
(Moka's internal payment ID) or otherTrxCode
(your order/transaction code). If both are null, an exception will be thrown.
If the request fails, a MokaPaymentDetailListException
will be thrown with the error message and code from Moka.
Testing
License
The MIT License (MIT). Please see License File for more information.
All versions of moka with dependencies
illuminate/support Version ^11.0|^12.0
illuminate/http Version ^11.0|^12.0
illuminate/database Version ^11.0|^12.0
illuminate/routing Version ^11.0|^12.0
guzzlehttp/guzzle Version ^7.8