PayZephyr: One Payment API for Stripe, Paystack, and PayPal
Managing multiple payment gateways in a Laravel application usually means juggling separate SDKs, inconsistent response shapes, and duplicated integration logic. PayZephyr, a package by Nwaneri Chukwunyere Kenneth, solves this by placing eight payment providers behind a single, fluent Payment facade.
Supported Providers
Out of the box, PayZephyr ships drivers for:
- Paystack
- Stripe
- PayPal
- Flutterwave
- Square
- Monnify
- OPay
- Mollie
All eight providers share the same API surface, so switching or adding a provider requires minimal code changes.
Taking a Payment
Initiating a checkout is straightforward. Chain the amount, customer email, a unique reference, and a callback URL onto the Payment facade, then call redirect():
use KenDeNigerian\PayZephyr\Facades\Payment;
Route::get('/checkout', function (Order $order) {
return Payment::amount(500.00)
->email($order->user->email)
->reference('order_'.$order->id)
->callback(route('payment.callback'))
->redirect();
});
When the customer returns, verify the transaction reference on your callback route:
Route::get('/payment/callback', function (Request $request) {
$verification = Payment::verify($request->query('reference'));
if ($verification->isSuccessful()) {
// Mark the order paid.
}
})->name('payment.callback');
Automatic Failover
PayZephyr supports a primary and a fallback provider configured via environment variables. If the default provider fails, the package automatically retries with the fallback:
PAYMENTS_DEFAULT_PROVIDER=paystack
PAYMENTS_FALLBACK_PROVIDER=stripe
This is particularly useful for applications serving markets where provider availability can vary.
Subscriptions
For SaaS products, PayZephyr exposes a subscription API. Create a plan with planData() and a SubscriptionPlanDTO, then subscribe a customer to it:
$plan = Payment::subscription()
->planData(new SubscriptionPlanDTO(
name: 'Pro Monthly',
amount: 20.00,
interval: 'monthly',
currency: 'USD',
))
->with('stripe')
->createPlan();
Payment::subscription()
->customer($user->email)
->plan($plan->planCode)
->idempotency()
->with('stripe')
->subscribe();
Subscription support depends on the underlying provider's capabilities.
Refunds
Full and partial refunds are supported. Pass an amount() for a partial refund, or omit it for a full refund:
$refund = Payment::refund('txn_ref_123')
->amount(25.00)
->reason('customer requested partial refund')
->with('paystack')
->refund();
Because some providers settle refunds asynchronously, check $refund->isPending() and handle the final status via a signed webhook.
Additional Features
- Double-charge protection — prevents a customer from being billed twice for the same transaction
- Signed webhooks — signature verification and replay prevention built in
- Custom drivers — extend the package with your own provider implementation
- Queue integration — documented in the official docs for async payment flows
Installation
Install via Composer and run the provided Artisan command:
composer require kendenigerian/payzephyr
php artisan payzephyr:install
The official documentation covers custom drivers, queue integration, and a production checklist. A playground is also available for testing the API without a local install.
Key Takeaways
- One
Paymentfacade covers eight providers: Paystack, Stripe, PayPal, Flutterwave, Square, Monnify, OPay, and Mollie - Automatic failover is configured with two environment variables
- Subscriptions, full refunds, and partial refunds are first-class features
- Double-charge protection and signed webhook verification are built in
- A playground lets you explore the API before installing anything
Source: PayZephyr: One Payment API for Stripe, Paystack, and PayPal — Laravel News