asciisd/knet/knet-development
Claude Code and agent skill by asciisd/knet
- community
Checking that the SKILL.md file is still in the repository.
Build and work with KNET payment gateway integration, including payment initiation, callback handling, refunds, and event-driven payment flows.
Install
npx vskill@latest install asciisd/knet/knet-developmentSKILL.md
KNET Payment Development
When to use this skill
Use this skill when:
- Integrating KNET payments into a Laravel application
- Creating payment flows that redirect users to the KNET gateway
- Handling KNET payment callbacks and response processing
- Implementing refunds (full or partial) for KNET transactions
- Querying transaction status from the KNET gateway
- Listening to payment events to trigger business logic
- Working with the
knet_transactionstable orKnetTransactionmodel
Package Overview
asciisd/knet provides a fluent Laravel interface to Kuwait's KNET payment gateway. It handles AES-encrypted communication, payment initiation, callback verification, transaction inquiry, and refunds.
Architecture
The package follows SOLID principles with focused interfaces:
CreatesPayments— payment creation and response handlingInquiresPayments— transaction status inquiryRefundsPayments— full and partial refundsTransactionRepository— data access abstractionEncryptsPayload— encryption abstraction (wraps AES-128-CBC)
KnetPaymentService is a pure delegating facade that implements all three payment interfaces. Prefer depending on the narrower interface when only a subset of functionality is needed.
Setup
Environment Variables
Add the Trait
Add HasKnet to any model that can make payments (typically User):
This adds:
pay(float $amount, array $options = []): KnetTransaction— create a paymentpayWithKfast(float $amount, array $options = []): KnetTransaction— KFAST faster checkout (auto-generates 8-digit token)refund(KnetTransaction $transaction, ?float $amount = null): array— full or partial refundkfastToken(): string— overridable 8-digit numeric KFAST token generatorknetTransactions(): HasMany— relationship to all transactions
Creating Payments
Via the Trait
Via Service Injection
Via Focused Interface
If you only need payment creation, type-hint the narrower interface:
With KFAST (Faster Checkout)
Override the token strategy by implementing kfastToken() on your model:
KFAST token rules:
- Must be exactly 8 numeric digits (validated automatically by
PaymentRequest) - Must uniquely identify the customer
- KFAST must be enabled on the terminal by the acquirer bank
Important Rules
- Amounts MUST use 3 decimal places (KWD format):
10.000,25.500,0.250 - Currency code
414is the ISO code for Kuwaiti Dinar - Track IDs must be unique per transaction
- UDF fields (
udf1–udf5) carry custom data through the full payment lifecycle - The
$transaction->urlcontains the full KNET gateway URL to redirect the user to
Payment Flow
- Initiate: Call
$user->pay()orKnetPaymentService::createPayment()— returns aKnetTransactionwith aurl - Redirect: Send the user to
$transaction->url(the KNET payment page) - Callback: KNET POSTs encrypted
trandatato/knet/response— middleware decrypts once and passes payload via request attributes - Events:
KnetPaymentSucceededorKnetPaymentFailedis dispatched - Redirect back: User is redirected to
KNET_REDIRECT_URLwith the result
Handling Payment Events
All Available Events
| Event | Payload | |
|---|---|---|
KnetPaymentSucceeded | KnetTransaction $transaction | |
KnetPaymentFailed | KnetTransaction $transaction, ?string $errorMessage | |
KnetRefundSucceeded | KnetTransaction $transaction, KnetTransaction $refundTransaction, float $amount | |
KnetRefundFailed | KnetTransaction $transaction, KnetTransaction $refundTransaction, string $reason | |
KnetResponseReceived | array $payload | |
KnetResponseHandled | array $payload | |
KnetTransactionCreated | KnetTransaction $transaction | |
KnetTransactionUpdated | KnetTransaction $transaction | |
KnetTransactionHasErrors | KnetTransaction $transaction | |
KnetReceiptSeen | KnetTransaction $transaction |
Working with KnetTransaction
To find by track ID, use the repository:
Key Columns
| Column | Type | Description | |
|---|---|---|---|
trackid | string | Unique tracking identifier | |
paymentid | string | KNET payment ID | |
result | string | Payment result (CAPTURED, FAILED, etc.) | |
amt | string | Payment amount | |
auth | string | Authorization code | |
ref | string | Reference number | |
tranid | string | Transaction ID | |
udf1–udf5 | string | User-defined fields | |
paid | boolean | Whether payment was successful | |
refunded | boolean | Whether transaction was refunded | |
refund_amount | decimal | Refund amount (if partial) |
Payment Status Enum
For presentation (colors, images), use the presenter:
Inquiry & Refunds
Transaction Inquiry
Refunds
Via Trait
Via Service
Refund Validation
The service automatically validates before processing:
- Transaction must be captured and not already refunded (
isRefundable()) - Refund amount must be greater than zero
- Refund amount must not exceed the original transaction amount
Throws KnetException on validation failure.
Refund Behavior
- On success: original transaction is marked
refunded = true,refunded_atis set,refund_amountis recorded - A separate
KnetTransactionrecord is created for the refund (withaction = 2andoriginal_transaction_idlinking to the original) KnetRefundSucceededevent is dispatched on success;KnetRefundFailedon failure- Refund result is
CAPTUREDfor success; any other value is a failure
Routes
The package auto-registers these routes (prefix configurable via KNET_PATH):
| Method | URI | Purpose | |
|---|---|---|---|
| POST | /knet/response | KNET encrypted callback (with signature verification middleware) | |
| POST | /knet/handle | Post-success redirect handler | |
| GET/POST | /knet/error | Error callback handler |
Disable auto-registration with Knet::ignoreRoutes() in a service provider.
Customization
Custom Billable Model
Skip Package Migrations
Skip Package Routes
Artisan Commands
| Command | Purpose | |
|---|---|---|
php artisan knet:install | Publish config, run migrations, validate setup | |
php artisan knet:check | Validate credentials and configuration | |
php artisan knet:publish | Publish config (--config) and/or migrations (--migrations) |
Common Patterns
Complete Checkout Controller
Payment Success Listener
KNET Gateway Protocol (K-064)
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingresources/boost/skills/knet-development/SKILL.md
Popularity
- Repository stars
- 14
- Repository forks
- 7
- 7-day trend score
- 14
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 18 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/asciisd/knet/knet-development)