Forward JSON registration POST bodies through the ladl.link proxy.
Deploy Ladill Link / deploy (push) Successful in 41s
Deploy Ladill Link / deploy (push) Successful in 41s
Event signup from ladl.link sends application/json; re-encoding as form data dropped the payload and caused failed registrations to redirect to ladl.link/undefined. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -154,4 +154,52 @@ class LinkRedirectTest extends TestCase
|
||||
return str_starts_with($request->url(), 'https://ladill.com/q/sales-webinar/registered/');
|
||||
});
|
||||
}
|
||||
|
||||
public function test_event_registration_post_forwards_json_body_to_events(): void
|
||||
{
|
||||
$user = $this->user();
|
||||
ShortLink::create([
|
||||
'user_id' => $user->id,
|
||||
'slug' => 'sales-webinar',
|
||||
'source_app' => 'events',
|
||||
'source_kind' => 'qr',
|
||||
'is_managed_here' => false,
|
||||
'destination_url' => 'https://ladl.link/sales-webinar',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
Http::fake([
|
||||
'https://events.ladill.com/q/sales-webinar/register' => function ($request) {
|
||||
$payload = json_decode($request->body(), true);
|
||||
|
||||
return Http::response(json_encode([
|
||||
'paid' => false,
|
||||
'success_url' => 'https://ladl.link/sales-webinar/registered/QRE-TESTREF123456',
|
||||
'badge_code' => 'BADGE123',
|
||||
]), 200, ['Content-Type' => 'application/json']);
|
||||
},
|
||||
]);
|
||||
|
||||
$this->postJson('https://ladl.link/sales-webinar/register', [
|
||||
'tier' => 'General Admission',
|
||||
'attendee_name' => 'Jane Doe',
|
||||
'attendee_email' => 'jane@example.com',
|
||||
'attendee_phone' => '+233200000000',
|
||||
])
|
||||
->assertOk()
|
||||
->assertJsonPath('success_url', 'https://ladl.link/sales-webinar/registered/QRE-TESTREF123456');
|
||||
|
||||
Http::assertSent(function ($request) {
|
||||
if ($request->url() !== 'https://events.ladill.com/q/sales-webinar/register') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$payload = json_decode($request->body(), true);
|
||||
|
||||
return is_array($payload)
|
||||
&& ($payload['attendee_email'] ?? '') === 'jane@example.com'
|
||||
&& ($payload['tier'] ?? '') === 'General Admission'
|
||||
&& $request->hasHeader('X-Ladill-Internal', '1');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user