switched to paddle inline checkout, removed paypal and most of stripe. added product sync between app and paddle.

This commit is contained in:
Codex Agent
2025-10-27 17:26:39 +01:00
parent ecf5a23b28
commit 5432456ffd
117 changed files with 4114 additions and 3639 deletions

View File

@@ -13,9 +13,10 @@ class PackageFactory extends Factory
public function definition(): array
{
$name = $this->faker->word();
return [
'name' => $name,
'slug' => Str::slug($name . '-' . uniqid()),
'slug' => Str::slug($name.'-'.uniqid()),
'description' => $this->faker->sentence(),
'price' => $this->faker->randomFloat(2, 0, 100),
'max_photos' => $this->faker->numberBetween(100, 1000),
@@ -29,6 +30,9 @@ class PackageFactory extends Factory
'advanced_analytics' => $this->faker->boolean(),
]),
'type' => $this->faker->randomElement(['endcustomer', 'reseller']),
'paddle_sync_status' => null,
'paddle_synced_at' => null,
'paddle_snapshot' => null,
];
}
@@ -59,4 +63,4 @@ class PackageFactory extends Factory
'type' => 'reseller',
]);
}
}
}

View File

@@ -16,6 +16,7 @@ class PackagePurchaseFactory extends Factory
return [
'tenant_id' => Tenant::factory(),
'package_id' => Package::factory(),
'provider' => 'manual',
'provider_id' => $this->faker->uuid(),
'price' => $this->faker->randomFloat(2, 0, 500),
'purchased_at' => now(),

View File

@@ -34,8 +34,8 @@ return new class extends Migration
$table->string('stripe_payment_intent_id')->nullable();
$table->string('stripe_customer_id')->nullable();
$table->string('stripe_subscription_id')->nullable();
$table->string('paypal_order_id')->nullable();
$table->string('paypal_subscription_id')->nullable();
$table->string('paddle_checkout_id')->nullable();
$table->string('paddle_transaction_id')->nullable();
$table->json('provider_metadata')->nullable();
$table->string('locale', 5)->nullable();
@@ -47,7 +47,8 @@ return new class extends Migration
$table->softDeletes();
$table->unique('stripe_payment_intent_id');
$table->unique('paypal_order_id');
$table->unique('paddle_checkout_id');
$table->unique('paddle_transaction_id');
$table->index(['provider', 'status']);
$table->index('expires_at');
});
@@ -60,4 +61,4 @@ return new class extends Migration
{
Schema::dropIfExists('checkout_sessions');
}
};
};

View File

@@ -0,0 +1,85 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
if (! Schema::hasColumn('packages', 'paddle_product_id')) {
Schema::table('packages', function (Blueprint $table) {
$table->string('paddle_product_id')->nullable()->after('price');
$table->string('paddle_price_id')->nullable()->after('paddle_product_id');
$table->index('paddle_product_id');
$table->index('paddle_price_id');
});
}
if (! Schema::hasColumn('tenants', 'paddle_customer_id')) {
Schema::table('tenants', function (Blueprint $table) {
$table->string('paddle_customer_id')->nullable()->after('subscription_status');
$table->index('paddle_customer_id');
});
}
if (! Schema::hasColumn('tenant_packages', 'paddle_subscription_id')) {
Schema::table('tenant_packages', function (Blueprint $table) {
$table->string('paddle_subscription_id')->nullable()->after('package_id');
$table->index('paddle_subscription_id');
});
}
if (! Schema::hasColumn('package_purchases', 'provider')) {
Schema::table('package_purchases', function (Blueprint $table) {
$table->string('provider')->nullable()->after('package_id');
$table->index('provider');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
if (Schema::hasColumn('packages', 'paddle_price_id')) {
Schema::table('packages', function (Blueprint $table) {
$table->dropIndex('packages_paddle_price_id_index');
$table->dropColumn('paddle_price_id');
});
}
if (Schema::hasColumn('packages', 'paddle_product_id')) {
Schema::table('packages', function (Blueprint $table) {
$table->dropIndex('packages_paddle_product_id_index');
$table->dropColumn('paddle_product_id');
});
}
if (Schema::hasColumn('tenants', 'paddle_customer_id')) {
Schema::table('tenants', function (Blueprint $table) {
$table->dropIndex('tenants_paddle_customer_id_index');
$table->dropColumn('paddle_customer_id');
});
}
if (Schema::hasColumn('tenant_packages', 'paddle_subscription_id')) {
Schema::table('tenant_packages', function (Blueprint $table) {
$table->dropIndex('tenant_packages_paddle_subscription_id_index');
$table->dropColumn('paddle_subscription_id');
});
}
if (Schema::hasColumn('package_purchases', 'provider')) {
Schema::table('package_purchases', function (Blueprint $table) {
$table->dropIndex('package_purchases_provider_index');
$table->dropColumn('provider');
});
}
}
};

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('packages', function (Blueprint $table) {
$table->string('paddle_sync_status', 50)
->nullable()
->after('paddle_price_id');
$table->timestamp('paddle_synced_at')
->nullable()
->after('paddle_sync_status');
$table->json('paddle_snapshot')
->nullable()
->after('paddle_synced_at');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('packages', function (Blueprint $table) {
$table->dropColumn(['paddle_sync_status', 'paddle_synced_at', 'paddle_snapshot']);
});
}
};

View File

@@ -149,6 +149,7 @@ class DemoLifecycleSeeder extends Seeder
$purchase = PackagePurchase::create([
'tenant_id' => $tenant->id,
'package_id' => $premium->id,
'provider' => 'stripe',
'provider_id' => 'stripe_demo_pi',
'price' => $premium->price,
'type' => 'endcustomer_event',
@@ -188,6 +189,7 @@ class DemoLifecycleSeeder extends Seeder
'tenant_id' => $tenant->id,
'event_id' => $draftEvent->id,
'package_id' => $standard->id,
'provider' => 'paypal',
'provider_id' => 'paypal_demo_capture',
'price' => $standard->price,
'type' => 'endcustomer_event',
@@ -223,6 +225,7 @@ class DemoLifecycleSeeder extends Seeder
PackagePurchase::create([
'tenant_id' => $tenant->id,
'package_id' => $reseller->id,
'provider' => 'stripe',
'provider_id' => 'stripe_demo_subscription',
'price' => $reseller->price,
'type' => 'reseller_subscription',
@@ -253,6 +256,7 @@ class DemoLifecycleSeeder extends Seeder
'tenant_id' => $tenant->id,
'event_id' => $event->id,
'package_id' => $standard->id,
'provider' => 'manual',
'provider_id' => 'reseller_allowance',
'price' => 0,
'type' => 'endcustomer_event',