kajuzi/omnipay-tazapay

Tazapay driver for the Omnipay payment processing library

0.0.1 2025-03-10 23:09 UTC

This package is auto-updated.

Last update: 2025-05-01 10:09:42 UTC


README

Caution: This package is yet to be properly tested. Do your own testing before using it in production!

Tazapay driver for the Omnipay PHP payment processing library

Latest Version on Packagist Software License Total Downloads

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

Installation

Omnipay is installed via Composer. To install, simply require league/omnipay and kajuzi/omnipay-tazapay with Composer:

composer require league/omnipay kajuzi/omnipay-tazapay

Basic Usage

The following gateways are provided by this package:

  • Tazapay

For general usage instructions, please see the main Omnipay repository.

Initialize Gateway

use Omnipay\Omnipay;

$gateway = Omnipay::create('Tazapay');
$gateway->setApiKey('your-api-key');
$gateway->setApiSecret('your-api-secret');
// If you intend to use the sandbox environment. 
$gateway->setTestMode(true);

The package has not been fully tested yet, so it's set to default to test mode.

Please do NOT hard-code your API credentials. Use the .env file for that

Create a Customer

$response = $gateway->createCustomer([
    'card' => [
        'firstName' => 'John',
        'lastName' => 'Doe',
        'email' => 'john.doe@example.com',
        'country' => 'SG',
        'phone' => '67854321',
        'phoneExtension' => '65',
    ],
    'referenceId' => 'customer-123',
])->send();

if ($response->isSuccessful()) {
    $customerId = $response->getTransactionReference();
    echo "Customer created with ID: " . $customerId;
} else {
    echo "Error: " . $response->getMessage();
}

Create a Checkout Session (Purchase)

$response = $gateway->purchase([
    'amount' => '10.00',
    'currency' => 'USD',
    'description' => 'Test Purchase',
    'transactionId' => 'order-123',
    'returnUrl' => 'https://example.com/return',
    'cancelUrl' => 'https://example.com/cancel',
    'webhookUrl' => 'https://example.com/webhook',
    'card' => [
        'firstName' => 'John',
        'lastName' => 'Doe',
        'email' => 'john.doe@example.com',
        'country' => 'SG',
    ],
])->send();

if ($response->isSuccessful() && $response->isRedirect()) {
    // Redirect to Tazapay hosted checkout page
    $response->redirect();
} else {
    echo "Error: " . $response->getMessage();
}

Fetch Transaction Details

$response = $gateway->fetchTransaction([
    'transactionReference' => 'chk_cirsp2sl4ar024j0akj0',
])->send();

if ($response->isSuccessful()) {
    $data = $response->getData();
    echo "Transaction status: " . $response->getPaymentStatus();
} else {
    echo "Error: " . $response->getMessage();
}

Refund a Transaction

$response = $gateway->refund([
    'transactionReference' => 'chk_cirsp2sl4ar024j0akj0',
    'amount' => '10.00',
    'currency' => 'USD',
    'reason' => 'Customer requested refund',
])->send();

if ($response->isSuccessful()) {
    $refundId = $response->getTransactionReference();
    echo "Refund created with ID: " . $refundId;
} else {
    echo "Error: " . $response->getMessage();
}

Void/Cancel a Transaction

$response = $gateway->void([
    'transactionReference' => 'chk_cirsp2sl4ar024j0akj0',
])->send();

if ($response->isSuccessful()) {
    echo "Transaction cancelled successfully";
} else {
    echo "Error: " . $response->getMessage();
}

Fetch Available Payment Methods

$response = $gateway->fetchPaymentMethods([
    'amount' => '10.00',
    'currency' => 'USD',
    'customerCountry' => 'SG',
])->send();

if ($response->isSuccessful()) {
    $paymentMethods = $response->getData()['payment_methods'];
    foreach ($paymentMethods as $method) {
        echo $method['display_name'] . " (" . $method['type'] . ")\n";
    }
} else {
    echo "Error: " . $response->getMessage();
}

Support

If you are struggling with your integration, please feel free to reach out at on kajuzi.co.za. Please note, you may be billed for certain services.

If you are having general issues with Omnipay, we suggest posting on Stack Overflow. Be sure to add the omnipay tag so it can be easily found.

If you believe you have found a bug, please report it using the Gitlab issue tracker, or better yet, fork the library and submit a pull request.

License

The MIT License (MIT). Please see License File for more information.