Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Liontech Laravel Laravel Package

nokimaro/liontech-laravel

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Installation Add the package via Composer:

    composer require nokimaro/liontech-laravel
    

    No manual registration is needed—auto-discovery handles it.

  2. Configure Environment Add these to your .env:

    LIONTECH_ACCESS_TOKEN=your_access_token
    LIONTECH_REFRESH_TOKEN=your_refresh_token
    LIONTECH_SANDBOX=true  # Set to false for production
    LIONTECH_BASE_URL=https://api.fusionpayments.io
    LIONTECH_SECURE_URL=https://secure.fusionpayments.io
    
  3. First Use Case Create a payment order via the facade:

    use Nokimaro\LionTech\Laravel\Facades\LionTech;
    use Nokimaro\LionTech\Requests\CreateOrderRequest;
    use Nokimaro\LionTech\ValueObjects\Currency;
    use Nokimaro\LionTech\ValueObjects\Money;
    
    $order = LionTech::orders()->create(new CreateOrderRequest(
        amount: new Money('100.00', Currency::USD),
        description: 'Order #1234',
        successUrl: 'https://your-site.com/success',
        declineUrl: 'https://your-site.com/decline',
        webhookUrl: 'https://your-site.com/webhook',
    ));
    

Implementation Patterns

Dependency Injection

Inject the Client or specific clients into controllers/services:

use Nokimaro\LionTech\Clients\PaymentsClient;

class PaymentController extends Controller
{
    public function __construct(private PaymentsClient $payments) {}

    public function processPayment()
    {
        $payment = $this->payments->create($request);
    }
}

Multi-Tenant Support

For multi-tenant apps, instantiate the client directly:

use Nokimaro\LionTech\Client;

$client = new Client(
    accessToken: $tenant->liontech_access_token,
    refreshToken: $tenant->liontech_refresh_token,
    baseUrl: config('liontech.base_url'),
    secureUrl: config('liontech.secure_url'),
);

Webhook Handling

Verify signatures and parse payloads:

use Nokimaro\LionTech\Security\WebhookSignatureVerifier;
use Nokimaro\LionTech\ValueObjects\WebhookPayload;

class WebhookController extends Controller
{
    public function handle(Request $request, WebhookSignatureVerifier $verifier)
    {
        if (!$verifier->verify($request->headers->all(), $request->getContent())) {
            abort(403);
        }

        $webhook = WebhookPayload::fromJson($request->getContent());
        if ($webhook->isSuccessful()) {
            // Handle success
        }
    }
}

Card Encryption

Encrypt card data before sending to LionTech:

use Nokimaro\LionTech\Security\CardEncryptor;

class PaymentController extends Controller
{
    public function __construct(private CardEncryptor $encryptor) {}

    public function encryptCard()
    {
        $encrypted = $this->encryptor->encryptForPayment([
            'pan' => '4405639704015096',
            'cvv' => '123',
            'exp_month' => 12,
            'exp_year' => 2030,
        ]);
    }
}

Configuration Validation

Check if the package is configured:

use Nokimaro\LionTech\Laravel\Config\LionTechConfig;

if (!LionTechConfig::isConfigured()) {
    abort(500, 'LionTech not configured');
}

Gotchas and Tips

Key Pitfalls

  1. Empty Config Values Empty strings in .env (e.g., LIONTECH_WEBHOOK_PUBLIC_KEY=) are treated as null, triggering API key fallback. Ensure non-empty values or set explicit keys.

  2. Card Encryption Key Fix In versions <1.1.0, CardEncryptor incorrectly used the webhook signature key instead of the card encryption key. Update to the latest version or explicitly set LIONTECH_CARD_ENCRYPTION_PUBLIC_KEY.

  3. Webhook Payload Parsing Always use WebhookPayload::fromJson() (SDK v1.1.3+) instead of manual parsing. Example:

    $webhook = WebhookPayload::fromJson($request->getContent());
    if ($webhook->isSuccessful()) { ... }
    
  4. Multi-Tenant Clients Avoid injecting the singleton Client if using multi-tenant. Instantiate clients manually per tenant to isolate credentials.

Debugging Tips

  • Check Config Use php artisan config:clear if changes to .env aren’t reflected.
  • Log Webhook Payloads Log raw payloads during development to debug:
    \Log::debug('Webhook payload:', $request->getContent());
    
  • Sandbox Mode Always test in sandbox (LIONTECH_SANDBOX=true) before going live.

Extension Points

  1. Custom Clients Extend the base Client class to add custom endpoints:

    class CustomClient extends \Nokimaro\LionTech\Client
    {
        public function customEndpoint()
        {
            return $this->get('/custom-endpoint');
        }
    }
    
  2. Override Config Publish the config file for customization:

    php artisan vendor:publish --tag=liontech-config
    
  3. Mocking for Tests Use Laravel’s container to mock the Client:

    $this->app->instance(\Nokimaro\LionTech\Client::class, $mockClient);
    

Performance Notes

  • Eager Loading The package registers all clients as singletons upfront, so no lazy-loading overhead.
  • Token Refresh The SDK handles token refreshes automatically. Avoid manual retries for 401 Unauthorized errors.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
symfony/ai-symfony-mate-extension
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata