'Legacy product', 'is_active' => true, 'setup_fee' => 0, ]); $product->id = 4; $product->setRelation('pricings', new Collection([ new ProductPricings([ 'billing_cycle' => 'semiannually', 'price' => 7200000, 'currency' => 'VND', ]), new ProductPricings([ 'billing_cycle' => 'one_time', 'price' => 15000000, 'currency' => 'VND', ]), ])); $data = (new ProductResource($product))->resolve(request()); $this->assertSame('7200000.00', $data['price_semiannually']); $this->assertSame('15000000.00', $data['price_onetime']); $this->assertSame('recurring', $data['billing_type']); } public function test_legacy_one_time_only_product_uses_frontend_billing_value(): void { $product = new Product([ 'name' => 'One-time product', 'is_active' => true, 'setup_fee' => 0, ]); $product->id = 5; $product->setRelation('pricings', new Collection([ new ProductPricings([ 'billing_cycle' => 'one_time', 'price' => 15000000, 'currency' => 'VND', ]), ])); $data = (new ProductResource($product))->resolve(request()); $this->assertSame('onetime', $data['billing_type']); $this->assertSame('15000000.00', $data['price_onetime']); } }