nordkit/svea
Modern PHP SDK for Svea Checkout, Payment Admin, webhook subscriptions and inbound webhook verification. Fluent API with typed value objects, retries, idempotency, async task polling, and a robust testing fake. Includes first-class Laravel integration.
when(), unless()) enhances readability and maintainability, especially for complex order flows.SveaClient instantiation, improving flexibility.SveaWebhookReceived event decouple webhook processing from routes, aligning with Laravel’s event-driven architecture.Svea::fake() mimics HTTP interactions (similar to Laravel’s Http::fake()), enabling isolated unit/feature tests without external dependencies.illuminate/support for facades/artisans may introduce version constraints (Laravel 11–13). Non-Laravel users must handle configuration manually.29900 for 299.00 SEK) demands careful validation in application logic to avoid arithmetic errors.webhook_secret or Svea-Signature handling could expose endpoints to replay attacks. Requires rigorous validation in middleware.Laravel Version Compatibility:
illuminate/support?Error Handling Strategy:
SveaApiException hierarchies be mapped to application-level errors (e.g., retries vs. user notifications)?Webhook Scaling:
Testing Coverage:
Svea::fake() suffice for all test scenarios, or are additional mocks needed for edge cases (e.g., retries, async tasks)?Idempotency in Queues:
unique() or uniqueForJob to deduplicate jobs by idempotency key.SveaClient with minimal overhead.SveaWebhookReceived events enable decoupled processing, aligning with Laravel’s event system (e.g., broadcasting, queues).nordkit/svea in a single feature (e.g., subscriptions).Svea::fake() to test in isolation before cutting over..env, config/svea.php) and remove legacy Svea SDK code.Svea::fake() to ensure full coverage.php artisan vendor:publish --tag=svea-config) and set .env variables.php artisan svea:subscription:add) and implement the SveaWebhookReceived event listener.Svea::checkout()->create()).Svea::admin()->order()->deliver().Svea::fake() and add assertions for Svea-specific responses (e.g., Svea::assertCreated()).composer update nordkit/svea) are straightforward due to clear versioning and changelog..env and config/svea.php simplify environment-specific tweaks (e.g., test/production URLs).guzzlehttp/guzzle and illuminate/support for breaking changes, especially if using Laravel outside 11–13.svea:subscription:list/get provide visibility into subscription statuses.SveaApiException hierarchy aids in pinpointing issues (e.g., 401 Unauthorized vs. 429 Too Many Requests).TaskResponse) requires application-level handling (e.g., retry queues).SVEA_MAX_RETRIES) prevents overload during spikes.SveaClient instances scale horizontally; no shared state between requests.HandlerStack) for high-volume APIs.orders table). Webhook events can be logged to a svea_webhooks table if auditing is needed.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Webhook signature mismatch | Silent drops or security breaches | Validate Svea-Signature in middleware; log failures. |
| Svea API downtime | Checkout/Admin operations fail | Implement retries with exponential backoff; notify users. |
| Idempotency key collisions | Duplicate payments/credits | Use UUIDs or database sequences for keys; validate uniqueness. |
| Async task polling timeout | Stuck HTTP 202 responses | Set reasonable timeouts; implement dead-letter queues for unresolved tasks. |
Configuration errors (e.g., wrong shared_secret) |
All API calls fail | Validate config on boot; use .env.example to prevent misconfigurations. |
Svea::fake() for testing; avoid touching production APIs until ready..env requirements and WiretapHow can I help you explore Laravel packages today?