How to keep in sync your customers details with Stripe in Laravel

Oliver Servín

There is a handy syncStripeCustomerDetails method available on Laravel Cashier for Stripe that lets you keep in sync your customers details.

So, when a customer updates their email or name details, it gets updated on Stripe too.

// App/Models/User.php

namespace App\Models;

use function Illuminate\Events\queueable;

class User extends Authenticatable
    // ...

    // listen for the updated User model event and invoke `syncStripeCustomerDetails`

    protected static function booted()
        static::updated(queueable(function ($customer) {

Code in action:

You can overwrite the attributes used to sync the information by adding the following methods stripeName, stripeEmail, stripePhone, and stripeAddress methods.