Skip to content

ElmMac/ikhokha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ElmMac - Laravel iKhokha Payment Integration API πŸ’³

Laravel iKhokha Payment Integration API (elmmac/ikhokha) πŸ’³

Latest Version on Packagist Total Downloads License: MIT Laravel GitHub Repo stars

Official Laravel package to integrate iKhokha Pay Links and Webhooks into your Laravel projects.


πŸ“˜ ElmMac iKhokha Laravel Package API

This Laravel package provides a native iKhokha payment integration layer, complete with:

  • Webhook handling
  • Database logging
  • API client functionality
  • Optional UI blade views for frontend integration
  • Paylink creation
  • Easily extendable API client

Perfect for:

βœ” SaaS platforms βœ” Marketplaces βœ” Payment-based apps βœ” Donation systems βœ” Subscription-like flows

πŸ”’ Secure, scalable, and modular β€” ideal for custom Laravel SaaS and marketplaces.


πŸ›† Features

βœ… Webhook listener & processor
βœ… Auto-persist IkhokhaPayment records
βœ… Extendable IkhokhaClient for outbound API calls
βœ… Built for Laravel 9/10+
βœ… Clean PSR-4 package structure
βœ… Optional config, views, and migration publishing
βœ… Optional UI views included (Blade templates)

Current Package Structure


elmmac/ikhokha/
β”‚
β”œβ”€β”€ composer.json
β”‚
β”œβ”€β”€ config/
β”‚   └── ikhokha.php
β”‚
β”œβ”€β”€ database/
β”‚   └── migrations/
β”‚       └── 2025_06_30_130134_create_ikhokha_payments_table.php
β”‚
β”œβ”€β”€ resources/
β”‚   └── views/
β”‚       └── ikhokha/
β”‚           β”œβ”€β”€ success.blade.php
β”‚           β”œβ”€β”€ failed.blade.php
β”‚           └── cancel.blade.php
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ Http/
β”‚   β”‚   └── Controllers/
β”‚   β”‚       └── IkhokhaPaymentController.php
β”‚   β”‚
β”‚   β”œβ”€β”€ Models/
β”‚   β”‚   └── IkhokhaPayment.php
β”‚   β”‚
β”‚   β”œβ”€β”€ Services/
β”‚   β”‚   └── IkhokhaClient.php
β”‚   β”‚
β”‚   β”œβ”€β”€ routes/                     ← **ROUTES ARE HERE**
β”‚   β”‚   β”œβ”€β”€ api.php
β”‚   β”‚   └── web.php
β”‚   β”‚
β”‚   └── IkhokhaServiceProvider.php
β”‚
└── README.md




πŸ›† Installation

Step 1: Install via Composer

composer require elmmac/ikhokha

Step 2: Register Service Provider (if needed)

For Laravel < 5.5 or explicit config

'providers' => [
    Elmmac\Ikhokha\IkhokhaServiceProvider::class,
],

βš™οΈ Configuration

Optional: Publish the config

php artisan vendor:publish --tag=ikhokha-config

This publishes: config/ikhokha.php

Edit your .env file:

IKHOKHA_APP_ID=YOUR_APP_ID
IKHOKHA_SIGN_SECRET=YOUR_SECRET
IKHOKHA_WEBHOOK_URL=https://yourdomain.com/api/ikhokha/callback

πŸ“„ Publish Views (Optional UI)

php artisan vendor:publish --tag=ikhokha-views

Views will be published to: resources/views/ikhokha

Use them as base templates or customize freely.


πŸ—ƒοΈ Migrations

Optional: Publish Migrations

php artisan vendor:publish --tag=ikhokha-migrations

Migration will be published to: database/migrations/

Then run:

php artisan migrate

Model:

Elmmac\Ikhokha\Models\IkhokhaPayment

Table: ikhokha_payments

Add relationship in your User.php:

public function ikhokha_payments()
{
    return $this->hasMany(IkhokhaPayment::class);
}

And in IkhokhaPayment.php:

public function user()
{
    return $this->belongsTo(\App\Models\User::class, 'user_id');
}

πŸ›† Example Manual Entry:

IkhokhaPayment::create([
    'user_id' => $user->id ?? null,
    'customer_email' => $user->email ?? $request->input(key: 'customer_email', default: 'misael@elmmac.co.za'),
    'transaction_id' => $externalTransactionID,
    'description' => $request->input('description', 'Payment'),
    'paylink_id' => $data['paylinkID'] ?? null,
    'amount' => $amount,
    'currency' => $currency,
    'status' => 'pending',
    'payment_url' => $data['paylinkUrl'] ?? null,
    'webhook_signature' => $ikSign,
    'metadata' => $data,
]);

πŸ”— Create Payment Link Payload - REQUEST | Refer to πŸ”— iKhokha API Overview for more.

Use this structure to initiate payment (All iKhokha Requests & Responses MUST be in JSON format):

$payload = [
    "entityID" => $appID,
    "amount" => (int) $amount * 100,
    "currency" => $currency,
    "requesterUrl" => url()->current(),
    "mode" => $mode,
    "externalTransactionID" => $externalTransactionID,
    "urls" => [
        "callbackUrl" => route(name: 'ikhokha.webhook'),
        "successPageUrl" => route(name: 'ikhokha.success'),
        "failurePageUrl" => route(name: 'ikhokha.failed'),
        "cancelUrl" => route(name: 'ikhokha.cancel'),
    ]
];

Create Paylink/Payment Link Response Object

CREATE PAYMENT LINK - RESPONSE
{
    "responseCode": "00",
    "message": "",
    "paylinkUrl": "https://securepay.ikhokha.red/2zh1zj6y8xpb0g3",
    "paylinkID": "2zh1zj6y8xpb0g3",
    "externalTransactionID": "TRANS789" // $transactionId
}

πŸ” Webhook Setup | Refer to πŸ”— iKhokha API Overview for more.

πŸ“¬ Webhook URL:

POST /api/ikhokha/webhook

Required headers:

ik-appid
ik-sign
Content-Type: application/json

πŸ“¨ Sample Payload:

{
    "paylinkID": "2zh1zj6y8xpb0g3", // Gotten from Create Payment Link Response
    "status": "SUCCESS",
    "externalTransactionID": "IKH_REF_CODE_9911",
    "responseCode": "00"
}

🚦 Route Summary

Method URL Purpose
POST /ikhokha-initiate Create payment link
GET /ikhokha/success Redirect page after payment
GET /ikhokha/failed Failed payment view
GET /ikhokha/cancel Cancel payment view
POST /api/ikhokha/webhook Webhook callback

πŸ“‹ Artisan Helper Tags (Optional)

For dev reminders:

php artisan vendor:publish --tag=ikhokha-config      # Publish config
php artisan vendor:publish --tag=ikhokha-views       # Publish views
php artisan vendor:publish --tag=ikhokha-migrations  # Publish migrations

Use only the ones you need! πŸ’‘


🧠 Roadmap

  • Full unit testing with PHPUnit
  • Laravel Octane compatibility
  • Tokenized card billing
  • Refunds & reversals
  • Multi-merchant support
  • Optional payment UI component scaffolds

iKhokha Subscription Tokenization Eloquent Traits (Billable) Octane compatibility


🀝 Contributing

Pull requests welcome. Open an issue for proposals or fixes.
Make sure tests pass if you're submitting functional changes.


πŸ™ Credits

Developed with πŸš€ by ElmMac Pty Ltd
Maintained by @ElmMac - Misael Cruise Mutege β€” WhatsApp: +27786411181 Durban, South Africa
Digital Dev | Hustler Mode: ON πŸ’Ό


πŸ“„ License

MIT License Β© ElmMac " ||| just edit according to the chamges say like the folder structure excluding the package folder, etc depending on what has changed so far.