Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Nite's avatar
Level 1

Cashier - syncStripeCustomerDetails() throwing exception

I overrided the syncStripeCustomerDetails() method in my Billable model.

/**
  * Sync the customer's information to Stripe.
  *
  * @return \Stripe\Customer
  */
 public function syncStripeCustomerDetails()
 {
     $licenseInvoicingAddress = $this->company->licenseInvoicingAddress;

     // dd([
     //     'name' => $licenseInvoicingAddress->name,
     //     'email' => $licenseInvoicingAddress->email,
     //     'phone' => $licenseInvoicingAddress->phone,
     //     'address' => $licenseInvoicingAddress->getFormattedAddress(),
     // ]);

     return $this->updateStripeCustomer([
         'name' => $licenseInvoicingAddress->name,
         'email' => $licenseInvoicingAddress->email,
         'phone' => $licenseInvoicingAddress->phone,
         'address' => $licenseInvoicingAddress->getFormattedAddress(),
     ]);
 }

The dd test code returns the correct information.

If I recall correctly, this exact same code worked fine until a couple of weeks ago, maybe something changed on Stripe ? I also did a composer update, but nothing changed.

When this method is called, I get this exception :

message: "Invalid object", exception: "Stripe\Exception\InvalidRequestException",…}
exception: "Stripe\Exception\InvalidRequestException"
file: "D:\xampp\htdocs\dental-manager\vendor\stripe\stripe-php\lib\Exception\ApiErrorException.php"
line: 38
message: "Invalid object"

Maybe instead I should override all the customer information methods (like stripeName() etc...)... even though on the documentation it is written that it should also be possible to directly override syncStripeCustomerDetails() ?

Also note I'm using Stripe in test mode, maybe that does not allow to update customers ?

0 likes
1 reply
Nite's avatar
Nite
OP
Best Answer
Level 1

I found the problem : The address must be an array with this structure :

       // return [
        //     'city' => 'Little Rock',
        //     'country' => 'US',
        //     'line1' => '1 Main St.',
        //     'line2' => 'Apartment 5',
        //     'postal_code' => '72201',
        //     'state' => 'Arkansas',
        // ];

I was just returning a string.

2 likes

Please or to participate in this conversation.