webtopay/libwebtopay
The WebToPay PHP library integrates Paysera’s Checkout API for collecting online payments via many methods and validating transferred/received security parameters. Install via Composer or the all-in-one WebToPay.php file.
Architecture fit
webtopay/libwebtopay is a thin, framework-agnostic SDK for Paysera's Checkout (payment gateway) API. It is not a Laravel package: there is no service provider, no facade, no publishable config, and no package discovery. The README shows a global-namespace class consumed as use WebToPay; — i.e. static-facade calls from arbitrary application code, with three supported installation shapes (merged WebToPay.php, src/includes.php, Composer).
For a Laravel codebase this is a driver, not a component. The correct architecture is:
App\Payments\Paysera adapter implementing a first-party contract (CheckoutGateway::initiate(), ::verifyCallback(), ::refund() if supported), bound in a service provider.WebToPay:: calls in controllers, jobs, or domain services — otherwise the static API becomes untestable and unswappable.config/payments.php fed from .env/secret manager: project ID, sign password, Paysera public key, merchant private key, callback URL, environment (test vs. live).Integration feasibility
High. Composer install, a config block, two routes (initiate + callback), one queued job. Realistic estimate: 2–4 engineer-days for an MVP redirect flow, another 3–5 days for idempotency, reconciliation, admin tooling, and tests. The library's value is narrow but real: request signing, SS1/SS2 callback parameter validation, and encoding/format edge cases you would otherwise get wrong.
Technical risk
^3.0 is documented as PHP 7.4-era (strict types, type hints) with an unchanged interface from ^2.0. PHP 8.2/8.3 compatibility is unverified from the README; a CI matrix is required before committing. The global class name also rules out clean mocking without an adapter.WebToPay.php into application source, or patching it in-tree, changes that analysis. Route to legal before build, not after.Key questions
^3.0, and is there an 8.x-tested release?Stack fit
Laravel 10–12 on PHP 8.1+. Because the library is not PSR-4 namespaced, wrap it: a single PayseraGateway class that composes the static API, injected via constructor into a PaymentService. Bind in AppServiceProvider (or a dedicated PaymentServiceProvider) as a singleton. Keep all WebToPay:: references inside that one file so the blast radius of an API change is one class.
Config surface:
PAYSERA_PROJECT_ID=
PAYSERA_SIGN_PASSWORD=
PAYSERA_PUBLIC_KEY_PATH= # Paysera's key, for callback verification
PAYSERA_PRIVATE_KEY_PATH= # merchant key, for request signing
PAYSERA_CALLBACK_URL=
PAYSERA_ENV=test|live
Keys belong in a secret manager mounted to a path, never in the repo or .env committed to source control.
Migration path
WebToPay:: call sites in three steps — (a) extract each call site into the adapter with identical behavior and no refactor, (b) capture recorded callback payloads and write validation tests against the adapter, (c) swap call sites one route at a time behind a feature flag. Pin the current major version for the duration; do not combine a version bump with the extraction.Compatibility
^3.0) and commit composer.lock; set config.platform.php to the production runtime so CI and deploys agree.class_alias to fake a namespace — it breaks static analysis and container resolution.withoutMiddleware(VerifyCsrfToken::class), outside auth/verified, and rate-limited by IP with a generous ceiling. Log the full payload (redacting keys) for forensic replay.Sequencing
CheckoutGateway contract and adapter; write fixtures from step 2 and unit-test signature verification both ways.Maintenance
The library itself should change rarely — it is a stable, first-party protocol wrapper. Ongoing cost is the adapter and the payment domain: budget ~0.5 engineer-day per month for dependency updates, PHP deprecation fixes, and Paysera API notices. The real liability is that a 7.4-era package will accumulate PHP 8.x friction faster than a modern one; schedule a quarterly compatibility check rather than reacting to a failed deploy.
Support
Vendor support flows through Paysera's merchant channel and developer documentation, which is adequate for a first-party PSP. Internally you need a written runbook covering the three recurring incidents: order stuck pending (callback lost), signature mismatch (key rotation or config drift), and duplicate fulfillment (idempotency breach). Support staff need merchant-portal access to look up transactions manually — without it, every discrepancy becomes an engineering escalation.
Scaling
Effectively negligible. The library is stateless and CPU-light; RSA verification per callback is sub-millisecond. Callback volume is bounded by payment volume, which is orders of magnitude below application traffic. The only scaling concerns are the callback endpoint's response time (keep work off the request thread, defer to queues) and DB row contention on hot order records under retry storms — solved with row-level locking or an append-only payment-events table with a unique constraint on the gateway reference.
Failure modes
Ramp-up
One backend engineer reaches productivity in 2–3 days; the library is small and the README is sufficient to get a sandbox payment working. The expensive knowledge is domain, not package: payment state machines, signature validation discipline, minor-unit arithmetic, reconciliation, and refund/chargeback handling. Document the payment lifecycle and the SS2 validation checklist before go-live, and run a tabletop exercise on refund and chargeback scenarios — none of which the library documentation will teach you.
How can I help you explore Laravel packages today?