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.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

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:

  1. Validate the payment
  2. Update the payment status
  3. 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:

  1. Check for success_url or failure_url parameters in the request
  2. Redirect to these URLs if present
  3. Fall back to the configured MOKA_PAYMENT_SUCCESS_URL or MOKA_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:

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

PHP Build Version
Package Version
Requires php Version ^8.2|^8.3|^8.4
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
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tarfin-labs/moka contains the following files

Loading the files please wait ....