PHPackages                             aghfatehi/laravel-tap - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. aghfatehi/laravel-tap

ActiveLibrary[Payment Processing](/categories/payments)

aghfatehi/laravel-tap
=====================

Tap Payment Gateway Integration for Laravel - Accept payments via Tap (supports KNET, Mada, Visa, Mastercard, Apple Pay, STC Pay, Tabby, Tamara, and more).

v1.0.0(1mo ago)03↓90%MITPHPPHP ^8.1CI passing

Since Jun 4Pushed 1mo agoCompare

[ Source](https://github.com/aghfatehi/laravel-tap)[ Packagist](https://packagist.org/packages/aghfatehi/laravel-tap)[ RSS](/packages/aghfatehi-laravel-tap/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

 [![PHP Version](https://camo.githubusercontent.com/d4fe5599dc4fb02fe432b94f8a25d1b06cfc6fbaad6f0baa6dc87ee043ca3e98/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d5e382e312d3838393242462e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d706870)](https://www.php.net/) [![Laravel Version](https://camo.githubusercontent.com/c3dc9a9c0dedd58aa68040d9fda598b18eea463a43763d9972109eb4bac2d1ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31307c31317c31327c31332d4646324432302e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d6c61726176656c)](https://laravel.com) [![Tap Payment Gateway](https://camo.githubusercontent.com/5fb244cf3c71c2a181b19fbaddd68f5e0bb0b09cee855aea49cb6028d495d5c3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5461702d5061796d656e745f476174657761792d3030413835392e7376673f7374796c653d666f722d7468652d6261646765)](https://www.tap.company) [![License](https://camo.githubusercontent.com/31e62e0eff03ce9ddfdf69d8476340d4f541990bfb152cb02a0f342965252997/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/aghfatehi/laravel-tap/blob/main/LICENSE) [![Tests](https://camo.githubusercontent.com/a1b5ba6f7eaf04a1f01efea230b5816aa5a532c3f835f2098d6e39ccf78f7695/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6167686661746568692f6c61726176656c2d7461702f6c61726176656c2e796d6c3f7374796c653d666f722d7468652d6261646765266c6162656c3d5465737473)](https://github.com/aghfatehi/laravel-tap/actions/workflows/laravel.yml) [![Packagist](https://camo.githubusercontent.com/4cce1eef24df3d968f744657a582dd406f83cda4a6196477d5651b51737327a0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6167686661746568692f6c61726176656c2d7461702e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/aghfatehi/laravel-tap) [![Downloads](https://camo.githubusercontent.com/63f024a228fdcf80e078db4291bbf4dfde37f8d650150ef6e68223d337025b68/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6167686661746568692f6c61726176656c2d7461702e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/aghfatehi/laravel-tap)

Laravel Tap Payment Gateway
===========================

[](#laravel-tap-payment-gateway)

### Accept payments via Tap — KNET, Mada, Visa, Mastercard, Apple Pay, STC Pay, Tabby, Tamara, and more

[](#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](https://tap.company) - 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
-------------------

[](#-table-of-contents)

- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)
- [Phase 1: Payment Processing (Charges)](#-phase-1-payment-processing-charges)
- [Phase 2: Order Management](#-phase-2-order-management)
- [API Methods](#api-methods)
- [Webhook Handling](#webhook-handling)
- [Testing](#testing)
- [Security](#security)
- [Integration Scenarios](#integration-scenarios)
- [Countries &amp; Currencies](#countries--currencies)

---

Features
--------

[](#features)

### Phase 1 — Payment Processing

[](#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 &amp; Production environments
- ✅ Multiple payment sources (cards, KNET, Mada, STC Pay, Apple Pay, etc.)

### Phase 2 — Order Management

[](#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
------------

[](#requirements)

LaravelPHPPackage Version10.x^8.1^1.011.x^8.2^1.012.x^8.2^1.013.x^8.2^1.0---

Installation
------------

[](#installation)

```
composer require aghfatehi/laravel-tap
```

### Publish Configuration

[](#publish-configuration)

```
php artisan vendor:publish --tag=tap-config
```

### Publish &amp; Run Migration (Optional but Recommended)

[](#publish--run-migration-optional-but-recommended)

```
php artisan vendor:publish --tag=tap-migrations
php artisan migrate
```

---

Configuration
-------------

[](#configuration)

### Environment Variables

[](#environment-variables)

Add these to your `.env` file:

```
TAP_MERCHANT_ID=your_merchant_id_here
TAP_SECRET_KEY=sk_test_your_secret_key_here
TAP_PUBLIC_KEY=pk_test_your_public_key_here
TAP_SANDBOX_MODE=true
TAP_CURRENCY=SAR
TAP_LOCALE=en
TAP_ROUTE_PREFIX=tap
TAP_REDIRECT_URL=/tap/callback
TAP_WEBHOOK_URL=/tap/webhook
```

VariableDescription`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 &amp; Facade

[](#service-provider--facade)

The package auto-discovers via Laravel's package discovery. If disabled, register manually:

```
// config/app.php
'providers' => [
    Aghfatehi\Tap\TapServiceProvider::class,
],

'aliases' => [
    'Tap' => Aghfatehi\Tap\Facades\Tap::class,
],
```

---

🟢 Phase 1: Payment Processing (Charges)
---------------------------------------

[](#-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)

[](#user-journey-step-by-step)

```
1. Customer clicks "Pay with Tap" on your site
2. Your backend calls Tap API → POST /v2/charges/
3. Tap returns {id: "chg_xxx", transaction.url: "https://..."}
4. You redirect customer to transaction.url (Tap hosted page)
5. Customer selects payment method (KNET, Mada, Card, Apple Pay, etc.)
6. Customer completes 3DS authentication if required
7. Tap redirects customer back to your {redirect.url}
8. Your backend verifies: GET /v2/charges/{id}
9. Tap sends webhook to your /tap/webhook (parallel)
10. You validate the webhook hashstring
11. Transaction is logged in tap_transactions table

```

### Routes Registered (Phase 1)

[](#routes-registered-phase-1)

MethodURINameDescriptionPOST`/tap/pay``tap.pay`Initiate charge (hosted checkout)ANY`/tap/callback``tap.callback`Payment callback/redirectGET`/tap/cancel``tap.cancel`Cancel handlerGET`/tap/failure``tap.failure`Failure handlerPOST`/tap/webhook``tap.webhook`Webhook receiver### Quick Start — Phase 1 Only

[](#quick-start--phase-1-only)

#### Using the Provided Routes

[](#using-the-provided-routes)

The simplest integration. Route your users to the checkout form:

```
// In your view (Blade)

    @csrf

    Pay with Tap

```

The customer will be redirected to the Tap hosted checkout page, then back to `/tap/callback` after payment.

#### Using the Facade Directly (Custom UI)

[](#using-the-facade-directly-custom-ui)

```
