Migrate billing from Paddle to Lemon Squeezy

This commit is contained in:
Codex Agent
2026-02-03 10:59:54 +01:00
parent 2f4ebfefd4
commit a0ef90e13a
228 changed files with 4369 additions and 4067 deletions

View File

@@ -2,14 +2,14 @@ import { test, expectFixture as expect } from '../helpers/test-fixtures';
const shouldRun = process.env.E2E_TESTING_API === '1';
test.describe('Classic package checkout with Paddle completion', () => {
test.describe('Classic package checkout with Lemon Squeezy completion', () => {
test.skip(!shouldRun, 'Set E2E_TESTING_API=1 to enable checkout tests that use /api/_testing endpoints.');
test('registers, applies coupon, and reaches confirmation', async ({
page,
clearTestMailbox,
seedTestCoupons,
getLatestCheckoutSession,
simulatePaddleCompletion,
simulateLemonSqueezyCompletion,
getTestMailbox,
}) => {
await clearTestMailbox();
@@ -27,23 +27,20 @@ test.describe('Classic package checkout with Paddle completion', () => {
};
});
await page.route('https://cdn.paddle.com/paddle/v2/paddle.js', async (route) => {
await page.route('https://app.lemonsqueezy.com/js/lemon.js', async (route) => {
await route.fulfill({
status: 200,
contentType: 'application/javascript',
body: `
window.__paddleEventCallback = null;
window.__paddleInitOptions = null;
window.__paddleCheckoutConfig = null;
window.Paddle = {
Environment: { set() {} },
Initialize(options) {
window.__paddleInitOptions = options;
window.__paddleEventCallback = options?.eventCallback || null;
window.__lemonEventHandler = null;
window.__lemonOpenedUrl = null;
window.LemonSqueezy = {
Setup(options) {
window.__lemonEventHandler = options?.eventHandler || null;
},
Checkout: {
open(config) {
window.__paddleCheckoutConfig = config;
Url: {
Open(url) {
window.__lemonOpenedUrl = url;
},
},
};
@@ -51,14 +48,14 @@ test.describe('Classic package checkout with Paddle completion', () => {
});
});
let paddleRequestPayload: Record<string, unknown> | null = null;
await page.route('**/paddle/create-checkout', async (route) => {
paddleRequestPayload = route.request().postDataJSON() as Record<string, unknown>;
let lemonsqueezyRequestPayload: Record<string, unknown> | null = null;
await page.route('**/lemonsqueezy/create-checkout', async (route) => {
lemonsqueezyRequestPayload = route.request().postDataJSON() as Record<string, unknown>;
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
checkout_url: 'https://sandbox.paddle.test/checkout/abc123',
checkout_url: 'https://fotospiel.lemonsqueezy.com/checkout/abc123',
}),
});
});
@@ -116,12 +113,12 @@ test.describe('Classic package checkout with Paddle completion', () => {
await expect(termsCheckbox).toBeVisible();
await termsCheckbox.click();
await page.getByRole('button', { name: /Weiter mit Paddle|Continue with Paddle/i }).first().click();
await page.getByRole('button', { name: /Weiter mit Lemon Squeezy|Continue with Lemon Squeezy/i }).first().click();
let checkoutMode: 'inline' | 'hosted' | null = null;
for (let i = 0; i < 8; i++) {
const state = await page.evaluate(() => ({
inline: Boolean(window.__paddleCheckoutConfig),
inline: Boolean(window.__lemonOpenedUrl),
opened: window.__openedWindows?.length ?? 0,
}));
@@ -143,11 +140,14 @@ test.describe('Classic package checkout with Paddle completion', () => {
if (checkoutMode === 'hosted') {
await expect.poll(async () => {
return page.evaluate(() => window.__openedWindows?.[0]?.[0] ?? null);
}).toContain('https://sandbox.paddle.test/checkout/abc123');
}).toContain('https://fotospiel.lemonsqueezy.com/checkout/abc123');
}
await page.evaluate(() => {
window.__paddleEventCallback?.({ name: 'checkout.completed' });
window.__lemonEventHandler?.({
event: 'Checkout.Success',
data: { id: 'ord_test', attributes: { checkout_id: 'chk_123' } },
});
});
let session = null;
@@ -160,7 +160,7 @@ test.describe('Classic package checkout with Paddle completion', () => {
}
if (session) {
await simulatePaddleCompletion(session.id);
await simulateLemonSqueezyCompletion(session.id);
for (let i = 0; i < 6; i++) {
const refreshed = await getLatestCheckoutSession({ email });
@@ -179,8 +179,8 @@ test.describe('Classic package checkout with Paddle completion', () => {
page.getByRole('button', { name: /Zum Admin-Bereich|To Admin Area/i })
).toBeVisible();
if (paddleRequestPayload) {
expect(paddleRequestPayload['coupon_code']).toBe('PERCENT10');
if (lemonsqueezyRequestPayload) {
expect(lemonsqueezyRequestPayload['coupon_code']).toBe('PERCENT10');
}
const messages = await getTestMailbox();
@@ -191,8 +191,7 @@ test.describe('Classic package checkout with Paddle completion', () => {
declare global {
interface Window {
__openedWindows?: unknown[];
__paddleEventCallback?: ((event: { name: string }) => void) | null;
__paddleInitOptions?: unknown;
__paddleCheckoutConfig?: unknown;
__lemonEventHandler?: ((event: { event: string; data?: unknown }) => void) | null;
__lemonOpenedUrl?: string | null;
}
}