Prefill storefront creation from CRM won-deal links.
Deploy Ladill Merchant / deploy (push) Successful in 23s

Decode CRM prefill tokens so payment storefronts open with deal label and product line items.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-06-23 20:07:18 +00:00
co-authored by Cursor
parent 06f9742b34
commit c1f5b029b4
3 changed files with 59 additions and 4 deletions
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace App\Support;
final class CrmPrefillCodec
{
/** @return array<string, mixed>|null */
public static function decode(?string $token): ?array
{
if (! is_string($token) || $token === '') {
return null;
}
$padded = $token.str_repeat('=', (4 - strlen($token) % 4) % 4);
$json = base64_decode(strtr($padded, '-_', '+/'), true);
if ($json === false) {
return null;
}
try {
$data = json_decode($json, true, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException) {
return null;
}
return is_array($data) ? $data : null;
}
}