Migrate billing from Paddle to Lemon Squeezy
This commit is contained in:
@@ -30,7 +30,7 @@ class CheckoutSession extends Model
|
||||
|
||||
public const PROVIDER_NONE = 'none';
|
||||
|
||||
public const PROVIDER_PADDLE = 'paddle';
|
||||
public const PROVIDER_LEMONSQUEEZY = 'lemonsqueezy';
|
||||
|
||||
public const PROVIDER_FREE = 'free';
|
||||
|
||||
|
||||
@@ -38,10 +38,10 @@ class Coupon extends Model
|
||||
'metadata',
|
||||
'starts_at',
|
||||
'ends_at',
|
||||
'paddle_discount_id',
|
||||
'paddle_mode',
|
||||
'paddle_snapshot',
|
||||
'paddle_last_synced_at',
|
||||
'lemonsqueezy_discount_id',
|
||||
'lemonsqueezy_mode',
|
||||
'lemonsqueezy_snapshot',
|
||||
'lemonsqueezy_last_synced_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
@@ -54,10 +54,10 @@ class Coupon extends Model
|
||||
'enabled_for_checkout' => 'boolean',
|
||||
'auto_apply' => 'boolean',
|
||||
'metadata' => 'array',
|
||||
'paddle_snapshot' => 'array',
|
||||
'lemonsqueezy_snapshot' => 'array',
|
||||
'starts_at' => 'datetime',
|
||||
'ends_at' => 'datetime',
|
||||
'paddle_last_synced_at' => 'datetime',
|
||||
'lemonsqueezy_last_synced_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
|
||||
@@ -23,7 +23,7 @@ class CouponRedemption extends Model
|
||||
'package_id',
|
||||
'tenant_id',
|
||||
'user_id',
|
||||
'paddle_transaction_id',
|
||||
'lemonsqueezy_order_id',
|
||||
'status',
|
||||
'failure_reason',
|
||||
'ip_address',
|
||||
|
||||
@@ -20,7 +20,7 @@ class EventPackageAddon extends Model
|
||||
'extra_photos',
|
||||
'extra_guests',
|
||||
'extra_gallery_days',
|
||||
'price_id',
|
||||
'variant_id',
|
||||
'checkout_id',
|
||||
'transaction_id',
|
||||
'status',
|
||||
|
||||
@@ -32,9 +32,9 @@ class GiftVoucher extends Model
|
||||
'recipient_email',
|
||||
'recipient_name',
|
||||
'message',
|
||||
'paddle_transaction_id',
|
||||
'paddle_checkout_id',
|
||||
'paddle_price_id',
|
||||
'lemonsqueezy_order_id',
|
||||
'lemonsqueezy_checkout_id',
|
||||
'lemonsqueezy_variant_id',
|
||||
'coupon_id',
|
||||
'expires_at',
|
||||
'redeemed_at',
|
||||
|
||||
@@ -33,11 +33,11 @@ class Package extends Model
|
||||
'description',
|
||||
'description_translations',
|
||||
'description_table',
|
||||
'paddle_product_id',
|
||||
'paddle_price_id',
|
||||
'paddle_sync_status',
|
||||
'paddle_synced_at',
|
||||
'paddle_snapshot',
|
||||
'lemonsqueezy_product_id',
|
||||
'lemonsqueezy_variant_id',
|
||||
'lemonsqueezy_sync_status',
|
||||
'lemonsqueezy_synced_at',
|
||||
'lemonsqueezy_snapshot',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
@@ -54,8 +54,8 @@ class Package extends Model
|
||||
'name_translations' => 'array',
|
||||
'description_translations' => 'array',
|
||||
'description_table' => 'array',
|
||||
'paddle_synced_at' => 'datetime',
|
||||
'paddle_snapshot' => 'array',
|
||||
'lemonsqueezy_synced_at' => 'datetime',
|
||||
'lemonsqueezy_snapshot' => 'array',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
@@ -146,20 +146,20 @@ class Package extends Model
|
||||
];
|
||||
}
|
||||
|
||||
public function getPaddleSyncErrorMessageAttribute(): ?string
|
||||
public function getLemonSqueezySyncErrorMessageAttribute(): ?string
|
||||
{
|
||||
$message = data_get($this->paddle_snapshot, 'error.message');
|
||||
$message = data_get($this->lemonsqueezy_snapshot, 'error.message');
|
||||
|
||||
return is_string($message) && $message !== '' ? $message : null;
|
||||
}
|
||||
|
||||
public function linkPaddleIds(string $productId, string $priceId): void
|
||||
public function linkLemonSqueezyIds(string $productId, string $variantId): void
|
||||
{
|
||||
$this->forceFill([
|
||||
'paddle_product_id' => $productId,
|
||||
'paddle_price_id' => $priceId,
|
||||
'paddle_sync_status' => 'linked',
|
||||
'paddle_synced_at' => now(),
|
||||
'lemonsqueezy_product_id' => $productId,
|
||||
'lemonsqueezy_variant_id' => $variantId,
|
||||
'lemonsqueezy_sync_status' => 'linked',
|
||||
'lemonsqueezy_synced_at' => now(),
|
||||
])->save();
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ class PackageAddon extends Model
|
||||
protected $fillable = [
|
||||
'key',
|
||||
'label',
|
||||
'price_id',
|
||||
'variant_id',
|
||||
'extra_photos',
|
||||
'extra_guests',
|
||||
'extra_gallery_days',
|
||||
|
||||
@@ -16,7 +16,7 @@ class TenantPackage extends Model
|
||||
protected $fillable = [
|
||||
'tenant_id',
|
||||
'package_id',
|
||||
'paddle_subscription_id',
|
||||
'lemonsqueezy_subscription_id',
|
||||
'price',
|
||||
'purchased_at',
|
||||
'expires_at',
|
||||
|
||||
Reference in New Issue
Block a user