Search by

tcgunel / omnipay-moka

Mobius Studio

Omnipay extension for Moka

Package info

github.com/tcgunel/omnipay-moka

pkg:composer/tcgunel/omnipay-moka

Statistics

Installs: 9

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v2.1.0 2026-10-21 11:56 UTC

This package is auto-updated.

Last update: 2026-10-21 11:57:07 UTC


README

Moka gateway for the Omnipay PHP payment processing library

Omnipay is a framework agnostic, multi-gateway payment processing library for PHP. This package implements Moka support for Omnipay.

Installation

composer require tcgunel/omnipay-moka

Usage

Gateway Setup

use Omnipay\Omnipay;

$gateway = Omnipay::create('Moka');
$gateway->setMerchantId('YOUR_DEALER_CODE');
$gateway->setMerchantUser('YOUR_USERNAME');
$gateway->setMerchantPassword('YOUR_PASSWORD');
$gateway->setTestMode(true); // uses https://service.refmoka.com

Non-3D Purchase

$response = $gateway->purchase([
    'amount'        => '1.50',
    'currency'      => 'TRY',
    'transactionId' => 'ORDER-12345',
    'installment'   => 1,
    'clientIp'      => '127.0.0.1',
    'card'          => [
        'firstName'   => 'John',
        'lastName'    => 'Doe',
        'number'      => '5269111122223332',
        'expiryMonth' => '01',
        'expiryYear'  => '2030',
        'cvv'         => '123',
    ],
])->send();

if ($response->isSuccessful()) {
    $transactionReference = $response->getTransactionReference(); // VirtualPosOrderId
}

3D Secure Purchase

$response = $gateway->purchase([
    'amount'        => '1.50',
    'currency'      => 'TRY',
    'transactionId' => 'ORDER-12345',
    'installment'   => 1,
    'clientIp'      => '127.0.0.1',
    'secure'        => true,
    'returnUrl'     => 'https://yoursite.com/callback',
    'card'          => [
        'firstName'   => 'John',
        'lastName'    => 'Doe',
        'number'      => '5269111122223332',
        'expiryMonth' => '01',
        'expiryYear'  => '2030',
        'cvv'         => '123',
    ],
])->send();

if ($response->isRedirect()) {
    $response->redirect(); // redirects to Moka 3D page
}

Complete Purchase (3D callback)

$response = $gateway->completePurchase([
    'otherTrxCode'  => $_POST['OtherTrxCode'],  // orderNumber
    'trxCode'       => $_POST['trxCode'],        // transactionId
    'resultCode'    => $_POST['resultCode'] ?? null,
    'resultMessage' => $_POST['resultMessage'] ?? null,
])->send();

if ($response->isSuccessful()) {
    // Payment verified
}

Payment Status

GetDealerPaymentTrxDetailList is also the payment-status endpoint. Query it by the same otherTrxCode sent with the purchase to reconcile an order after a lost/duplicated 3D callback:

$response = $gateway->paymentStatus([
    'otherTrxCode' => 'ORDER-12345', // order number
])->send();

if ($response->hasApiError()) {
    // No answer from Moka (bad credentials, malformed request, transport
    // error, ...). Retry later; do not treat this as "unpaid".
} elseif (! $response->hasPaymentRecord()) {
    // Moka has no payment for this order number.
} elseif ($response->isCaptured()) {
    $reference = $response->getVirtualPosOrderId(); // for void/refund
} elseif ($response->isPending()) {
    // Moka has not decided yet; retry later.
} elseif ($response->isFailed() || $response->isCancelled() || $response->isRefunded()) {
    // Definitive unsuccessful outcome.
}

A query for an unknown otherTrxCode returns ResultCode=Success with PaymentDetail=null — that is a definitive "no payment record", not an API error. isSuccessful() only returns true when the payment was captured.

Cancel (Void)

$response = $gateway->void([
    'virtualPosOrderId' => 'MOKA_ORDER_ID',
    'transactionId'     => 'ORDER-12345',
    'clientIp'          => '127.0.0.1',
])->send();

if ($response->isSuccessful()) {
    // Void successful
}

Refund

$response = $gateway->refund([
    'virtualPosOrderId' => 'MOKA_ORDER_ID',
    'transactionId'     => 'ORDER-12345',
    'amount'            => '9.99',
])->send();

if ($response->isSuccessful()) {
    // Refund successful
}

BIN Lookup

$response = $gateway->binLookup([
    'binNumber' => '526911',
])->send();

if ($response->isSuccessful()) {
    $creditType           = $response->getCreditType();           // e.g. "CreditCard"
    $maxInstallmentNumber = $response->getMaxInstallmentNumber(); // e.g. 12
}

Installment Query

$response = $gateway->installmentQuery([
    'binNumber'   => '526911',
    'amount'      => '100.00',
    'currency'    => 'TRY',
    'installment' => 3,
    'isThreeD'    => 0,
])->send();

if ($response->isSuccessful()) {
    $paymentAmount = $response->getPaymentAmount(); // total with commission
}

Endpoints

Environment URL
Test https://service.refmoka.com
Live https://service.moka.com

Authentication

Moka uses CheckKey-based authentication:

CheckKey = SHA256(DealerCode + "MK" + Username + "PD" + Password)

This is generated automatically by the gateway.

Currency

Omnipay uses ISO currency codes (TRY, USD, EUR, GBP). The gateway automatically maps TRY to Moka's TL format.

Testing

composer test

License

MIT