Installation Add the package via Composer:
composer require nokimaro/liontech-laravel
No manual registration is needed—auto-discovery handles it.
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
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',
));
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);
}
}
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'),
);
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
}
}
}
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,
]);
}
}
Check if the package is configured:
use Nokimaro\LionTech\Laravel\Config\LionTechConfig;
if (!LionTechConfig::isConfigured()) {
abort(500, 'LionTech not configured');
}
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.
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.
Webhook Payload Parsing
Always use WebhookPayload::fromJson() (SDK v1.1.3+) instead of manual parsing. Example:
$webhook = WebhookPayload::fromJson($request->getContent());
if ($webhook->isSuccessful()) { ... }
Multi-Tenant Clients
Avoid injecting the singleton Client if using multi-tenant. Instantiate clients manually per tenant to isolate credentials.
php artisan config:clear if changes to .env aren’t reflected.\Log::debug('Webhook payload:', $request->getContent());
LIONTECH_SANDBOX=true) before going live.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');
}
}
Override Config Publish the config file for customization:
php artisan vendor:publish --tag=liontech-config
Mocking for Tests
Use Laravel’s container to mock the Client:
$this->app->instance(\Nokimaro\LionTech\Client::class, $mockClient);
401 Unauthorized errors.How can I help you explore Laravel packages today?