Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jsrosas's avatar

use Stripe\Customer as StripeCustomer in Controller throws Error

Hi Everyone, I am having an issue trying to use StripeCustomer in a controller. I need to retrieve a customer from Stripe. So I have on my controller : use Stripe\Customer as StripeCustomer; I see in cashier's Billable.php being used this way. But I try to use it in the controller I get

Could not determine which URL to request: Stripe\Customer instance has invalid ID: Any ideas how to use Stripe\Customer within a controller? Is there a scope of namespace? Thanks in advance.

0 likes
8 replies
jsrosas's avatar

Well I am declaring the Stripe\Customer like this:

use Stripe\Customer as StripeCustomer;

And Im using it in my function like this:

$stripeCustomer = StripeCustomer::retrieve($admin->stripe_id);

I saw on the Billable calls that Stripe is being called like that :

use Stripe\Customer as StripeCustomer;

jsrosas's avatar

Yes @Francismori7 it returns the id of one of my test customers "cus_8gQFFsLjewyhiW" I am fetching and $admin from my DB who has already done a charge, he has a customer id which is what I'm trying to add to a new subscription. But before I do that I'd like to make sure that I can fetch the same customer from Stripe and verify the customer id.

jsrosas's avatar

Im beginning to think maybe require() will be easier.

enkay's avatar

Did you make sure the Customer ID and the Stripe keys are for the same Stripe environment and account?

Please or to participate in this conversation.