Download the PHP package jeffersongoncalves/laravel-zapsign without Composer
On this page you can find all versions of the php package jeffersongoncalves/laravel-zapsign. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jeffersongoncalves/laravel-zapsign
More information about jeffersongoncalves/laravel-zapsign
Files in jeffersongoncalves/laravel-zapsign
Package laravel-zapsign
Short Description Laravel client for the ZapSign API (e-signature): documents, templates, signers, rate-limit aware requests, database persistence, queued jobs and webhooks.
License MIT
Homepage https://github.com/jeffersongoncalves/laravel-zapsign
Informations about the package laravel-zapsign
Laravel ZapSign
Laravel client for the ZapSign e-signature REST API: documents, templates, signers and webhooks — rate-limit aware out of the box, with database persistence and queued jobs.
ZapSign allows 500 requests per minute per token/IP and answers 429 above that. This package:
- throttles requests client-side through your cache store, so every worker sharing the store stays under the limit;
- waits for a free slot (up to
max_waitseconds) instead of failing, or throws aRateLimitExceptionyou can use torelease()a queued job; - retries any
429/503that still reaches the API with exponential backoff, honouringRetry-After(never timeouts/502, which could create a document twice); - queued jobs release themselves on a rate limit instead of failing.
Documents and signers can be stored in your database and kept up to date by queued jobs and webhooks, and signed PDFs copied to any filesystem disk before ZapSign's 60-minute links expire.
Installation
Publish the config and migrations, then migrate (creates zapsign_documents, zapsign_signers and zapsign_webhook_calls):
Add your API token (ZapSign > Settings > Integration > ZapSign API):
Usage
Every method returns the decoded JSON response as an array. Request bodies follow the ZapSign docs field names as-is.
Errors
Database and jobs
Models
| Model | Table | Holds |
|---|---|---|
Models\Document |
zapsign_documents |
token, external_id, name, status (pending/signed/refused), sandbox, original_file, signed_file, signed_file_path, rejected_reason, finished_at, raw payload, optional documentable (any model) — soft deletes |
Models\Signer |
zapsign_signers |
token, external_id, name, email, phone, status, sign_url, times_viewed, last_view_at, signed_at, raw payload |
Models\WebhookCall |
zapsign_webhook_calls |
every received webhook (body hash unique), event_type, document_token, processed_at, exception |
Document::sync(array $data, ?Model $documentable = null) upserts any document array returned by the API or a webhook (same shape) with its signers — signers missing from the payload are removed — so you can store results of your own calls too.
Jobs
- On a rate limit the jobs
release()themselves for theRetry-Aftertime ($tries = 10). CreateDocumentis not retried after an error ($maxExceptions = 1): the document may already exist at ZapSign and credits may be spent.SyncDocumentis unique per document for 60 s, so bursts collapse into one request.StoreSignedFiledownloads the signed PDF toZAPSIGN_FILES_DISK(ZAPSIGN_FILES_DIRECTORY/{token}.pdf) and savessigned_file_path; it is queued automatically when a webhook marks a document signed, or dispatch it yourself:StoreSignedFile::dispatch($document).- Set
ZAPSIGN_QUEUE_CONNECTION/ZAPSIGN_QUEUEto run them on a dedicated queue.
Rate limit in your own jobs
The client already waits for a free slot. In your own jobs, keep max_wait small and release the job instead of blocking the worker:
Option (config/zapsign.php) |
Env | Default |
|---|---|---|
rate_limit.enabled |
ZAPSIGN_RATE_LIMIT_ENABLED |
true |
rate_limit.max_attempts |
ZAPSIGN_RATE_LIMIT_MAX_ATTEMPTS |
500 |
rate_limit.decay_seconds |
ZAPSIGN_RATE_LIMIT_DECAY_SECONDS |
60 |
rate_limit.max_wait |
ZAPSIGN_RATE_LIMIT_MAX_WAIT |
60 |
rate_limit.cache_store |
ZAPSIGN_RATE_LIMIT_CACHE_STORE |
default store |
rate_limit.retry_times |
ZAPSIGN_RETRY_TIMES |
3 |
rate_limit.retry_sleep_ms |
ZAPSIGN_RETRY_SLEEP_MS |
1000 (doubles each retry) |
Use a shared store (Redis, database) when you run several servers/workers — the array or file store only limits a single process/host.
Webhooks
ZapSign does not sign webhook requests, so the endpoint is protected by a secret header that you register together with the webhook:
Register https://your-app.com/zapsign/webhook in ZapSign (Settings > Integration > Webhooks) with a custom header X-ZapSign-Secret: a-long-random-string, or via the API:
The POST /zapsign/webhook route (name zapsign.webhook) is registered only when a secret is set. It:
- checks the secret header (
403otherwise); - stores the call in
zapsign_webhook_calls— once per body (ZapSign sends no event id and redelivers until it gets a200), so duplicate deliveries are ignored; - answers
200right away and queuesProcessWebhookCall, which upserts the document and its signers from the body, soft-deletes ondoc_deleted, queuesStoreSignedFilewhen the document is signed and a disk is configured, and finally dispatchesWebhookReceived.
The route has no web middleware, so CSRF does not apply. Schedule php artisan model:prune to remove stored calls older than ZAPSIGN_WEBHOOK_PRUNE_AFTER_DAYS (30).
The listener runs after the local tables are updated. $event->payload holds the full body.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-zapsign with dependencies
laravel/framework Version ^12.61.1|^13.12.0
spatie/laravel-package-tools Version ^1.16