Migrate billing from Paddle to Lemon Squeezy
This commit is contained in:
@@ -61,7 +61,7 @@ class TestCheckoutController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function simulatePaddle(
|
||||
public function simulateLemonSqueezy(
|
||||
Request $request,
|
||||
CheckoutWebhookService $webhooks,
|
||||
CheckoutSession $session
|
||||
@@ -70,13 +70,13 @@ class TestCheckoutController extends Controller
|
||||
|
||||
$validated = $request->validate([
|
||||
'event_type' => ['nullable', 'string'],
|
||||
'transaction_id' => ['nullable', 'string'],
|
||||
'order_id' => ['nullable', 'string'],
|
||||
'status' => ['nullable', 'string'],
|
||||
'checkout_id' => ['nullable', 'string'],
|
||||
'metadata' => ['nullable', 'array'],
|
||||
]);
|
||||
|
||||
$eventType = $validated['event_type'] ?? 'transaction.completed';
|
||||
$eventType = $validated['event_type'] ?? 'order_created';
|
||||
$metadata = array_merge([
|
||||
'tenant_id' => $session->tenant_id,
|
||||
'package_id' => $session->package_id,
|
||||
@@ -84,16 +84,21 @@ class TestCheckoutController extends Controller
|
||||
], $validated['metadata'] ?? []);
|
||||
|
||||
$payload = [
|
||||
'event_type' => $eventType,
|
||||
'data' => array_filter([
|
||||
'id' => $validated['transaction_id'] ?? ('txn_'.Str::uuid()),
|
||||
'status' => $validated['status'] ?? 'completed',
|
||||
'meta' => [
|
||||
'event_name' => $eventType,
|
||||
'custom_data' => $metadata,
|
||||
'checkout_id' => $validated['checkout_id'] ?? $session->provider_metadata['paddle_checkout_id'] ?? 'chk_'.Str::uuid(),
|
||||
],
|
||||
'data' => array_filter([
|
||||
'id' => $validated['order_id'] ?? ('order_'.Str::uuid()),
|
||||
'attributes' => array_filter([
|
||||
'status' => $validated['status'] ?? 'paid',
|
||||
'checkout_id' => $validated['checkout_id'] ?? $session->provider_metadata['lemonsqueezy_checkout_id'] ?? 'chk_'.Str::uuid(),
|
||||
'custom_data' => $metadata,
|
||||
]),
|
||||
]),
|
||||
];
|
||||
|
||||
$handled = $webhooks->handlePaddleEvent($payload);
|
||||
$handled = $webhooks->handleLemonSqueezyEvent($payload);
|
||||
|
||||
return response()->json([
|
||||
'data' => [
|
||||
|
||||
Reference in New Issue
Block a user