shopper/stripe package is a first-party Stripe driver for Shopper’s payment system. It uses Stripe PaymentIntents to handle card payments with full support for 3D Secure authentication, manual and automatic capture, partial refunds, and webhook processing.
Installation
stripe driver with the payment manager and merges the default configuration.
Configuration
Publish the config file:config/shopper/stripe.php:
.env:
Capture Method
Thecapture_method setting controls when funds are collected from the customer.
Manual capture is the default. When using manual capture, the payment status goes through
Pending → Authorized → Paid. The merchant captures from the order detail page when ready.
Authorization holds typically expire after 7 days (varies by card network). You must capture within that window or the hold is released and the customer is not charged.
Payment Method Setup
Create a payment method record linked to the Stripe driver. This makes it selectable at checkout.Payment Flow
The Stripe driver uses the PaymentIntent API. Here’s the complete flow for a checkout with manual capture:1. Initiate at Checkout
When the customer places an order, initiate the payment. The driver creates a Stripe PaymentIntent and returns aclientSecret for the frontend.
2. Confirm on the Frontend
On your payment page, use Stripe.js with the Payment Element to collect card details and confirm the payment:return_url.
3. Handle the Callback
On the callback page, verify the payment status:payment_status is now Authorized. With automatic capture, it goes straight to Paid.
4. Capture from the Admin Panel
When the order is ready to ship, the merchant clicks Capture payment on the order detail page. This callscapturePayment() on the Stripe driver and collects the funds.
The payment status changes from Authorized to Paid.
Webhooks
Stripe sends webhook events for asynchronous payment updates. The driver handles these events and converts them into standardized actions.Setting Up
-
In your Stripe Dashboard, create a webhook endpoint pointing to your application (e.g.
https://yourstore.com/webhooks/stripe) -
Copy the signing secret to your
.env:
- Create a webhook controller:
- Register the route (excluded from CSRF verification):
Handled Events
All other events are returned as
ignored.
Signature Verification
The driver verifies every webhook using the signing secret. If the signature is invalid, aStripeException is thrown. This prevents forged webhook payloads from being processed.
Refunds
The driver supports full and partial refunds through thePaymentProcessingService:
payment_status automatically updates to PartiallyRefunded or Refunded based on the total refunded amount compared to the order total.
Cancellation
Cancel an authorized payment before capture to release the hold without processing a refund:payment_status changes to Voided. No funds are collected and no refund fees apply.
Testing
Stripe Test Cards
Use Stripe’s test card numbers in test mode:Webhook Testing
Use the Stripe CLI to forward events to your local environment:STRIPE_WEBHOOK_SECRET during development.
Test Mode
Make sure your.env uses sk_test_ and pk_test_ keys. Stripe automatically isolates test data from live data.