online-payments/sdk-php
PHP SDK for integrating Online Payments into your app. Create and manage hosted checkouts, process card and local payments, handle refunds and payouts, and verify webhooks. Built for Laravel/PHP projects with clean models, API clients, and examples.
App\Services\PaymentGateway) with clear interfaces for:
Http client to wrap SDK calls, enabling middleware for retries, logging, and rate limiting.PaymentProcessed, PaymentFailed) to trigger business logic (e.g., inventory updates, notifications).config/services/payment.php with environment-specific overrides (e.g., sandbox/live).PaymentController@charge() → PaymentGateway::create()).Payment::created() → store payment_id).ProcessRefundJob) to queues.MockPaymentGateway) and integration tests with sandbox environments.Http client or Guzzle, adding middleware for:
AddApiKeyMiddleware.RetryFailedRequests middleware.monolog or Laravel Debugbar.$client = app(HttpClient::class)->withOptions([
'base_uri' => config('services.payment.api_url'),
'headers' => ['Authorization' => 'Bearer ' . config('services.payment.key')],
]);
class Payment extends Model {
protected $casts = ['metadata' => 'array'];
public static function boot() {
static::created(fn ($payment) => PaymentGateway::create($payment));
}
}
POST /payment/webhook) with:
signed routes.PaymentWebhookReceived).phpunit and pestphp using mocked SDK responses. Validate against Laravel’s LTS (e.g., 10.x) and PHP 8.1+.Cache::remember) or SDK-specific idempotency keys.failed_jobs table for retries and dead-letter queues.ProcessPaymentJob) with queue monitoring (e.g., Horizon).PaymentGatewayException with HTTP status codes)?Number package intervene?logs table or a custom payments table integrate with SDK events?$app->singleton(PaymentGateway::class, fn () => new OnlinePayments(
config('services.payment.key'),
config('services.payment.secret'),
config('services.payment.env')
));
Payment::charge()) while keeping core logic in a service class.Gate::define('create_payment')) to restrict access.Http client, adding middleware for:
LogRequests middleware.RetryFailedRequests middleware.ThrottleRequests middleware.$client = app(HttpClient::class)->withOptions([
'base_uri' => config('services.payment.api_url'),
'headers' => ['X-API-Key' => config('services.payment.key')],
]);
class Payment extends Model {
protected $dispatchesEvents = [
'created' => PaymentCharged::class,
'updated' => PaymentRefunded::class,
];
}
Modules/Payments).amount in cents").^8.1) and Laravel (e.g., ^10.0) versions in composer.json.platform-check to resolve dependency conflicts (e.g., Guzzle, Symfony components).| Environment | PHP | Laravel | SDK Version | Notes |
|---|---|---|---|---|
| Local (Docker) | 8.2 | 10.x | 1.0.* | Use valet or laravel-sail |
| CI (GitHub Actions) | 8.1 | 9.x | 1.0.* | Test oldest supported |
| Staging | 8.1 | 10.x | 1.0.* | Mirror production |
php artisan vendor:publish --tag=payment-config)..env with provider credentials.PaymentService class to wrap SDK methods.Payment::charge()).ProcessRefundJob).database or redis).POST /payment/webhook) with Laravel’s Route::post.PaymentWebhookHandled).monolog channel for payment events).laravel-metrics for success/failure rates).config/services/payment.php with environment overrides.config:cache for runtime optimization.How can I help you explore Laravel packages today?