flexonexus/laravel-tap-payments

Laravel integration for Tap Payments (charges, refunds, webhooks).

Maintainers

Package info

github.com/flexonexus/laravel-tap-payments

pkg:composer/flexonexus/laravel-tap-payments

Statistics

Installs: 11

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2025-09-29 19:48 UTC

This package is auto-updated.

Last update: 2026-03-29 01:13:40 UTC


README

Latest Version License

๐Ÿš€ Elegant Laravel integration with Tap Payments: charges, refunds, webhooks โ€” the clean Laravel way.

โœจ Features

  • ๐Ÿ”‘ Simple Facade API: Tap::createCharge(), Tap::refundCharge(), etc.
  • โš™๏ธ Configurable via .env (TAP_SECRET_KEY, TAP_MODE, etc.)
  • ๐Ÿ”” Built-in Webhook signature verification
  • ๐Ÿ“ฆ PSR-4 autoload & Laravel auto-discovery
  • ๐Ÿงช Testbench support for easy unit testing

๐Ÿ“ฆ Installation & Setup

Follow these steps to fully install and configure the package:

1. Install via Composer

composer require flexonexus/laravel-tap-payments

2. Publish the Config File

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

This will create:

config/tap.php

3. Add Environment Variables

In your .env file:

TAP_MERCHANT_ID=your_merchant_id_here # Your Merchant ID
TAP_SECRET_KEY=sk_test_xxx   # Your Tap secret key
TAP_PUBLIC_KEY=pk_test_xxx   # Your Tap public key
TAP_WEBHOOK_SECRET=whsec_xxx # Webhook secret for signature verification
TAP_MODE=sandbox             # sandbox | live

4. Configure Webhook URL

Set the webhook endpoint in your Tap dashboard:

https://your-domain.com/tap/webhook

The package already registers this route automatically.

5. Clear Cached Configs

If your app uses config caching, run:

php artisan config:clear

6. Test the Integration

Use the Facade to create a test charge:

use Tap;

$charge = Tap::createCharge([
    'amount'   => 50,
    'currency' => 'USD',
    'customer' => [
        'first_name' => 'Test',
        'email'      => 'test@example.com',
        'phone'      => ['country_code' => '966', 'number' => '500000000'],
    ],
    'merchant' => ['id' => config('tap.merchant_id')],
    'source'   => ['id' => 'src_all'],
    'redirect' => ['url' => route('checkout.callback')],
    'description' => 'Order #1001',
    // ...any other Tap fields you need
]);

dd($charge);

If you see a JSON response with a charge_id, ๐ŸŽ‰ the package is working.

๐Ÿš€ Usage Examples

Create a Charge

$charge = Tap::createCharge([
    'amount'   => 50,
    'currency' => 'USD',
    'customer' => [
        'first_name' => 'Mohamed',
        'email'      => 'mohamed@example.com',
        'phone'      => ['country_code' => '966', 'number' => '500000000'],
    ],
    'merchant' => ['id' => config('tap.merchant_id')],
    'source'   => ['id' => 'src_all'],
    'redirect' => ['url' => route('checkout.callback')],
    'description' => 'Order #1234',
    // ...any other Tap fields you need
]);

Retrieve a Charge

$charge = Tap::retrieveCharge($charge['id']);

Refund a Charge

$refund = Tap::refundCharge($charge['id'], [
    'amount' => 50,
    'reason' => 'customer_request'
]);

๐Ÿ”” Webhooks

  • The package registers /tap/webhook automatically.
  • All requests are verified with TAP_WEBHOOK_SECRET.

Example: Listen for events

Event::listen('tap::charge.succeeded', function ($payload) {
    // Update your order, mark it as paid
});

๐Ÿงช Testing

composer test

This uses PHPUnit with Orchestra Testbench.

๐Ÿค Contributing

PRs are welcome!
Please run composer test before submitting.

๐Ÿ’ก Credits