FakeGateway driver that processes all billing operations in memory. You can create subscriptions, apply coupons, charge customers, and simulate failures without any external credentials or network calls. This makes it straightforward to write fast, deterministic tests in CI.
Configure the fake gateway
Set the default gateway tofake in your test bootstrap or base test case. No other configuration is required.
Subscribd::for($user)->... exactly as it would in production. The fake driver intercepts every operation transparently.
Create a subscription in a test
Simulate a charge failure
CallshouldFailNextCharge() on the fake gateway instance before the charge. The next charge attempt will throw a RuntimeException.
Simulate a subscription creation failure
CallshouldFailNextSubscription() to make the next subscription creation throw:
The FakeGateway is never cached
GatewayManager does not cache the fake driver — each call to Subscribd::gateway('fake') returns a fresh instance. If you need to set a failure flag before an action runs, store the instance first:
The FakeGateway processes all billing operations in memory with no external calls. It is safe to use in CI without any gateway credentials configured.