thejano/zaincash-laravel

There is no license information available for the latest version (1.0.0) of this package.

A Laravel SDK for integrating with ZainCash payment gateway

1.0.0 2025-02-10 18:00 UTC

This package is auto-updated.

Last update: 2025-02-10 20:13:43 UTC


README

Introduction

ZainCash Laravel is a PHP SDK designed to integrate the ZainCash payment gateway with Laravel applications seamlessly. This package provides an easy-to-use interface for initiating and verifying payments.

Installation

You can install the package via Composer:

composer require thejano/zaincash-laravel

Configuration

After installing the package, publish the configuration file using:

php artisan vendor:publish --provider="TheJano\ZainCash\Providers\ZainCashPaymentServiceProvider"

This will create a config/zaincash.php file where you can set your credentials.

Add your credentials in your .env file:

ZAINCASH_SECRET=your_secret_key
ZAINCASH_MERCHANT_ID=your_merchant_id
ZAINCASH_MSISDN=your_phone_number
ZAINCASH_ENV=staging
ZAINCASH_REDIRECT_URL=https://yourdomain.com/payment/callback
ZAINCASH_PREFIX_ORDER_ID=ORD_

Usage

Initiate a Payment

You can initiate a payment using the ZainCashPayment facade:

use TheJano\ZainCash\Facades\ZainCashPayment;

$response = ZainCashPayment::initiatePayment(
    orderId: '12345',
    amount: 1000.00,
    serviceType: 'purchase',
    redirectUrl: 'https://yourdomain.com/payment/success'
);

$transactionId = $response['id'];
$paymentUrl = ZainCashPayment::getPaymentUrl($transactionId);

return redirect($paymentUrl);

Verify a Payment

use TheJano\ZainCash\Facades\ZainCashPayment;

$token = request('token');
$paymentData = ZainCashPayment::verifyPayment($token);

if ($paymentData) {
    // Payment is successful
} else {
    // Payment failed
}

Check Transaction Status

use TheJano\ZainCash\Facades\ZainCashPayment;

$transactionId = 'some_transaction_id';
$transactionStatus = ZainCashPayment::checkTransaction($transactionId);

Service Provider & Facade

The package registers ZainCashPaymentServiceProvider automatically. It also provides a facade ZainCashPayment for convenient usage.

License

This package is open-sourced software licensed under the MIT license.

API Documentation

For more details, visit the official API documentation:

https://docs.zaincash.iq