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

Card details never updated #814

Closed aginev closed 5 years ago

aginev commented 5 years ago

Description:

When Billable::updateDefaultPaymentMethodFromStripe() has been called the Stripe customer returned has it's property default_source of type Stripe\Source that is passed as a parameter to Billable::fillSourceDetails($source). In that method the source is checked if instance of StripeCard or StripeBankAccount and because it's not one of this the card details will never be updated.

Steps To Reproduce:

Consider the case when the subscription is set to send invoice rather then charge automatically. In this scenario Stripe will send the invoice to the customer then he'll add his CC details and Stripe will issue an customer.updated event that should be handled at the webhook and add the CC details to the Billable model.

$customerId = 'cus_G7gjfeLOmIyK19';

/**
 * @see \Laravel\Cashier\Http\Controllers\WebhookController::getUserByStripeId()
 */
$model = config('cashier.model');
$billable = (new $model)->where('stripe_id', $customerId)->first();

if (!$billable) {
    $billable = Spark::team()->where('stripe_id', $customerId)->first();
}

if ($billable) {
    $billable->updateDefaultPaymentMethodFromStripe();
}

Hope it's clear enough

Regards

driesvints commented 5 years ago

Hey @aginev. We unfortunately don't support the old sources API anymore. Cashier makes use of the new Payment Methods API. If you have a specific issue with Spark, please contact Spark support.