Download the PHP package aghfatehi/laravel-tap without Composer
On this page you can find all versions of the php package aghfatehi/laravel-tap. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download aghfatehi/laravel-tap
More information about aghfatehi/laravel-tap
Files in aghfatehi/laravel-tap
Package laravel-tap
Short Description Tap Payment Gateway Integration for Laravel - Accept payments via Tap (supports KNET, Mada, Visa, Mastercard, Apple Pay, STC Pay, Tabby, Tamara, and more).
License MIT
Informations about the package laravel-tap
Laravel Tap Payment Gateway
Accept payments via Tap — KNET, Mada, Visa, Mastercard, Apple Pay, STC Pay, Tabby, Tamara, and more
Laravel package for integrating Tap Payments - the unified payment platform in the Middle East. Supports KNET, Mada, Visa, Mastercard, American Express, Apple Pay, Google Pay, STC Pay, Tabby, Tamara, Benefit, Fawry, OmanNet, NAPS, and more.
A professional Laravel package for integrating Tap Payments - the unified payment platform in the Middle East. Supports KNET, Mada, Visa, Mastercard, American Express, Apple Pay, Google Pay, STC Pay, Tabby, Tamara, Benefit, Fawry, OmanNet, NAPS, and more.
📋 Table of Contents
- Features
- Requirements
- Installation
- Configuration
- Phase 1: Payment Processing (Charges)
- Phase 2: Order Management
- API Methods
- Webhook Handling
- Testing
- Security
- Integration Scenarios
- Countries & Currencies
Features
Phase 1 — Payment Processing
- ✅ Create Charge (hosted checkout page —
src_all) - ✅ Retrieve Charge (verify payment status)
- ✅ List Charges (with filters)
- ✅ Update Charge (metadata/description)
- ✅ Webhook receiver with hashstring validation
- ✅ Transaction logging (migration included)
- ✅ Sandbox & Production environments
- ✅ Multiple payment sources (cards, KNET, Mada, STC Pay, Apple Pay, etc.)
Phase 2 — Order Management
- ✅ Authorize (hold payment, auth-only)
- ✅ Capture (collect authorized payment)
- ✅ Void (cancel authorized payment)
- ✅ Refund (return funds)
- ✅ Token Management (create tokens)
- ✅ Customer Management (create/list)
- ✅ Saved Cards (list/delete)
Requirements
| Laravel | PHP | Package Version |
|---|---|---|
| 10.x | ^8.1 | ^1.0 |
| 11.x | ^8.2 | ^1.0 |
| 12.x | ^8.2 | ^1.0 |
| 13.x | ^8.2 | ^1.0 |
Installation
Publish Configuration
Publish & Run Migration (Optional but Recommended)
Configuration
Environment Variables
Add these to your .env file:
| Variable | Description |
|---|---|
TAP_MERCHANT_ID |
Your merchant ID from Tap Dashboard (Accounts → Operators → Merchant) |
TAP_SECRET_KEY |
Secret API key (sk_test_xxx for sandbox, sk_live_xxx for production) |
TAP_PUBLIC_KEY |
Public API key (pk_test_xxx for sandbox, pk_live_xxx for production) |
TAP_SANDBOX_MODE |
true for sandbox (testing), false for production |
TAP_CURRENCY |
3-letter ISO currency code (SAR, AED, KWD, USD, etc.) |
TAP_LOCALE |
Checkout page language: en or ar |
TAP_ROUTE_PREFIX |
URL prefix for all Tap routes (default: tap) |
Service Provider & Facade
The package auto-discovers via Laravel's package discovery. If disabled, register manually:
🟢 Phase 1: Payment Processing (Charges)
Phase 1 covers the basic "Charge" flow — the most common integration. Customer is redirected to a Tap-hosted checkout page, pays, and returns to your app.
User Journey (Step by Step)
Routes Registered (Phase 1)
| Method | URI | Name | Description |
|---|---|---|---|
| POST | /tap/pay |
tap.pay |
Initiate charge (hosted checkout) |
| ANY | /tap/callback |
tap.callback |
Payment callback/redirect |
| GET | /tap/cancel |
tap.cancel |
Cancel handler |
| GET | /tap/failure |
tap.failure |
Failure handler |
| POST | /tap/webhook |
tap.webhook |
Webhook receiver |
Quick Start — Phase 1 Only
Using the Provided Routes
The simplest integration. Route your users to the checkout form:
The customer will be redirected to the Tap hosted checkout page, then back to /tap/callback after payment.
Using the Facade Directly (Custom UI)
Handling Callback (tap/callback)
When the customer completes payment on Tap's page, they are redirected back to {redirect.url} with ?tap_id=chg_xxxxxxxx. Your callback handler should:
- Get the
tap_idfrom query string - Call
Tap::getCharge(tap_id)to verify the status - Check if status is
CAPTURED(success) or any other status - Update your order accordingly
🔵 Phase 2: Order Management
Phase 2 adds Authorize-Capture-Void-Refund flow plus token/customer management.
Additional routes:
| Method | URI | Name | Description |
|---|---|---|---|
| POST | /tap/authorize |
tap.authorize |
Create authorization |
| POST | /tap/charge/capture |
tap.capture |
Capture authorized charge |
| POST | /tap/charge/void |
tap.void |
Void authorized charge |
| POST | /tap/charge/refund |
tap.refund |
Refund a charge |
| GET | /tap/charge/{id} |
tap.details |
Get charge details |
Authorize → Capture Flow
Void Flow
Refund Flow
API Methods
Phase 1: Charges
Phase 2: Authorize & Order Management
Phase 2: Tokens, Customers & Saved Cards
Webhook Handling
Tap sends server-to-server POST notifications to your webhook URL after payment events.
Webhook Payload Example
Webhook Hashstring Validation
The package automatically validates the webhook signature. Here's how it works:
The hashstring is computed as:
Custom Webhook Handler
You can listen to the dispatched events:
Integration Scenarios
Scenario A: Phase 1 Only (Minimum Integration)
You want a simple hosted checkout. No authorize/capture/refund.
- Add your
.envvariables - Add a
POSTform toroute('tap.pay')withamount - Handle callback at
route('tap.callback') - Done.
Scenario B: Phase 1 (your own) + Phase 2 (this package)
You already have a charge integration (either via this package, another package, or direct API calls). You want to add authorize/capture/void/refund:
- Use
Tap::createAuthorize()for auth-only payments - Use
Tap::captureCharge()to capture - Use
Tap::voidCharge()to void - Use
Tap::refundCharge()to refund - Webhook automatically logs all events
Scenario C: Full Integration (Phase 1 + Phase 2)
All features enabled. This is the recommended approach for production.
Set up your webhook URL in your Tap Dashboard:
Routes Reference
| Method | URI | Name | Phase | Description |
|---|---|---|---|---|
| POST | /tap/pay |
tap.pay |
1 | Initiate charge (hosted checkout) |
| ANY | /tap/callback |
tap.callback |
1 | Payment callback/redirect |
| GET | /tap/cancel |
tap.cancel |
1 | Cancel handler |
| GET | /tap/failure |
tap.failure |
1 | Failure handler |
| POST | /tap/webhook |
tap.webhook |
1+2 | Webhook receiver |
| POST | /tap/authorize |
tap.authorize |
2 | Create authorization |
| POST | /tap/charge/capture |
tap.capture |
2 | Capture authorized charge |
| POST | /tap/charge/void |
tap.void |
2 | Void authorized charge |
| POST | /tap/charge/refund |
tap.refund |
2 | Refund a charge |
| GET | /tap/charge/{id} |
tap.details |
2 | Get charge details |
Customising Routes
Publish the config and modify the routes section:
Webhook Events
The package dispatches these events:
| Event | When | Payload |
|---|---|---|
PaymentSucceeded |
Webhook received with CAPTURED/AUTHORIZED status | Full webhook payload |
PaymentFailed |
Webhook received with failed/declined status | Full webhook payload |
WebhookReceived |
Any webhook received | Payload + validation boolean |
Payment Sources
The source.id field determines which payment methods appear:
| Source ID | Payment Methods |
|---|---|
src_all |
All available methods |
src_cards |
Card only (Visa, Mastercard, Mada) |
src_kw.knet |
KNET only |
src_sa.stcpay |
STC Pay only |
src_bh.benefit |
Benefit only |
src_om.omannet |
OmanNet only |
src_qa.naps |
NAPS/QPay only |
For a tokenized card, pass the token ID as source:
Countries & Currencies
| Country | Code | Currency | Code | Decimals |
|---|---|---|---|---|
| Saudi Arabia | SA | Saudi Riyal | SAR | 2 |
| UAE | AE | UAE Dirham | AED | 2 |
| Kuwait | KW | Kuwaiti Dinar | KWD | 3 |
| Bahrain | BH | Bahraini Dinar | BHD | 3 |
| Qatar | QA | Qatari Riyal | QAR | 2 |
| Oman | OM | Omani Riyal | OMR | 3 |
| Jordan | JO | Jordanian Dinar | JOD | 3 |
| Egypt | EG | Egyptian Pound | EGP | 2 |
| USA | US | US Dollar | USD | 2 |
| Europe | EU | Euro | EUR | 2 |
| UK | GB | British Pound | GBP | 2 |
Security
Credential Safety
- NEVER hardcode
TAP_SECRET_KEYin your code — use.envonly - Secret keys start with
sk_— keep them server-side only - Public keys start with
pk_— safe to use in frontend - The package never logs full secret keys (masked as
sk_****)
Webhook Validation
All webhooks are validated using HMAC-SHA256 hashstring verification. If the hash doesn't match, the webhook is rejected with HTTP 403.
Safe Logging
- ✅ API requests logged without sensitive data
- ✅ Transaction IDs logged for debugging
- ✅ Error responses logged with message only
- ❌ Secret keys never logged
- ❌ Card numbers never logged
Testing
Run Package Tests
The test suite covers:
- Unit\TapClientTest: URL resolution, method existence
- Unit\WebhookValidatorTest: Hashstring generation, validation, currency rounding
- Feature\TapChargeControllerTest: Route accessibility
Sandbox Credentials
Set these in your .env for sandbox testing:
Note: Your API keys are provided by Tap Payments through the merchant dashboard. You can retrieve them from the Merchant Dashboard → Developers → API Keys. The keys cannot be generated or modified by the developer; they are assigned by Tap.
For viewing reports and payment transactions (both staging and production), visit: Tap Reports Portal
Test Cards — Local Payment Methods
| Method | Card Number | Expiry | PIN | Result |
|---|---|---|---|---|
| KNET | 8888880000000001 |
09/30 | 1234 |
CAPTURED |
| KNET | 8888880000000002 |
09/30 | 1234 |
CAPTURED |
| KNET | 8888880000000001 |
05/21 | 1234 |
NOT CAPTURED |
| Benefit | 4600410123456789 |
12/27 | 1234 |
CAPTURED |
| Benefit | 7777770123456789 |
12/27 | 1234 |
NOT CAPTURED |
| Benefit | 1111110123456789 |
12/27 | 1234 |
DECLINED |
| Naps/QPay | 4215375500883243 |
12/25 | 944 (OTP: 1234) |
CAPTURED |
KNET Page: Select KNET Test Card [KNET1] from the Bank drop-down.
Test Cards — Credit / Debit Cards
| Method | Card Number | 3D Secure |
|---|---|---|
| MasterCard | 5123450000000008 |
Yes |
| MasterCard | 5111111111111118 |
No |
| VISA | 4508750015741019 |
Yes |
| VISA | 4012000033330026 |
No |
| VISA | 4440000009900010 |
Yes |
| VISA | 4440000042200014 |
Yes |
| VISA | 4440000042200022 |
Yes |
| American Express | 345678901234564 |
Yes |
| American Express | 371449635398431 |
No |
| Mada | 4464040000000007 |
Yes |
| Mada | 5588480000000003 |
No |
| OmanNet | 4837915060379278 |
Yes |
Expiry Date — Response Mapping
Use these expiry dates to simulate specific outcomes:
| Expiry Date | Transaction Response |
|---|---|
| 01/39 | APPROVED |
| 05/22 | DECLINED |
| 04/27 | EXPIRED_CARD |
| 08/28 | TIMED_OUT |
| 01/37 | ACQUIRER_SYSTEM_ERROR |
| 02/37 | UNSPECIFIED_FAILURE |
| 05/37 | UNKNOWN |
| 07/30 | APPROVED (OmanNet) |
CSC / CVV — Response Mapping
| CVV | Gateway Code | Meaning |
|---|---|---|
100 |
MATCH | CVV matches (MasterCard / Visa) |
101 |
NOT_PROCESSED | CVV not processed (MasterCard / Visa) |
102 |
NO_MATCH | CVV does not match (MasterCard / Visa) |
1000 |
MATCH | CVV matches (American Express) |
1010 |
NOT_PROCESSED | CVV not processed (American Express) |
1020 |
NO_MATCH | CVV does not match (American Express) |
844 |
MATCH | CVV matches (OmanNet, OTP: 9999) |
STC Pay — Test Phone Numbers
| Country Code | Phone Number |
|---|---|
| 966 | 548220713 |
| 966 | 550955806 |
| 966 | 554748162 |
| 966 | 554774102 |
Changelog
See CHANGELOG for recent changes.
Security
If you discover security issues, please email [email protected] instead of using the issue tracker.
License
This package is open-sourced software licensed under the MIT license.
Support
- Issues: GitHub Issues
- Tap API Docs: https://developers.tap.company
- Author: AL-AGHBARI Fatehi ([email protected])
All versions of laravel-tap with dependencies
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
illuminate/routing Version ^10.0|^11.0|^12.0|^13.0
ext-curl Version *
ext-json Version *