ashrafic/bagisto-clover
Ashrafic Bagisto Clover is a Laravel package that integrates the Clover payment gateway with Bagisto, enabling online stores to accept secure card payments at checkout. It adds Clover as a payment method, helping merchants deliver a smoother ecommerce experience.
ashrafic/bagisto-clover is a Bagisto (Laravel e-commerce) payment-gateway integration for Clover. Treat it as a payment method package, not a general-purpose utility: nearly everything you touch will be a Bagisto payment abstraction, a config key, or a Clover API call.
First steps:
composer require ashrafic/bagisto-clover in a Bagisto application (not a bare Laravel app — Bagisto's Webkul\Payment contracts and payment_methods config are hard dependencies).composer.json before installing. This is the single most important step for v3.0.0 (see Gotchas). Confirm the bagisto/bagisto / webkul/* constraint range matches your store's version, and confirm the PHP constraint.php artisan vendor:publish --provider="Ashrafic\Clover\CloverServiceProvider" --tag=config
The package's service provider (auto-discovered) is the map of the whole package — check whether it registers a payment method, a route group for webhooks/callbacks, a view namespace for the checkout form, and any migrations..env: Clover merchant ID plus the API token / OAuth access token for your environment. Keep sandbox and production values in separate env blocks — do not swap them by editing config files.If the provider name or tag above doesn't match, run php artisan vendor:publish with no arguments and look for the Clover entry — never guess the tag in a deployment script.
Extend the payment method, don't bypass it. Bagisto resolves payment methods from config into classes implementing its payment contract. Keep any store-specific behaviour (extra logging, order comments, fee surcharges) in a subclass registered via the config key rather than by editing vendor code, so composer update stays safe.
Configuration layering. Keep package defaults in config/clover.php untouched; put per-store overrides in config/services.php or an env-driven block, and remember php artisan config:cache in every deploy. Payment packages are the classic victim of a cached config holding a stale sandbox key.
Server-side charge creation, webhook-confirmed status. The reliable pattern is: Bagisto creates the order in a pending state → you create the Clover charge/session server-side using the order total and a generated idempotency key → the customer pays on Clover → the browser returns to your success route and Clover posts a webhook. Trust the webhook for fulfilment, use the return route only for UX. Make both routes idempotent on the Clover charge/payment ID so a double callback doesn't create a second invoice or duplicate shipment.
Order lifecycle hooks. Bagisto emits events around order placement and invoice creation; hook the invoice-paid path to capture/settle if you're doing auth-then-capture. For refunds, Bagisto's admin refund action is the right seam — map it to the Clover refund endpoint and record the Clover reference on the transaction so support can reconcile.
Testing. Use Http::fake() against the Clover client for unit tests of success, decline, and timeout paths, and assert on order payment state rather than on the outgoing payload where possible. Run one manual sandbox purchase per release — gateway packages rarely have integration coverage that catches API drift.
Multi-store and multi-currency. If the package resolves credentials from a single config key, add a small resolver keyed on store()->id early. Retrofitting multi-store credentials after go-live is painful because orders already reference the old merchant.
v2.0.5...v3.0.0 compare link. A major bump on a payment package means you must read the diff yourself before upgrading. Review at minimum: the service provider, the payment method class, any published config file, and the gateway client's request/response shapes. Assume breaking changes to config keys, class namespaces, and the Clover API version used.--force overwrites — copy it aside first), clear config and view caches, and run a sandbox transaction before merging. Payment bugs surface at checkout, not in CI.Webkul classes that move between Bagisto releases. If your Bagisto version is outside the newly declared constraint, composer will silently hold you on v2.x — check composer why-not rather than assuming the upgrade happened.getRedirectUrl/getPaymentView style hooks), the config file's endpoint base URL (point this at a mock server for local work), and the events the package dispatches, if any. If it dispatches none, add your own via an observer on order payment state so downstream systems (ERP, email) don't depend on the gateway.How can I help you explore Laravel packages today?