Closed devinfd closed 2 months ago
We don't have any plan for this, please refer to the answer provided via https://github.com/laravel/cashier-paddle/issues/267#issuecomment-2242258114
It's a dirty solution but works for now. For reference for others in the future:
use App\Models\User;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Str;
use Laravel\Paddle\Cashier;
Http::fake([
Cashier::apiUrl().'/*' => Http::response([
'data' => [[
'id' => Str::random(),
'name' => 'Test User',
'email' => 'test@example.com',
]]
]),
]);
$user = User::factory()->withPersonalTeam()->create([
'name' => 'Test User',
'email' => 'test@example.com',
]);
Cashier Paddle Version
2.5.2
Laravel Version
11.23.5
PHP Version
8.3.11
Database Driver & Version
SingleStore
Description
When seeding the database for testing or local development the developer is required to be connected to the internet so that
ManagesCustomer@createAsCustomer
can make API calls to Paddle. I tried to seed a Customer first and attach that to the User however that is not possible because the billable_id and billable_type columns on the Customer are required. Therefore in order to create the "billable" values the User must first be created which then in-turn calls thecreateAsCustomer
method and thus reintroducing the original problem.Ultimately API calls to 3rd party services should not be called when seeding or testing. re: https://github.com/laravel/cashier-paddle/issues/267
Steps To Reproduce
Turn the internet off and try to seed the database with either a User or Team model as the billable.