laravel / cashier-paddle

Cashier Paddle provides an expressive, fluent interface to Paddle's subscription billing services.
https://laravel.com/docs/cashier-paddle
MIT License
238 stars 57 forks source link

Integrity constraint violation: 1048 Column 'billable_id' cannot be null #265

Closed ricksonchew closed 2 months ago

ricksonchew commented 2 months ago

Cashier Paddle Version

2.4

Laravel Version

10.48.12

PHP Version

8.3

Database Driver & Version

No response

Description

When creating a customer using createAsCustomer(), billable_id is not passed and saved thus an error occur.

Steps To Reproduce

On your webhook controller:

use App\Models\User;

$user = new User();
$customer = $user->createAsCustomer($request->data);
crynobone commented 2 months ago

You need to save the $user for this to work.

ricksonchew commented 2 months ago

Thanks @crynobone , saving data in the User model works as it is now getting the id from the users table. However, my use case is that the user is already registered and has a data already on the users table in which I want it to "sync" on to the customers table. I tried getting the data of the user but no avail.

$users = new Users();
$user = $users->where('email', 'customer01@email.com')->first();
$users->createAsCustomer(array_merge($request->data, ['id' => $user->id]));
bluzeey commented 2 months ago

I am getting the same error , however for me , the name value is being null.