Clickwrap agreement in Laravel
Eight files put a terms and privacy checkbox on your Laravel registration, call the Esign Comply API with the Http facade, and create the user only after the acceptance is confirmed as a sealed record.
Free plan: 10 live signatures a month and a full test mode. No card required.
The working code: a signup clickwrap in Laravel
A service class, four controllers, one Blade view, a migration with its model, and the routes. There is no Composer package to require: Laravel's own HTTP client does the work.
<?php // app/Services/EsignComply.php namespace App\Services; use App\Models\Acceptance; use Illuminate\Http\Client\ConnectionException; use Illuminate\Http\Client\PendingRequest; use Illuminate\Http\Client\RequestException; use Illuminate\Support\Facades\Http; // The whole client. There is no Composer package to install: these are plain HTTPS calls with the secret key. class EsignComply { public const SEALED = ['recorded', 'timestamped', 'anchored']; // POST /v1/sessions. The response carries client_token, api_url and the pinned documents. public static function createSession(array $signer, string $url): array { return self::client() ->withHeaders(['Idempotency-Key' => 'signup-'.$signer['external_id']]) ->post('/sessions', [ 'profile' => config('services.esigncomply.profile'), 'signer' => $signer, 'documents' => [ ['document' => config('services.esigncomply.terms'), 'version' => 'current'], ['document' => config('services.esigncomply.privacy'), 'version' => 'current'], ], 'context' => ['url' => $url, 'locale' => 'en-US', 'purpose' => 'account_signup'], ]) ->throw() ->json(); } // GET /v1/records/{id} public static function getRecord(string $recordId): array { return self::client()->get('/records/'.rawurlencode($recordId))->throw()->json(); } // GET /v1/documents/{id}/versions/{version_id}/content public static function getDocumentContent(string $documentId, string $versionId): array { return self::client() ->get('/documents/'.$documentId.'/versions/'.rawurlencode($versionId).'/content') ->throw() ->json(); } // Server confirmation: read the record with the secret key and compare it with // what this server saved when it created the session. public static function confirmRecord(string $recordId, Acceptance $acceptance): ?array { try { $record = self::getRecord($recordId); } catch (RequestException|ConnectionException) { return null; // a made-up ID, a record from the other environment, or the API could not be reached } $actual = array_column($record['documents'], 'version_id'); $expected = $acceptance->document_version_ids; sort($actual); sort($expected); $confirmed = in_array($record['status'], self::SEALED, true) && $record['livemode'] === app()->isProduction() && $record['signer']['external_id'] === $acceptance->signer_id && $actual === $expected; return $confirmed ? $record : null; } private static function client(): PendingRequest { return Http::baseUrl(config('services.esigncomply.url')) ->withToken(config('services.esigncomply.key')) // Authorization: Bearer <key> ->acceptJson() ->timeout(10) // Rate limited: wait out the one-second window and try again (the Free plan allows 2 requests per second). ->retry(3, 1000, fn ($exception) => $exception instanceof RequestException && $exception->response->status() === 429); } }
<?php // app/Http/Controllers/SignupCeremonyController.php namespace App\Http\Controllers; use App\Models\Acceptance; use App\Services\EsignComply; use Illuminate\Http\Client\ConnectionException; use Illuminate\Http\Client\RequestException; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Str; // POST /signup/ceremony creates the session and returns only the client token. class SignupCeremonyController extends Controller { public function __invoke(Request $request): JsonResponse { $input = $request->validate([ 'email' => ['required', 'email'], 'country' => ['required', 'string', 'size:2'], 'state' => ['nullable', 'string', 'size:2'], ]); $country = strtoupper($input['country']); // Your identifier for this person. Keep using it for them in later sessions. $signer = ['external_id' => (string) Str::uuid(), 'email' => $input['email'], 'class' => 'consumer', 'country' => $country]; if ($country === 'US' && ! empty($input['state'])) { $signer['region'] = 'US-'.strtoupper($input['state']); } try { $session = EsignComply::createSession($signer, route('signup')); } catch (RequestException|ConnectionException) { return response()->json(['error' => 'ceremony_unavailable'], 502); } // Server-owned state: the signer and the versions this session pinned. Acceptance::create([ 'signer_id' => $signer['external_id'], 'session_id' => $session['id'], 'document_version_ids' => array_column($session['documents'], 'version_id'), ]); $request->session()->put('esign_session_id', $session['id']); // Only these go to the browser. Never the key, never the whole session. return response()->json([ 'clientToken' => $session['client_token'], 'apiUrl' => $session['api_url'], 'documents' => $session['documents'], ]); } }
{{-- resources/views/auth/signup.blade.php --}}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Create your account</title>
<style>
body { font: 16px/1.5 system-ui, sans-serif; color: #111; max-width: 420px; margin: 40px auto; padding: 0 20px; }
label { display: block; margin-bottom: 12px; }
#assent label { display: inline; }
#assent a { color: #2563eb; text-decoration: underline; }
</style>
</head>
<body>
<form id="signup" action="{{ route('signup') }}" method="post">
@csrf
<label>Email <input name="email" type="email" autocomplete="email" required data-signer></label>
<label>Country <input name="country" value="US" maxlength="2" required data-signer></label>
<label>State <input name="state" placeholder="CA" maxlength="2" data-signer></label>
<label>Password <input name="password" type="password" autocomplete="new-password" minlength="12" required></label>
<div id="assent">
<input id="agree" type="checkbox" disabled>
<label for="agree">
By checking the box and clicking Create account, you agree to the
<a id="tos-link" href="{{ route('legal', 'terms') }}" target="_blank" rel="noopener">Terms of Service</a>
and acknowledge the
<a id="privacy-link" href="{{ route('legal', 'privacy') }}" target="_blank" rel="noopener">Privacy Notice</a>.
</label>
<p><button id="create-account" type="submit" disabled>Create account</button></p>
<p>Acme uses Esign Comply to record this event on its behalf. See Acme's Privacy Notice for purposes and roles.</p>
</div>
<p id="message" role="alert"></p>
</form>
<script src="https://esigncomply.com/sdk/v1/esigncomply.js"></script>
<script type="module">
const form = document.querySelector("#signup");
const fields = form.elements;
const agree = document.querySelector("#agree");
const submit = document.querySelector("#create-account");
const message = document.querySelector("#message");
const tosLink = document.querySelector("#tos-link");
const privacyLink = document.querySelector("#privacy-link");
const INCONCLUSIVE = "We could not confirm whether your acceptance was recorded. Please wait while we check.";
let ceremony = null;
let startedFor = null; // the signer details the current session was created with
let run = 0;
let timer;
const details = () => JSON.stringify([fields.email.value, fields.country.value, fields.state.value]);
// A session belongs to the signer details it was created with. Without one, the box stays disabled.
function drop() {
run += 1; // a start that is still in flight is ignored
if (ceremony) ceremony.destroy();
ceremony = null;
startedFor = null;
agree.checked = false; // a new session must find the box unchecked
agree.disabled = submit.disabled = true;
message.textContent = "";
}
async function start() {
clearTimeout(timer);
if (startedFor === details()) return; // a session for these details exists or is on its way
drop();
if (!fields.email.value || !fields.email.checkValidity()) return;
startedFor = details();
const current = run;
try {
// Your server creates the session with the secret key and returns only the client token.
const response = await fetch("{{ route('signup.ceremony') }}", {
method: "POST",
headers: { "Content-Type": "application/json", Accept: "application/json", "X-CSRF-TOKEN": fields._token.value },
body: JSON.stringify({ email: fields.email.value, country: fields.country.value, state: fields.state.value }),
});
if (!response.ok) throw new Error("We could not start the signup. Reload the page to try again.");
const { clientToken, apiUrl, documents } = await response.json();
if (current !== run) return; // a field changed while the request was in flight
const attached = await EsignComply.attach({ clientToken, apiUrl });
if (current !== run) return attached.destroy();
ceremony = attached;
ceremony.on("change", ({ remainingSteps }) => {
submit.disabled = remainingSteps.some((step) => step !== "signature.applied");
});
ceremony.on("expired", () => {
drop();
start();
});
// Point each link at the exact version this session pinned, then report it.
const [terms, privacy] = documents;
tosLink.search = "?v=" + terms.version_id;
privacyLink.search = "?v=" + privacy.version_id;
await ceremony.presentDocument({ versionId: terms.version_id, mode: "hyperlink", link: tosLink });
await ceremony.presentDocument({ versionId: privacy.version_id, mode: "hyperlink", link: privacyLink });
// The region holds the notice, the links, the checkbox and the button.
await ceremony.observeAssent({ region: document.querySelector("#assent"), checkbox: agree, submit });
agree.disabled = false; // the box can be ticked only while the SDK is watching it
} catch (error) {
if (current === run) message.textContent = error.message;
}
}
// When a signer field changes, drop the session at once. Start a new one when the
// field is left, or when the typing stops.
form.addEventListener("input", (event) => {
if (!event.target.matches("[data-signer]")) return;
drop();
clearTimeout(timer);
if (event.target !== fields.email) timer = setTimeout(start, 800); // an email is finished when its field is left
});
form.addEventListener("change", (event) => {
if (event.target.matches("[data-signer]")) start();
});
start();
form.addEventListener("submit", async (event) => {
event.preventDefault();
if (!ceremony) return;
message.textContent = "";
try {
const result = await ceremony.complete(); // the signing act: { recordId, receipt, verifyUrl, status }
const body = new FormData(form);
body.set("record_id", result.recordId);
// Your server confirms the record with the secret key before it creates the account.
const finished = await fetch(form.action, { method: "POST", body, headers: { Accept: "application/json" } });
if (!finished.ok) throw new Error("Not confirmed");
location.assign("/");
} catch (error) {
// A refusal carries a message and a fix: keep the form. Anything else is inconclusive.
const refused = error instanceof EsignComply.EsignComplyError && error.code !== "network_error" && error.status < 500;
message.textContent = refused ? error.message : INCONCLUSIVE;
}
});
</script>
</body>
</html><?php // app/Http/Controllers/RegisterController.php namespace App\Http\Controllers; use App\Models\Acceptance; use App\Models\User; use App\Services\EsignComply; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; class RegisterController extends Controller { // GET /signup renders the form. public function create() { return view('auth.signup'); } // POST /signup confirms the record, then creates the account. public function store(Request $request): JsonResponse { $input = $request->validate([ 'email' => ['required', 'email', 'unique:users,email'], 'password' => ['required', 'string', 'min:12'], 'record_id' => ['required', 'string'], // from the browser: a claim to check ]); $acceptance = Acceptance::where('session_id', $request->session()->get('esign_session_id')) ->whereNull('user_id') ->first(); $record = $acceptance ? EsignComply::confirmRecord($input['record_id'], $acceptance) : null; if ($record === null) { // Not confirmed: no account. The browser shows the "could not confirm" message. return response()->json(['error' => 'not_confirmed'], 409); } $user = User::create([ 'name' => $input['email'], 'email' => $input['email'], 'password' => Hash::make($input['password']), ]); $acceptance->update([ 'user_id' => $user->id, 'record_id' => $record['id'], 'receipt' => $record['receipt'], 'accepted_at' => Carbon::parse($record['signed_at']), ]); Auth::login($user); $request->session()->regenerate(); return response()->json(['ok' => true]); } }
<?php // database/migrations/2026_11_22_000000_create_acceptances_table.php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { public function up(): void { Schema::create('acceptances', function (Blueprint $table) { $table->id(); // Written when the session is created. $table->string('signer_id'); // signer.external_id sent to Esign Comply $table->string('session_id')->unique(); // ses_... $table->json('document_version_ids'); // ["dv_...", "dv_..."]: the versions the session pinned // Filled in once the record is confirmed. $table->foreignId('user_id')->nullable()->constrained()->cascadeOnDelete(); $table->string('record_id')->nullable()->unique(); // rec_... $table->text('receipt')->nullable(); // signed receipt (JWS, ES256) $table->timestamp('accepted_at')->nullable(); // the record's signed_at $table->timestamps(); }); } public function down(): void { Schema::dropIfExists('acceptances'); } }; // app/Models/Acceptance.php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Acceptance extends Model { protected $guarded = []; protected $casts = ['document_version_ids' => 'array', 'accepted_at' => 'datetime']; }
<?php // app/Http/Controllers/LegalController.php namespace App\Http\Controllers; use App\Services\EsignComply; use Illuminate\Http\Client\ConnectionException; use Illuminate\Http\Client\RequestException; use Illuminate\Http\Request; // GET /legal/terms?v=dv_... serves one registered version, unmodified. class LegalController extends Controller { public function __invoke(Request $request, string $slug) { try { $content = EsignComply::getDocumentContent( config('services.esigncomply.'.$slug), // the route allows only "terms" and "privacy" (string) $request->query('v', 'current'), ); } catch (RequestException|ConnectionException) { abort(404); } return view('legal', ['content' => $content]); } } // resources/views/legal.blade.php holds the registered HTML and nothing else inside the article, // because the SDK hashes its text: // <article data-esc-document="{{ $content['version_id'] }}">{!! $content['html'] !!}</article>
<?php // app/Http/Controllers/EsignWebhookController.php namespace App\Http\Controllers; use App\Models\Acceptance; use App\Services\EsignComply; use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Support\Carbon; use Illuminate\Support\Str; // POST /webhooks/esigncomply class EsignWebhookController extends Controller { public function __invoke(Request $request): Response { $payload = $request->getContent(); // the raw body: never parse and re-serialize before verifying if (! $this->verified($request, $payload)) { return response('Invalid signature', 400); } $event = json_decode($payload, true); // Deliveries are at-least-once. This only fills in a row that is still open, so a repeat changes nothing. if ($event['type'] === 'record.completed') { $data = $event['data']; $acceptance = Acceptance::where('session_id', $data['session_id'])->whereNull('record_id')->first(); $versions = array_column($data['documents'], 'version_id'); $expected = $acceptance?->document_version_ids ?? []; sort($versions); sort($expected); if ($acceptance && $event['livemode'] === app()->isProduction() && $data['signer_external_id'] === $acceptance->signer_id && $versions === $expected) { $record = EsignComply::getRecord($data['record_id']); // the payload carries no receipt $acceptance->update([ 'record_id' => $record['id'], 'receipt' => $record['receipt'], 'accepted_at' => Carbon::parse($record['signed_at']), ]); } } return response('', 200); // also for event types this code does not know } // Standard Webhooks: HMAC-SHA256 over "<webhook-id>.<webhook-timestamp>.<raw body>". private function verified(Request $request, string $payload): bool { $id = (string) $request->header('webhook-id'); $timestamp = (string) $request->header('webhook-timestamp'); $signatures = (string) $request->header('webhook-signature'); if ($id === '' || ! ctype_digit($timestamp) || $signatures === '') { return false; } if (abs(time() - (int) $timestamp) > 300) { // more than 5 minutes from now return false; } // The key is the base64-decoded part of the secret after "whsec_". $key = base64_decode(Str::after(config('services.esigncomply.webhook_secret'), 'whsec_')); $expected = base64_encode(hash_hmac('sha256', $id.'.'.$timestamp.'.'.$payload, $key, true)); // The header can hold several space-separated "v1,<signature>" values while a secret is rotated. foreach (explode(' ', $signatures) as $part) { if (str_starts_with($part, 'v1,') && hash_equals($expected, substr($part, 3))) { return true; } } return false; } }
<?php // routes/web.php use App\Http\Controllers\EsignWebhookController; use App\Http\Controllers\LegalController; use App\Http\Controllers\RegisterController; use App\Http\Controllers\SignupCeremonyController; use Illuminate\Support\Facades\Route; Route::get('/signup', [RegisterController::class, 'create'])->name('signup'); Route::post('/signup', [RegisterController::class, 'store']); Route::post('/signup/ceremony', SignupCeremonyController::class)->name('signup.ceremony'); Route::get('/legal/{slug}', LegalController::class)->whereIn('slug', ['terms', 'privacy'])->name('legal'); // The webhook is signed, not a browser form, so it is left out of CSRF protection. // In bootstrap/app.php: $middleware->validateCsrfTokens(except: ['webhooks/esigncomply']); Route::post('/webhooks/esigncomply', EsignWebhookController::class); // config/services.php: add this entry. The values come from .env. return [ 'esigncomply' => [ 'url' => env('ESIGNCOMPLY_API_URL', 'https://esigncomply.com/v1'), 'key' => env('ESIGNCOMPLY_API_KEY'), 'webhook_secret' => env('ESIGNCOMPLY_WEBHOOK_SECRET'), 'profile' => env('ESIGNCOMPLY_PROFILE_ID'), 'terms' => env('ESIGNCOMPLY_TERMS_ID'), 'privacy' => env('ESIGNCOMPLY_PRIVACY_ID'), ], ];
What each file does
Eight files, four jobs: create the session in a controller, collect the acceptance in your own Blade view, confirm the record before User::create, and keep the receipt next to the user.
The server SDK is for Node, so Laravel calls the REST API itself. client() sets the base URL, withToken sends Authorization: Bearer <key>, and createSession adds an Idempotency-Key to its POST /v1. retry waits a second and tries again on a 429, because the Free plan allows 2 requests per second and one signup makes three calls close together.
confirmRecord guards the registration. It reads GET /v1 and returns the record only when the status is recorded, timestamped or anchored, livemode equals app()->isProduction(), and the signer and the exact set of document versions equal what the Acceptance model holds.
SignupCeremonyController: create the session, return the client token
app/Http/Controllers/SignupCeremonyController.phpView the file The form posts the email, country and state here once the email is entered. The controller validates them, makes a signer ID, creates the session and saves an Acceptance with the signer ID and the version IDs the session pinned. That row is the server-owned state the confirmation compares against. The session ID goes into the Laravel session.
The JSON response has three keys: clientToken, apiUrl and documents. The client token is short-lived and scoped to this one session. The secret key and the rest of the session object stay on the server.
signup.blade.php: your notice, your checkbox, your button
resources/views/auth/signup.blade.phpView the file A complete page you can fold into your layout. The notice names the button and both documents, the links are underlined and coloured apart from the text around them, and the checkbox starts unchecked and disabled. The script enables it only after observeAssent is watching, so every tick is one the SDK saw happen.
The script loads the browser SDK from https:/, posts to signup.ceremony with the @csrf token in the X-CSRF-TOKEN header, and calls EsignComply.attach with the client token. presentDocument reports each link, the change event opens the button when the signing act is the only step left, and complete() runs from the real click. The record ID is then posted to RegisterController@store with the rest of the form.
RegisterController: confirm first, then User::create
app/Http/Controllers/RegisterController.phpView the file store validates the email and password, then treats the posted record_id as a claim. It finds the open Acceptance for this Laravel session and asks EsignComply::confirmRecord to check the claim against it. No row, no record or a mismatch returns 409, the page tells the signer the acceptance could not be confirmed, and no account is created.
On a confirmed record it creates the user, writes the user ID, the record ID, the signed receipt and the accepted time onto the row, and signs the user in.
The migration and the Acceptance model
database/migrations/2026_11_22_000000_create_acceptances_table.phpView the file One row per ceremony. signer_id, session_id and document_version_ids are written when the session is created. user_id, record_id, receipt and accepted_at are filled in when the record is confirmed. The model casts the version IDs to an array, so the confirmation compares two plain lists.
The receipt is a compact signed token (ES256) that names the record hash. A row with no record ID is a registration that was started and abandoned: sessions expire after 30 minutes, so open rows older than a day are safe to prune.
LegalController: the registered version, unmodified
app/Http/Controllers/LegalController.phpView the file /legal and /legal render the version Esign Comply holds, fetched by the version ID in ?v=. The Blade view prints the returned HTML with {!! !!} inside <article data-esc-document> and nothing else. When the form reports a link, the browser SDK reads this page, hashes the article's text and sends the hash, and the API compares it with the registered version (rule CR-08).
EsignWebhookController: verify the signature, fill the open row
app/Http/Controllers/EsignWebhookController.phpView the file record.completed arrives once a record is sealed, including when the browser closed before store ran. The controller takes the raw body from $request->getContent(), rejects a timestamp more than 5 minutes from now and recomputes HMAC-SHA256 over <webhook-id>.<webhook-timestamp>.<raw body>, keyed with the base64-decoded part of the secret after whsec_. hash_equals keeps the comparison constant-time.
Deliveries are at-least-once, and the handler only fills a row that is still open, so a repeat changes nothing.
Five routes and one config entry. The webhook route is excluded from CSRF protection in bootstrap/app.php, because the delivery is signed. The services.esigncomply entry reads the key, the webhook secret and the three IDs from .env, so the code never calls env() directly.
Run it
From an empty account to a sealed test record on localhost:8000. No domain, no card and no Composer package.
- 01
Create a free account and a test key
Sign up, then choose Create test key in the dashboard. The key starts with
esc_test_and is shown once. The Free plan needs no card, and test keys work onlocalhoston any port with no domain. - 02
Register your two documents and a signup profile
In the dashboard, add a document named Terms of Service and one named Privacy Notice, publish a version of each, and create a profile with method
checkboxand levelL1. The names matter: the notice in the form names each document by its title, and ruleCR-02looks for both. Copy the three IDs. - 03
Set the environment variables
Add these to
.env. Theservices.esigncomplyentry in the last tab maps them into config..envESIGNCOMPLY_API_KEY=esc_test_us_... # the test key, shown once in the dashboard ESIGNCOMPLY_PROFILE_ID=prof_signup_4f1a # the signup profile: checkbox, L1 ESIGNCOMPLY_TERMS_ID=doc_8Hq2 # Terms of Service ESIGNCOMPLY_PRIVACY_ID=doc_Pv71 # Privacy Notice ESIGNCOMPLY_WEBHOOK_SECRET=whsec_... # only for the webhook # An EU key (esc_test_eu_...) also needs: # ESIGNCOMPLY_API_URL=https://api.eu.esigncomply.com/v1
- 04
Migrate and start the server
The migration adds the
acceptancestable.$php artisan migrate && php artisan serve - 05
Sign up once
Open
http:/. Enter an email and move to the next field: the checkbox unlocks when the session is attached. Tick it and click Create account./localhost:8000 /signup - 06
Open the test record
The dashboard lists one new test record under Records. It shows what Esign Comply observed from the browser (the page attached, both documents presented, the notice captured, the tick, the signing act), the conformance findings and the evidence report, watermarked TEST. Your
acceptancesrow holds the same record ID and its signed receipt. - 07
Run the conformance check
The checker is a Node CLI, so it needs Node.js 20.19 or later on your machine, not in your app. The command reads
ESIGNCOMPLY_API_KEYfrom your shell and takes test keys only. It opens your page in headless Chromium at 390 by 844, 768 by 1024 and 1440 by 900, tries to submit without the tick and with a scripted click, then signs up for real at each size, so expect three test users in your development database. Every finding names its rule, the measurement and the fix, and the exit code fails a CI build. A clean run ends with0 block.$npx esigncomply@latest check --url http://localhost:8000/signup
Going live
The same code runs in test and live. What changes is .env on the production server.
- 01Register your domainEnter your production host in the dashboard under Domains. Registering
app.example.comcoversexample.comand every subdomain, and every plan, Free included, covers that one domain. - 02Verify it with one TXT recordAdd a TXT record named
_esigncomplywith the valueesc-verify=<token>that the dashboard shows. Esign Comply checks every minute for the first hour. Leave the record in place: it is checked again every day. - 03Add your organization detailsEnter your organization's legal name and country in the dashboard. The Free plan covers 10 live signature events a month with no checkout. Starter is $200 per year for 2,000 live signature events, and Unlimited is $1,200 per year. One event is one signer's completed signing act, so the terms and the privacy notice accepted together at signup count once.
- 04Switch to the live keyCreate a live key (
esc_live_...) and put it in the production.envonly. Copy your documents and profile to live from the dashboard and set the live IDs beside it. WithAPP_ENV=production,app()->isProduction()makes the confirmation expect a live record, so a test record cannot open a production account.
In live mode context.url has to be inside your registered domain, browser calls are accepted only from it, and a finding at Block level stops the record from being sealed. Run the conformance check until nothing blocks before you switch keys.
Have your AI tool do it instead
Paste this into Cursor, Claude Code or any coding agent that is open on your Laravel app. It names the two things a tool gets wrong on this stack: there is no Composer package, and the browser SDK comes from a script tag.
The prompt generator writes the long version: your own document and profile IDs, the rule packs for your regions and the stack you pick, in one prompt.
Generate a promptAdd a signup clickwrap to this Laravel app with Esign Comply. A new user accepts our Terms of Service and Privacy Notice before the account is created. We render every screen. Esign Comply observes it and keeps the independent record.
Read these first and follow them exactly:
- https://esigncomply.com/setup.md
- https://esigncomply.com/auth.md
- https://esigncomply.com/llms.txt
- https://esigncomply.com/guides/laravel-clickwrap (working code for this stack: use it as the reference)
Stack
- There is no Esign Comply Composer package. Call the REST API with the Http facade: withToken(config('services.esigncomply.key')), and an Idempotency-Key header on POST requests.
- Load the browser SDK with <script src="https://esigncomply.com/sdk/v1/esigncomply.js"></script>. It defines the global EsignComply.
Build
1. POST /signup/ceremony: create the session with POST /v1/sessions. Return only client_token, api_url and the pinned documents. Save the signer ID and the version IDs on an Acceptance model.
2. The Blade signup view: attach the SDK to our own unchecked checkbox and our Create account button. Present each document link, observe the assent container, and call complete() from the user's real click.
3. POST /signup: before User::create, read GET /v1/records/{id} and require status recorded, timestamped or anchored, livemode equal to app()->isProduction(), and the saved signer ID and version IDs. Store the record ID and the receipt on the acceptance row.
Never
- Never invent API methods, packages or legal wording.
- Never pre-check the box, auto-submit or click for the user.
- Never put the secret key in client code, in a template or in the repository, and never print it.
- Never create the account before the server has confirmed the record.
If anything conflicts with existing code, stop and ask me. Finish with npx esigncomply@latest check --url http://localhost:8000/signup and fix every finding marked "block".Questions about a clickwrap in Laravel
Is there a Composer package for Esign Comply?
No, and the integration does not need one. The server SDK exists for Node. A Laravel app calls the REST API with the Http facade, and a signup clickwrap uses three calls: POST /v1/sessions, GET /v1/records/{id} and one GET for the registered document text. The service class on this page is the whole client.
How do I add a clickwrap agreement to a Laravel registration form?
Create a session from a controller with your secret key and return only the client token. In the Blade view, load the browser SDK with a script tag and attach it to your own unchecked checkbox and submit button. When the signer clicks, the SDK returns a record ID. Confirm that record on your server with GET /v1/records/{id} before User::create, and store the record ID and receipt in an acceptances table.
Where does the confirmation go if I use a starter kit?
Wherever the kit calls User::create. In Breeze that is RegisteredUserController::store, and in Fortify and Jetstream it is the CreateNewUser action. Run EsignComply::confirmRecord there first and create the user only when it returns a record.
Why is the webhook route excluded from CSRF protection?
Because it is a server-to-server POST, not a form in a browser. Esign Comply signs each delivery with HMAC-SHA256, and the controller verifies that signature on the raw body and rejects timestamps more than 5 minutes from now. The signature is the authentication, so the route is listed under validateCsrfTokens(except: ...) in bootstrap/app.php.
Read the webhook referenceWhat happens when my Laravel app hits the rate limit?
The API answers 429 with a Retry-After header, and the client on this page waits a second and sends the request again, up to three times. The Free plan allows 2 requests per second per key, Starter 10 and Unlimited 50. Calls made by the signer's browser are limited per session, not per key, so a busy signup page does not use up your key's limit.
See the plansAdd the eight files to your Laravel app. Leave the record to us.
Free plan: 10 live signatures a month and a full test mode. No card required.