Laravel Facade getting properties

Viewed 153

I'm trying to wrap the Stripe PHP library with a facade in Laravel. I'm aware that this already exists, but unfortunately it's using a deprecated Stripe API and is behaving unexpectedly.

So I created a Facade and a ServiceProvider and updated the configuration to reflect this.

This is working as expected. When I try to call a method on my Stripe facade/alias, it redirects to the StripeClient:

>>> Stripe::foo()
PHP Error:  Call to undefined method Stripe/StripeClient::foo() in ...

However, the Stripe api uses class constants, like so:

$stripe = new StripeClient(...);
$stripe->products->all();

But when I try to fetch these properties from the Facade, rather than redirecting to the StripeClient, it instead tries to get a class constant of the Stripe facade itself.

>>> Stripe::products->all()
PHP Fatal error:  Class constant 'App/Facades/Stripe::products' not found ...

So how do I do this?

0 Answers
Related