switched to paddle inline checkout, removed paypal and most of stripe. added product sync between app and paddle.
This commit is contained in:
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Package;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\TenantPackage;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PayPalWebhookControllerTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_subscription_activation_marks_tenant_active(): void
|
||||
{
|
||||
$tenant = Tenant::factory()->create(['subscription_status' => 'free']);
|
||||
$package = Package::factory()->reseller()->create();
|
||||
|
||||
$payload = [
|
||||
'webhook_id' => 'WH-activation',
|
||||
'webhook_event' => [
|
||||
'event_type' => 'BILLING.SUBSCRIPTION.ACTIVATED',
|
||||
'resource' => [
|
||||
'id' => 'I-123456',
|
||||
'custom_id' => json_encode([
|
||||
'tenant_id' => $tenant->id,
|
||||
'package_id' => $package->id,
|
||||
]),
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$response = $this->postJson('/paypal/webhook', $payload);
|
||||
|
||||
$response->assertOk()
|
||||
->assertJson(['status' => 'SUCCESS']);
|
||||
|
||||
$this->assertEquals('active', $tenant->fresh()->subscription_status);
|
||||
}
|
||||
|
||||
public function test_subscription_cancellation_deactivates_tenant_package(): void
|
||||
{
|
||||
$tenant = Tenant::factory()->create(['subscription_status' => 'active']);
|
||||
$package = Package::factory()->reseller()->create();
|
||||
|
||||
TenantPackage::factory()->create([
|
||||
'tenant_id' => $tenant->id,
|
||||
'package_id' => $package->id,
|
||||
'active' => true,
|
||||
]);
|
||||
|
||||
$payload = [
|
||||
'webhook_id' => 'WH-cancel',
|
||||
'webhook_event' => [
|
||||
'event_type' => 'BILLING.SUBSCRIPTION.CANCELLED',
|
||||
'resource' => [
|
||||
'id' => 'I-123456',
|
||||
'custom_id' => json_encode([
|
||||
'tenant_id' => $tenant->id,
|
||||
'package_id' => $package->id,
|
||||
]),
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$response = $this->postJson('/paypal/webhook', $payload);
|
||||
|
||||
$response->assertOk()
|
||||
->assertJson(['status' => 'SUCCESS']);
|
||||
|
||||
$this->assertEquals('expired', $tenant->fresh()->subscription_status);
|
||||
$this->assertFalse($tenant->tenantPackages()->first()->fresh()->active);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user