Search code examples
laravellaravel-5stripe-paymentslaravel-5.3laravel-cashier

Get Stripe Customer Details in Laravel 5.3 with Cashier 7.0


In Laravel 5.1 with Cashier ~5.0, I used to get Stipe Customer details of that user like this:

$customer = $user->subscription()->getStripeCustomer();

After updating to Laravel 5.3 with Cashier ~7.0, I changed the above line in controller to this:

$customer = $user->subscription('main')->getStripeCustomer();

Since the update, I am now getting the error:

BadMethodCallException in Builder.php line 2440: 
Call to undefined method Illuminate\Database\Query\Builder::getStripeCustomer()

How can I get Stripe Customer Details in Laravel 5.3 with Cashier ~7.0?


Solution

  • You can get Stripe Customer with $user->asStripeCustomer()