laravel / cashier-stripe

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.
https://laravel.com/docs/billing
MIT License
2.38k stars 679 forks source link

hasPaymentMethod() return false even if the user have several payment methods available #824

Closed rabol closed 4 years ago

rabol commented 4 years ago

Description:

hasPaymentMethod() return false even if the user have several payment methods available

Steps To Reproduce:

use addPaymentMethod() to add one or more payment methods

then call hasPaymentMethod()

It will return false even if the user have several payment methods

public function hasPaymentMethod() { return (bool) $this->card_brand; }

and if card_brand have never been updated, then it will always return false

driesvints commented 4 years ago

hasPaymentMethod determines if the Billable model has a default payment method. You'll need to add a default payment method first.

driesvints commented 4 years ago

Also: if you have your webhooks properly set up it'll always keep your default payment method in sync through the customer.updated event.

rabol commented 4 years ago

yes, but if the user don't have any of his payment methods marked as default, then it will not help

and the method is called hasPaymentMethod(), not hasDefaultPaymentMethod()

Calling addPaymentMethod() should update the 'card_brand' field

driesvints commented 4 years ago

@rabol the reason for this is that Cashier v10.x is the first version that supports multiple payment methods so this method wasn't renamed properly. I'll send in a PR to deprecate the current method and implement a new one.

Calling addPaymentMethod() should update the 'card_brand' field

Definitely not. That's only for the default payment method.

driesvints commented 4 years ago

Send in a PR for this here: https://github.com/laravel/cashier/pull/838