taut-id/payment

payment starter kit package

Fund package maintenance!
tautid

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/taut-id/payment

dev-main 2025-10-14 08:31 UTC

This package is not auto-updated.

Last update: 2025-10-14 10:53:59 UTC


README

A Laravel package for handling payment transactions with customizable state transitions and webhook integrations.

Installation

You can install the package via composer:

composer require tautid/payment

Publish the configuration file:

php artisan vendor:publish --tag="taut-payment-config"

Publish the webhook client migrations:

php artisan vendor:publish --provider="Spatie\WebhookClient\WebhookClientServiceProvider" --tag="webhook-client-migrations"

Publish the payment migrations:

php artisan vendor:publish --tag="taut-payment-migrations"
php artisan vendor:publish --provider="Spatie\WebhookClient\WebhookClientServiceProvider" --tag="webhook-client-config"

Run the migrations:

php artisan migrate

Important

Remove the default config in webhook-client after publishing.

This step is crucial to ensure proper configuration of the webhook client for your application.

Available Commands

This package provides two artisan commands:

1. Payment Due Command

Automatically changes pending payments to due status when they exceed their due date:

php artisan taut-payment:due

You can schedule this command to run periodically in your app/Console/Kernel.php:

protected function schedule(Schedule $schedule)
{
    $schedule->command('taut-payment:due')->hourly();
}

2. Make Transitions Command

Generates custom transition files for handling payment state changes:

Customizing Payment Transitions

You can add custom business logic to payment state changes by creating your own transition classes. This allows you to:

  • Send notifications when payments are completed
  • Update related models when payment status changes
  • Log payment activities for audit trails
  • Integrate with third-party services
  • Execute custom business rules

Creating Custom Transitions

Use the provided command to generate transition files:

php artisan taut-payment:make-transitions

This will create the following transition files in your app/Transitions/Payment/ directory:

  • ToCanceled.php - Executed when payment is canceled
  • ToCompleted.php - Executed when payment is completed
  • ToDue.php - Executed when payment becomes due
  • ToPending.php - Executed when payment becomes pending

Example Custom Transition

Each transition file extends the PaymentTransitionAbstract class. Here's an example of customizing the ToCompleted transition:

<?php

namespace App\Transitions\Payment;

use TautId\Payment\Abstracts\PaymentTransitionAbstract;
use TautId\Payment\Models\Payment;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Log;

class ToCompleted extends PaymentTransitionAbstract
{
    public function handle(Payment $record): void
    {
        // Your extra step
    }
}

Configuration

The transition namespace can be configured in your config/taut-payment.php:

'transitions_namespace' => 'App\\Transitions\\Payment',

This allows you to organize your transitions in a different namespace if needed.