CryptomusService or integrated into existing payment gateways (e.g., PaymentGatewayInterface).url_callback), enabling async event handling (e.g., transaction status updates) via Laravel’s queue:work or Horizon (Laravel Echo).Cryptomus) for cleaner syntax (e.g., Cryptomus::payout()->create($data)).CryptoTransaction).Http client can replace it if needed.RequestBuilderException integrates with Laravel’s exception handling (e.g., render() in App\Exceptions\Handler).PaymentGateway contract). Use Laravel’s Mockery or Pest for SDK interactions.| Risk | Mitigation Strategy | Severity |
|---|---|---|
| Deprecated API | Monitor Cryptomus’s API docs for breaking changes. Use a wrapper layer to isolate SDK calls. | Medium |
| No Type Safety | Add PHP 8.0+ type hints to SDK methods via a decorator pattern or fork. | Low |
| Webhook Reliability | Implement retry logic (e.g., Laravel’s retry() helper) for failed callbacks. |
High |
| PHP Version Support | Drop PHP 5.6 support; enforce PHP 8.0+ in composer.json for modern Laravel (v9+). |
Medium |
| No Rate Limiting | Add exponential backoff in a Laravel middleware or SDK wrapper. | Medium |
| Lack of Observability | Instrument SDK calls with Laravel’s logging (\Log::debug()) or OpenTelemetry. |
High |
IdempotencyMiddleware.Client class or use a config-based approach.payment->info())? If not, implement Laravel’s cache() or Redis.CryptoTransactionObserver).benchmark() helper.spatie/fruitful) or fallback to another gateway.$this->app->singleton(CryptomusClient::class, function ($app) {
return new \Cryptomus\Api\Client(
config('services.cryptomus.payment_key'),
config('services.cryptomus.merchant_uuid')
);
});
config/services.php:
'cryptomus' => [
'payment_key' => env('CRYPTOMUS_PAYMENT_KEY'),
'payout_key' => env('CRYPTOMUS_PAYOUT_KEY'),
'merchant_uuid' => env('CRYPTOMUS_MERCHANT_UUID'),
'callback_url' => env('CRYPTOMUS_CALLBACK_URL'),
],
.env for secrets (never commit keys).// Dispatch a job for payout creation
PayoutJob::dispatch($data)->onQueue('cryptomus');
event(new CryptoPaymentCreated($paymentData));
Listen with:
CryptoPaymentCreated::subscribe(CryptoPaymentSubscriber::class);
Phase 1: Proof of Concept (1–2 weeks)
CryptomusService class with basic methods.Phase 2: Laravel Integration (2–3 weeks)
CryptoTransaction).Phase 3: Production Readiness (1–2 weeks)
| Component | Compatibility Notes |
|---|---|
| Laravel Version | Tested on Laravel 8+ (PHP 8.0+). Use laravel/framework:^9.0 for PHP 8.1+ features. |
| PHP Extensions | Requires json and curl. Ensure these are enabled in php.ini. |
| Database | No strict requirements, but recommend PostgreSQL/MySQL for transaction tables. |
| Caching | Use Laravel’s cache (Redis/Memcached) for rate-limiting or frequent API calls. |
| Queues | Supports Laravel Queues for async operations (e.g., database, redis, beanstalkd). |
| Webhooks | Requires a public endpoint for callbacks. Use Laravel’s route:model or a dedicated controller. |
Prerequisites:
.env).Installation:
composer require cryptomus/api-php-sdk
Configuration:
config/services.php.php artisan vendor:publish --provider="CryptomusServiceProvider"
Core Integration:
app/Services/CryptomusService.php):
namespace App\Services;
use Cryptomus\Api\Client;
class CryptomusService {
public function __construct(
protected Client $paymentClient,
protected Client $payoutClient
) {}
public function createPayment(array $data) {
return $this->paymentClient->create($data);
}
}
AppServiceProvider:
$this->app->bind(CryptomusService::class, function ($app) {
return new CryptomusService(
Client::payment(config('services.cryptomus.payment_key'), config('services.cryptomus.merchant_uuid')),
Client::payout(config('services.cryptomus.payout_key'), config('services.cryptomus.merchant_uuid'))
);
});
Webhook Handling:
How can I help you explore Laravel packages today?