Migrate billing from Paddle to Lemon Squeezy
This commit is contained in:
@@ -44,8 +44,8 @@ class CouponFactory extends Factory
|
||||
'metadata' => ['note' => 'factory'],
|
||||
'starts_at' => now()->subDay(),
|
||||
'ends_at' => now()->addMonth(),
|
||||
'paddle_discount_id' => 'dsc_'.Str::upper(Str::random(10)),
|
||||
'paddle_mode' => 'standard',
|
||||
'lemonsqueezy_discount_id' => 'dsc_'.Str::upper(Str::random(10)),
|
||||
'lemonsqueezy_mode' => 'standard',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class IntegrationWebhookEventFactory extends Factory
|
||||
$processedAt = (clone $receivedAt)->modify('+2 minutes');
|
||||
|
||||
return [
|
||||
'provider' => $this->faker->randomElement(['paddle', 'revenuecat']),
|
||||
'provider' => $this->faker->randomElement(['lemonsqueezy', 'revenuecat']),
|
||||
'event_id' => $this->faker->uuid(),
|
||||
'event_type' => $this->faker->word(),
|
||||
'status' => IntegrationWebhookEvent::STATUS_PROCESSED,
|
||||
|
||||
@@ -30,9 +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,
|
||||
'lemonsqueezy_sync_status' => null,
|
||||
'lemonsqueezy_synced_at' => null,
|
||||
'lemonsqueezy_snapshot' => null,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -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('paddle_checkout_id')->nullable();
|
||||
$table->string('paddle_transaction_id')->nullable();
|
||||
$table->string('lemonsqueezy_checkout_id')->nullable();
|
||||
$table->string('lemonsqueezy_order_id')->nullable();
|
||||
$table->json('provider_metadata')->nullable();
|
||||
|
||||
$table->string('locale', 5)->nullable();
|
||||
@@ -47,8 +47,8 @@ return new class extends Migration
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique('stripe_payment_intent_id');
|
||||
$table->unique('paddle_checkout_id');
|
||||
$table->unique('paddle_transaction_id');
|
||||
$table->unique('lemonsqueezy_checkout_id');
|
||||
$table->unique('lemonsqueezy_order_id');
|
||||
$table->index(['provider', 'status']);
|
||||
$table->index('expires_at');
|
||||
});
|
||||
|
||||
@@ -11,26 +11,26 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasColumn('packages', 'paddle_product_id')) {
|
||||
if (! Schema::hasColumn('packages', 'lemonsqueezy_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');
|
||||
$table->string('lemonsqueezy_product_id')->nullable()->after('price');
|
||||
$table->string('lemonsqueezy_variant_id')->nullable()->after('lemonsqueezy_product_id');
|
||||
$table->index('lemonsqueezy_product_id');
|
||||
$table->index('lemonsqueezy_variant_id');
|
||||
});
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('tenants', 'paddle_customer_id')) {
|
||||
if (! Schema::hasColumn('tenants', 'lemonsqueezy_customer_id')) {
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
$table->string('paddle_customer_id')->nullable()->after('subscription_status');
|
||||
$table->index('paddle_customer_id');
|
||||
$table->string('lemonsqueezy_customer_id')->nullable()->after('subscription_status');
|
||||
$table->index('lemonsqueezy_customer_id');
|
||||
});
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('tenant_packages', 'paddle_subscription_id')) {
|
||||
if (! Schema::hasColumn('tenant_packages', 'lemonsqueezy_subscription_id')) {
|
||||
Schema::table('tenant_packages', function (Blueprint $table) {
|
||||
$table->string('paddle_subscription_id')->nullable()->after('package_id');
|
||||
$table->index('paddle_subscription_id');
|
||||
$table->string('lemonsqueezy_subscription_id')->nullable()->after('package_id');
|
||||
$table->index('lemonsqueezy_subscription_id');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -47,31 +47,31 @@ return new class extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
if (Schema::hasColumn('packages', 'paddle_price_id')) {
|
||||
if (Schema::hasColumn('packages', 'lemonsqueezy_variant_id')) {
|
||||
Schema::table('packages', function (Blueprint $table) {
|
||||
$table->dropIndex('packages_paddle_price_id_index');
|
||||
$table->dropColumn('paddle_price_id');
|
||||
$table->dropIndex('packages_lemonsqueezy_variant_id_index');
|
||||
$table->dropColumn('lemonsqueezy_variant_id');
|
||||
});
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('packages', 'paddle_product_id')) {
|
||||
if (Schema::hasColumn('packages', 'lemonsqueezy_product_id')) {
|
||||
Schema::table('packages', function (Blueprint $table) {
|
||||
$table->dropIndex('packages_paddle_product_id_index');
|
||||
$table->dropColumn('paddle_product_id');
|
||||
$table->dropIndex('packages_lemonsqueezy_product_id_index');
|
||||
$table->dropColumn('lemonsqueezy_product_id');
|
||||
});
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('tenants', 'paddle_customer_id')) {
|
||||
if (Schema::hasColumn('tenants', 'lemonsqueezy_customer_id')) {
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
$table->dropIndex('tenants_paddle_customer_id_index');
|
||||
$table->dropColumn('paddle_customer_id');
|
||||
$table->dropIndex('tenants_lemonsqueezy_customer_id_index');
|
||||
$table->dropColumn('lemonsqueezy_customer_id');
|
||||
});
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('tenant_packages', 'paddle_subscription_id')) {
|
||||
if (Schema::hasColumn('tenant_packages', 'lemonsqueezy_subscription_id')) {
|
||||
Schema::table('tenant_packages', function (Blueprint $table) {
|
||||
$table->dropIndex('tenant_packages_paddle_subscription_id_index');
|
||||
$table->dropColumn('paddle_subscription_id');
|
||||
$table->dropIndex('tenant_packages_lemonsqueezy_subscription_id_index');
|
||||
$table->dropColumn('lemonsqueezy_subscription_id');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -12,15 +12,15 @@ return new class extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('packages', function (Blueprint $table) {
|
||||
$table->string('paddle_sync_status', 50)
|
||||
$table->string('lemonsqueezy_sync_status', 50)
|
||||
->nullable()
|
||||
->after('paddle_price_id');
|
||||
$table->timestamp('paddle_synced_at')
|
||||
->after('lemonsqueezy_variant_id');
|
||||
$table->timestamp('lemonsqueezy_synced_at')
|
||||
->nullable()
|
||||
->after('paddle_sync_status');
|
||||
$table->json('paddle_snapshot')
|
||||
->after('lemonsqueezy_sync_status');
|
||||
$table->json('lemonsqueezy_snapshot')
|
||||
->nullable()
|
||||
->after('paddle_synced_at');
|
||||
->after('lemonsqueezy_synced_at');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ return new class extends Migration
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('packages', function (Blueprint $table) {
|
||||
$table->dropColumn(['paddle_sync_status', 'paddle_synced_at', 'paddle_snapshot']);
|
||||
$table->dropColumn(['lemonsqueezy_sync_status', 'lemonsqueezy_synced_at', 'lemonsqueezy_snapshot']);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -36,10 +36,10 @@ return new class extends Migration
|
||||
$table->timestamp('starts_at')->nullable();
|
||||
$table->timestamp('ends_at')->nullable();
|
||||
|
||||
$table->string('paddle_discount_id')->nullable()->unique();
|
||||
$table->string('paddle_mode', 40)->default('standard');
|
||||
$table->json('paddle_snapshot')->nullable();
|
||||
$table->timestamp('paddle_last_synced_at')->nullable();
|
||||
$table->string('lemonsqueezy_discount_id')->nullable()->unique();
|
||||
$table->string('lemonsqueezy_mode', 40)->default('standard');
|
||||
$table->json('lemonsqueezy_snapshot')->nullable();
|
||||
$table->timestamp('lemonsqueezy_last_synced_at')->nullable();
|
||||
|
||||
$table->foreignIdFor(\App\Models\User::class, 'created_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->foreignIdFor(\App\Models\User::class, 'updated_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
|
||||
@@ -20,7 +20,7 @@ return new class extends Migration
|
||||
$table->foreignIdFor(\App\Models\Tenant::class)->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignIdFor(\App\Models\User::class)->nullable()->constrained()->nullOnDelete();
|
||||
|
||||
$table->string('paddle_transaction_id')->nullable();
|
||||
$table->string('lemonsqueezy_order_id')->nullable();
|
||||
$table->string('status', 40)->default('pending');
|
||||
$table->text('failure_reason')->nullable();
|
||||
|
||||
@@ -33,7 +33,7 @@ return new class extends Migration
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['status', 'redeemed_at']);
|
||||
$table->unique('paddle_transaction_id');
|
||||
$table->unique('lemonsqueezy_order_id');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@ return new class extends Migration
|
||||
$table->string('recipient_name')->nullable();
|
||||
$table->string('message', 500)->nullable();
|
||||
|
||||
$table->string('paddle_transaction_id')->nullable()->unique();
|
||||
$table->string('paddle_checkout_id')->nullable()->unique();
|
||||
$table->string('paddle_price_id')->nullable();
|
||||
$table->string('lemonsqueezy_order_id')->nullable()->unique();
|
||||
$table->string('lemonsqueezy_checkout_id')->nullable()->unique();
|
||||
$table->string('lemonsqueezy_variant_id')->nullable();
|
||||
|
||||
$table->foreignIdFor(\App\Models\Coupon::class)->nullable()->constrained()->nullOnDelete();
|
||||
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
<?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) {
|
||||
if (Schema::hasColumn('packages', 'paddle_product_id')) {
|
||||
$table->dropIndex('packages_paddle_product_id_index');
|
||||
$table->dropColumn('paddle_product_id');
|
||||
}
|
||||
if (Schema::hasColumn('packages', 'paddle_price_id')) {
|
||||
$table->dropIndex('packages_paddle_price_id_index');
|
||||
$table->dropColumn('paddle_price_id');
|
||||
}
|
||||
if (Schema::hasColumn('packages', 'paddle_sync_status')) {
|
||||
$table->dropColumn(['paddle_sync_status', 'paddle_synced_at', 'paddle_snapshot']);
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('packages', 'lemonsqueezy_product_id')) {
|
||||
$table->string('lemonsqueezy_product_id')->nullable()->after('price');
|
||||
$table->index('lemonsqueezy_product_id');
|
||||
}
|
||||
if (! Schema::hasColumn('packages', 'lemonsqueezy_variant_id')) {
|
||||
$table->string('lemonsqueezy_variant_id')->nullable()->after('lemonsqueezy_product_id');
|
||||
$table->index('lemonsqueezy_variant_id');
|
||||
}
|
||||
if (! Schema::hasColumn('packages', 'lemonsqueezy_sync_status')) {
|
||||
$table->string('lemonsqueezy_sync_status', 50)->nullable()->after('lemonsqueezy_variant_id');
|
||||
$table->timestamp('lemonsqueezy_synced_at')->nullable()->after('lemonsqueezy_sync_status');
|
||||
$table->json('lemonsqueezy_snapshot')->nullable()->after('lemonsqueezy_synced_at');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('tenants', 'paddle_customer_id')) {
|
||||
$table->dropIndex('tenants_paddle_customer_id_index');
|
||||
$table->dropColumn('paddle_customer_id');
|
||||
}
|
||||
if (! Schema::hasColumn('tenants', 'lemonsqueezy_customer_id')) {
|
||||
$table->string('lemonsqueezy_customer_id')->nullable()->after('subscription_status');
|
||||
$table->index('lemonsqueezy_customer_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('tenant_packages', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('tenant_packages', 'paddle_subscription_id')) {
|
||||
$table->dropIndex('tenant_packages_paddle_subscription_id_index');
|
||||
$table->dropColumn('paddle_subscription_id');
|
||||
}
|
||||
if (! Schema::hasColumn('tenant_packages', 'lemonsqueezy_subscription_id')) {
|
||||
$table->string('lemonsqueezy_subscription_id')->nullable()->after('package_id');
|
||||
$table->index('lemonsqueezy_subscription_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('checkout_sessions', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('checkout_sessions', 'paddle_checkout_id')) {
|
||||
$table->dropUnique('checkout_sessions_paddle_checkout_id_unique');
|
||||
$table->dropColumn('paddle_checkout_id');
|
||||
}
|
||||
if (Schema::hasColumn('checkout_sessions', 'paddle_transaction_id')) {
|
||||
$table->dropUnique('checkout_sessions_paddle_transaction_id_unique');
|
||||
$table->dropColumn('paddle_transaction_id');
|
||||
}
|
||||
if (! Schema::hasColumn('checkout_sessions', 'lemonsqueezy_checkout_id')) {
|
||||
$table->string('lemonsqueezy_checkout_id')->nullable()->after('stripe_subscription_id');
|
||||
$table->unique('lemonsqueezy_checkout_id');
|
||||
}
|
||||
if (! Schema::hasColumn('checkout_sessions', 'lemonsqueezy_order_id')) {
|
||||
$table->string('lemonsqueezy_order_id')->nullable()->after('lemonsqueezy_checkout_id');
|
||||
$table->unique('lemonsqueezy_order_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('coupons', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('coupons', 'paddle_discount_id')) {
|
||||
$table->dropUnique('coupons_paddle_discount_id_unique');
|
||||
$table->dropColumn(['paddle_discount_id', 'paddle_mode', 'paddle_snapshot', 'paddle_last_synced_at']);
|
||||
}
|
||||
if (! Schema::hasColumn('coupons', 'lemonsqueezy_discount_id')) {
|
||||
$table->string('lemonsqueezy_discount_id')->nullable()->unique()->after('ends_at');
|
||||
$table->string('lemonsqueezy_mode', 40)->default('standard')->after('lemonsqueezy_discount_id');
|
||||
$table->json('lemonsqueezy_snapshot')->nullable()->after('lemonsqueezy_mode');
|
||||
$table->timestamp('lemonsqueezy_last_synced_at')->nullable()->after('lemonsqueezy_snapshot');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('coupon_redemptions', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('coupon_redemptions', 'paddle_transaction_id')) {
|
||||
$table->dropUnique('coupon_redemptions_paddle_transaction_id_unique');
|
||||
$table->dropColumn('paddle_transaction_id');
|
||||
}
|
||||
if (! Schema::hasColumn('coupon_redemptions', 'lemonsqueezy_order_id')) {
|
||||
$table->string('lemonsqueezy_order_id')->nullable()->after('user_id');
|
||||
$table->unique('lemonsqueezy_order_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('gift_vouchers', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('gift_vouchers', 'paddle_transaction_id')) {
|
||||
$table->dropUnique('gift_vouchers_paddle_transaction_id_unique');
|
||||
$table->dropColumn('paddle_transaction_id');
|
||||
}
|
||||
if (Schema::hasColumn('gift_vouchers', 'paddle_checkout_id')) {
|
||||
$table->dropUnique('gift_vouchers_paddle_checkout_id_unique');
|
||||
$table->dropColumn('paddle_checkout_id');
|
||||
}
|
||||
if (Schema::hasColumn('gift_vouchers', 'paddle_price_id')) {
|
||||
$table->dropColumn('paddle_price_id');
|
||||
}
|
||||
if (! Schema::hasColumn('gift_vouchers', 'lemonsqueezy_order_id')) {
|
||||
$table->string('lemonsqueezy_order_id')->nullable()->unique()->after('message');
|
||||
$table->string('lemonsqueezy_checkout_id')->nullable()->unique()->after('lemonsqueezy_order_id');
|
||||
$table->string('lemonsqueezy_variant_id')->nullable()->after('lemonsqueezy_checkout_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('package_addons', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('package_addons', 'price_id')) {
|
||||
$table->dropColumn('price_id');
|
||||
}
|
||||
if (! Schema::hasColumn('package_addons', 'variant_id')) {
|
||||
$table->string('variant_id')->nullable()->after('label');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('event_package_addons', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('event_package_addons', 'price_id')) {
|
||||
$table->dropColumn('price_id');
|
||||
}
|
||||
if (! Schema::hasColumn('event_package_addons', 'variant_id')) {
|
||||
$table->string('variant_id')->nullable()->after('extra_gallery_days');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('packages', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('packages', 'lemonsqueezy_product_id')) {
|
||||
$table->dropIndex('packages_lemonsqueezy_product_id_index');
|
||||
$table->dropColumn('lemonsqueezy_product_id');
|
||||
}
|
||||
if (Schema::hasColumn('packages', 'lemonsqueezy_variant_id')) {
|
||||
$table->dropIndex('packages_lemonsqueezy_variant_id_index');
|
||||
$table->dropColumn('lemonsqueezy_variant_id');
|
||||
}
|
||||
if (Schema::hasColumn('packages', 'lemonsqueezy_sync_status')) {
|
||||
$table->dropColumn(['lemonsqueezy_sync_status', 'lemonsqueezy_synced_at', 'lemonsqueezy_snapshot']);
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('tenants', 'lemonsqueezy_customer_id')) {
|
||||
$table->dropIndex('tenants_lemonsqueezy_customer_id_index');
|
||||
$table->dropColumn('lemonsqueezy_customer_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('tenant_packages', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('tenant_packages', 'lemonsqueezy_subscription_id')) {
|
||||
$table->dropIndex('tenant_packages_lemonsqueezy_subscription_id_index');
|
||||
$table->dropColumn('lemonsqueezy_subscription_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('checkout_sessions', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('checkout_sessions', 'lemonsqueezy_checkout_id')) {
|
||||
$table->dropUnique('checkout_sessions_lemonsqueezy_checkout_id_unique');
|
||||
$table->dropColumn('lemonsqueezy_checkout_id');
|
||||
}
|
||||
if (Schema::hasColumn('checkout_sessions', 'lemonsqueezy_order_id')) {
|
||||
$table->dropUnique('checkout_sessions_lemonsqueezy_order_id_unique');
|
||||
$table->dropColumn('lemonsqueezy_order_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('coupons', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('coupons', 'lemonsqueezy_discount_id')) {
|
||||
$table->dropUnique('coupons_lemonsqueezy_discount_id_unique');
|
||||
$table->dropColumn(['lemonsqueezy_discount_id', 'lemonsqueezy_mode', 'lemonsqueezy_snapshot', 'lemonsqueezy_last_synced_at']);
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('coupon_redemptions', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('coupon_redemptions', 'lemonsqueezy_order_id')) {
|
||||
$table->dropUnique('coupon_redemptions_lemonsqueezy_order_id_unique');
|
||||
$table->dropColumn('lemonsqueezy_order_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('gift_vouchers', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('gift_vouchers', 'lemonsqueezy_order_id')) {
|
||||
$table->dropUnique('gift_vouchers_lemonsqueezy_order_id_unique');
|
||||
$table->dropColumn('lemonsqueezy_order_id');
|
||||
}
|
||||
if (Schema::hasColumn('gift_vouchers', 'lemonsqueezy_checkout_id')) {
|
||||
$table->dropUnique('gift_vouchers_lemonsqueezy_checkout_id_unique');
|
||||
$table->dropColumn('lemonsqueezy_checkout_id');
|
||||
}
|
||||
if (Schema::hasColumn('gift_vouchers', 'lemonsqueezy_variant_id')) {
|
||||
$table->dropColumn('lemonsqueezy_variant_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('package_addons', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('package_addons', 'variant_id')) {
|
||||
$table->dropColumn('variant_id');
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('event_package_addons', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('event_package_addons', 'variant_id')) {
|
||||
$table->dropColumn('variant_id');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -21,7 +21,7 @@ class CouponSeeder extends Seeder
|
||||
|
||||
/** @var Collection<string, int> $packageIds */
|
||||
$packageIds = Package::query()
|
||||
->whereNotNull('paddle_price_id')
|
||||
->whereNotNull('lemonsqueezy_variant_id')
|
||||
->pluck('id', 'slug');
|
||||
|
||||
$coupons = [
|
||||
|
||||
@@ -2,75 +2,32 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Package;
|
||||
use App\Services\Paddle\PaddleGiftVoucherCatalogService;
|
||||
use App\Services\LemonSqueezy\LemonSqueezyGiftVoucherCatalogService;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class GiftVoucherTierSeeder extends Seeder
|
||||
{
|
||||
public function __construct(private readonly PaddleGiftVoucherCatalogService $catalog) {}
|
||||
public function __construct(private readonly LemonSqueezyGiftVoucherCatalogService $catalog) {}
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
if (! config('paddle.api_key')) {
|
||||
$this->command?->warn('Skipping gift voucher Paddle sync: paddle.api_key not configured.');
|
||||
if (! config('lemonsqueezy.api_key')) {
|
||||
$this->command?->warn('Skipping gift voucher Lemon Squeezy sync: lemonsqueezy.api_key not configured.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$tiers = $this->buildTiers();
|
||||
$tiers = config('gift-vouchers.tiers', []);
|
||||
|
||||
foreach ($tiers as $tier) {
|
||||
$result = $this->catalog->ensureTier($tier);
|
||||
|
||||
$this->command?->info(sprintf(
|
||||
'%s → product %s, price %s',
|
||||
'%s → product %s, variant %s',
|
||||
$tier['key'],
|
||||
$result['product_id'],
|
||||
$result['price_id']
|
||||
$result['variant_id']
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array{key:string,label:string,amount:float,currency?:string,paddle_product_id?:string|null,paddle_price_id?:string|null}>
|
||||
*/
|
||||
protected function buildTiers(): array
|
||||
{
|
||||
$columns = ['slug', 'name', 'price'];
|
||||
if (Schema::hasColumn('packages', 'currency')) {
|
||||
$columns[] = 'currency';
|
||||
}
|
||||
|
||||
$packages = Package::query()
|
||||
->where('type', 'endcustomer')
|
||||
->whereNotNull('price')
|
||||
->get($columns)
|
||||
->unique(fn (Package $package) => $package->price.'|'.($package->currency ?? 'EUR'));
|
||||
|
||||
return $packages->map(function (Package $package): array {
|
||||
$amount = (float) $package->price;
|
||||
$currency = $package->currency ?? 'EUR';
|
||||
|
||||
return [
|
||||
'key' => 'gift-'.$package->slug,
|
||||
'label' => 'Gutschein '.$package->name,
|
||||
'amount' => $amount,
|
||||
'currency' => $currency,
|
||||
'paddle_price_id' => $this->lookupPaddlePriceId($package->slug),
|
||||
];
|
||||
})->values()->all();
|
||||
}
|
||||
|
||||
protected function lookupPaddlePriceId(string $slug): ?string
|
||||
{
|
||||
return match ($slug) {
|
||||
'starter' => 'pri_01kbwccfe1mpwh7hh60eygemx6',
|
||||
'standard' => 'pri_01kbwccfvzrf4z2f1r62vns7gh',
|
||||
'pro' => 'pri_01kbwccg8vjc5cwz0kftfvf9wm',
|
||||
'premium' => 'pri_01kbwccgnjzwrjy5xg1yp981p6',
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ class PackageSeeder extends Seeder
|
||||
'watermark_allowed' => false,
|
||||
'branding_allowed' => false,
|
||||
'features' => ['basic_uploads', 'limited_sharing', 'custom_tasks', 'live_slideshow'],
|
||||
'paddle_product_id' => 'pro_01k8jcxx2g1vj9snqbga4283ej',
|
||||
'paddle_price_id' => 'pri_01k8jcxx8qktxvqzzv0nkjjj27',
|
||||
'lemonsqueezy_product_id' => 'pro_01k8jcxx2g1vj9snqbga4283ej',
|
||||
'lemonsqueezy_variant_id' => 'pri_01k8jcxx8qktxvqzzv0nkjjj27',
|
||||
'description' => <<<'TEXT'
|
||||
Ideal für Geburtstage, Gartenpartys oder Polterabende! {{max_guests}} Gäste teilen ihre besten Schnappschüsse, lösen {{max_tasks}} Fotoaufgaben und haben {{gallery_duration}} Zugriff auf die Online-Galerie. {{max_photos}} Bilder sind inklusive – genug Platz für jede Menge Lieblingsmomente.
|
||||
TEXT,
|
||||
@@ -65,8 +65,8 @@ TEXT,
|
||||
'watermark_allowed' => true,
|
||||
'branding_allowed' => true,
|
||||
'features' => ['basic_uploads', 'unlimited_sharing', 'custom_branding', 'custom_tasks', 'live_slideshow', 'no_watermark'],
|
||||
'paddle_product_id' => 'pro_01k8jcxwjv4ne8vf9pvd9bye3j',
|
||||
'paddle_price_id' => 'pri_01k8jcxws51pze5xc3vj2ea0yc',
|
||||
'lemonsqueezy_product_id' => 'pro_01k8jcxwjv4ne8vf9pvd9bye3j',
|
||||
'lemonsqueezy_variant_id' => 'pri_01k8jcxws51pze5xc3vj2ea0yc',
|
||||
'description' => <<<'TEXT'
|
||||
Das Rundum-Sorglos-Paket für Hochzeiten, Firmenfeiern oder Jubiläen. {{max_photos}} Bilder, {{max_guests}} Gäste und {{max_tasks}} Fotoaufgaben – dazu eine Galerie, die {{gallery_duration}} online bleibt. Eigenes Logo oder Wasserzeichen inklusive.
|
||||
TEXT,
|
||||
@@ -98,8 +98,8 @@ TEXT,
|
||||
'watermark_allowed' => true,
|
||||
'branding_allowed' => true,
|
||||
'features' => ['basic_uploads', 'unlimited_sharing', 'custom_branding', 'custom_tasks', 'live_slideshow', 'advanced_analytics', 'priority_support'],
|
||||
'paddle_product_id' => 'pro_01k8jcxvwp38gay6jj2akjg76s',
|
||||
'paddle_price_id' => 'pri_01k8jcxw5sap4r306wcvc0ephy',
|
||||
'lemonsqueezy_product_id' => 'pro_01k8jcxvwp38gay6jj2akjg76s',
|
||||
'lemonsqueezy_variant_id' => 'pri_01k8jcxw5sap4r306wcvc0ephy',
|
||||
'description' => <<<'TEXT'
|
||||
Das volle Erlebnis für alle, die keine Kompromisse machen wollen. {{max_photos}} Bilder, unbegrenzt viele Gäste, {{gallery_duration}} Galerie-Zugang und {{max_tasks}} Aufgaben – dazu eigenes Wasserzeichen, Live-Slideshow und Premium-Support.
|
||||
TEXT,
|
||||
@@ -134,8 +134,8 @@ TEXT,
|
||||
'max_events_per_year' => 5,
|
||||
'expires_after' => null,
|
||||
'features' => ['reseller_dashboard', 'custom_branding', 'priority_support'],
|
||||
'paddle_product_id' => 'pro_01k8jcxvax48mhmwsfydw8ha9y',
|
||||
'paddle_price_id' => 'pri_01k8jcxvhe0bfasg9gg1rw70sy',
|
||||
'lemonsqueezy_product_id' => 'pro_01k8jcxvax48mhmwsfydw8ha9y',
|
||||
'lemonsqueezy_variant_id' => 'pri_01k8jcxvhe0bfasg9gg1rw70sy',
|
||||
'description' => <<<'TEXT'
|
||||
Event-Kontingent für Partner / Agenturen: {{max_events_per_year}} Events auf Starter‑Niveau. Empfohlen innerhalb von 24 Monaten zu nutzen.
|
||||
TEXT,
|
||||
@@ -168,8 +168,8 @@ TEXT,
|
||||
'max_events_per_year' => 15,
|
||||
'expires_after' => null,
|
||||
'features' => ['reseller_dashboard', 'custom_branding', 'priority_support', 'advanced_reporting'],
|
||||
'paddle_product_id' => 'pro_01k8jcxtrxw7jsew52jnax901q',
|
||||
'paddle_price_id' => 'pri_01k8jcxv06nsgy8ym8mnfrfm5v',
|
||||
'lemonsqueezy_product_id' => 'pro_01k8jcxtrxw7jsew52jnax901q',
|
||||
'lemonsqueezy_variant_id' => 'pri_01k8jcxv06nsgy8ym8mnfrfm5v',
|
||||
'description' => <<<'TEXT'
|
||||
Event-Kontingent für Partner / Agenturen: {{max_events_per_year}} Events auf Classic‑Niveau. Empfohlen innerhalb von 24 Monaten zu nutzen.
|
||||
TEXT,
|
||||
@@ -202,8 +202,8 @@ TEXT,
|
||||
'max_events_per_year' => 35,
|
||||
'expires_after' => null,
|
||||
'features' => ['reseller_dashboard', 'custom_branding', 'priority_support', 'advanced_reporting', 'live_slideshow'],
|
||||
'paddle_product_id' => 'pro_01k8jcxt7gc6g6ddavmq65txzz',
|
||||
'paddle_price_id' => 'pri_01k8jcxtfa07gvq43kpvpe0t8z',
|
||||
'lemonsqueezy_product_id' => 'pro_01k8jcxt7gc6g6ddavmq65txzz',
|
||||
'lemonsqueezy_variant_id' => 'pri_01k8jcxtfa07gvq43kpvpe0t8z',
|
||||
'description' => <<<'TEXT'
|
||||
Event-Kontingent für Partner / Agenturen: {{max_events_per_year}} Events auf Premium‑Niveau. Empfohlen innerhalb von 24 Monaten zu nutzen.
|
||||
TEXT,
|
||||
@@ -236,8 +236,8 @@ TEXT,
|
||||
'max_events_per_year' => 5,
|
||||
'expires_after' => null,
|
||||
'features' => ['reseller_dashboard', 'custom_branding', 'priority_support'],
|
||||
'paddle_product_id' => 'pro_01kf16ttp0fph79j59x0z1cdqc',
|
||||
'paddle_price_id' => 'pri_01kf16v0v2z4hse5cxq5wnah4b',
|
||||
'lemonsqueezy_product_id' => 'pro_01kf16ttp0fph79j59x0z1cdqc',
|
||||
'lemonsqueezy_variant_id' => 'pri_01kf16v0v2z4hse5cxq5wnah4b',
|
||||
'description' => <<<'TEXT'
|
||||
Premium Event-Kontingent für Partner / Agenturen: {{max_events_per_year}} Events auf Premium‑Niveau. Empfohlen innerhalb von 24 Monaten zu nutzen.
|
||||
TEXT,
|
||||
@@ -270,8 +270,8 @@ TEXT,
|
||||
'max_events_per_year' => 24,
|
||||
'expires_after' => null,
|
||||
'features' => ['reseller_dashboard', 'custom_branding', 'priority_support', 'advanced_reporting'],
|
||||
'paddle_product_id' => 'pro_01k8jct3gz9ks5mg6z61q6nrxb',
|
||||
'paddle_price_id' => 'pri_01k8jcxsa8axwpjnybhjbcrb06',
|
||||
'lemonsqueezy_product_id' => 'pro_01k8jct3gz9ks5mg6z61q6nrxb',
|
||||
'lemonsqueezy_variant_id' => 'pri_01k8jcxsa8axwpjnybhjbcrb06',
|
||||
'description' => <<<'TEXT'
|
||||
Event-Kontingent für Partner / Agenturen: {{max_events_per_year}} Events auf Classic‑Niveau. Empfohlen innerhalb von 24 Monaten zu nutzen.
|
||||
TEXT,
|
||||
|
||||
Reference in New Issue
Block a user