Checkout‑Registrierung validiert jetzt die E‑Mail‑Länge, und die Checkout‑Flows sind Paddle‑only: Stripe‑Endpoints/
Services/Helpers sind entfernt, API/Frontend angepasst, Tests auf Paddle umgestellt. Außerdem wurde die CSP gestrafft und Stripe‑Texte in den Abandoned‑Checkout‑Mails ersetzt.
This commit is contained in:
66
tests/Feature/Tenant/TenantPaddleCheckoutTest.php
Normal file
66
tests/Feature/Tenant/TenantPaddleCheckoutTest.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Tenant;
|
||||
|
||||
use App\Models\Package;
|
||||
use App\Services\Paddle\PaddleCheckoutService;
|
||||
use Mockery;
|
||||
|
||||
class TenantPaddleCheckoutTest extends TenantTestCase
|
||||
{
|
||||
protected function tearDown(): void
|
||||
{
|
||||
Mockery::close();
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function test_tenant_can_create_paddle_checkout(): void
|
||||
{
|
||||
$package = Package::factory()->create([
|
||||
'paddle_price_id' => 'pri_test_123',
|
||||
'price' => 129,
|
||||
]);
|
||||
|
||||
$checkoutService = Mockery::mock(PaddleCheckoutService::class);
|
||||
$checkoutService->shouldReceive('createCheckout')
|
||||
->once()
|
||||
->withArgs(function ($tenant, $payloadPackage, array $payload) use ($package) {
|
||||
return $tenant->is($this->tenant)
|
||||
&& $payloadPackage->is($package)
|
||||
&& array_key_exists('success_url', $payload)
|
||||
&& array_key_exists('return_url', $payload);
|
||||
})
|
||||
->andReturn([
|
||||
'checkout_url' => 'https://checkout.paddle.test/checkout/123',
|
||||
'id' => 'chk_test_123',
|
||||
]);
|
||||
$this->instance(PaddleCheckoutService::class, $checkoutService);
|
||||
|
||||
$response = $this->authenticatedRequest('POST', '/api/v1/tenant/packages/paddle-checkout', [
|
||||
'package_id' => $package->id,
|
||||
]);
|
||||
|
||||
$response->assertOk()
|
||||
->assertJsonPath('checkout_url', 'https://checkout.paddle.test/checkout/123');
|
||||
}
|
||||
|
||||
public function test_paddle_checkout_requires_paddle_price_id(): void
|
||||
{
|
||||
$package = Package::factory()->create([
|
||||
'paddle_price_id' => null,
|
||||
'price' => 129,
|
||||
]);
|
||||
|
||||
$response = $this->authenticatedRequest('POST', '/api/v1/tenant/packages/paddle-checkout', [
|
||||
'package_id' => $package->id,
|
||||
]);
|
||||
|
||||
$response->assertStatus(422)
|
||||
->assertJsonStructure([
|
||||
'errors' => [
|
||||
'package_id' => [],
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user