laravel / cashier-stripe

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

[15.x] Check if the default payment method is valid #1684

Closed srmklive closed 1 month ago

srmklive commented 1 month ago

This PR adds a method hasValidDefaultPaymentMethod which checks whether the user has a valid default payment method stored on Stripe.

Currently in cashier, we can check whether a user has a default payment method through:

hasDefaultPaymentMethod only checks for payment type.
defaultPaymentMethod -- only gives the default payment method details.

This method will check:

driesvints commented 1 month ago

Bit confused here @srmklive. Why is hasDefaultPaymentMethod not enough for you? That should only return true if there's a valid default payment method in Stripe. Is that not happening for you?

srmklive commented 1 month ago

@driesvints the ``hasDefaultPaymentMethod method only returns if payment method type is set or not,

    /**
     * Determines if the customer currently has a default payment method.
     *
     * @return bool
     */
    public function hasDefaultPaymentMethod()
    {
        return (bool) $this->pm_type;
    }
driesvints commented 1 month ago

But this type is only set if there's a valid default payment method on the customer in stripe. So again: why do you specifically need this new method?

srmklive commented 1 month ago

We need this method is that they is no way to verify the default payment method in Cashier on Stripe. This method offers that check.

driesvints commented 1 month ago

I still don't understand sorry. The pm_type method is only filled out when there's a valid default payment method. I don't see how this new method is differently other than it invokes an API call to Stripe. I'm going to close this one now but if you at some point can offer a thorough explanation why this is different from the current hasDefaultPaymentMethod then I'll be happy to revisit.