Skip to content

Repository files navigation

digisign

Latest Version on PackagistSoftware LicenseCIScrutinizer Code QualitycodecovTotal Downloads

DigiSign PHP library - provides communication with https://api.digisign.org in PHP using PSR-18 HTTP Client, PSR-17 HTTP Factories and PSR-16 SimpleCache.

API documentation is here https://api.digisign.org/api/docs

Install

Via Composer

$ composer require digitalcz/digisign

Configuration

Example configuration in PHP

useDigitalCz\DigiSign\Auth\ApiKeyCredentials;
useDigitalCz\DigiSign\DigiSign;
// Via constructor options$dgs = newDigiSign([
'access_key' => '...', 'secret_key' => '...'
]);
// Or via methods$dgs = newDigiSign();
$dgs->setCredentials(newApiKeyCredentials('...', '...'));

Available constructor options

  • access_key - string; ApiKey access key
  • secret_key - string; ApiKey secret key
  • credentials - DigitalCz\DigiSign\Auth\Credentials instance
  • client - DigitalCz\DigiSign\DigiSignClient instance with your custom PSR17/18 objects
  • http_client - Psr\Http\Client\ClientInterface instance of your custom PSR18 client
  • cache - Psr\SimpleCache\CacheInterface for caching Credentials Tokens
  • sandbox - bool; whether to use sandbox or production API
  • api_base - string; override the base API url
  • signature_tolerance - int; The tolerance for webhook signature age validation (in seconds)

Available configuration methods

useDigitalCz\DigiSign\Auth\Token;
useDigitalCz\DigiSign\Auth\TokenCredentials;
useDigitalCz\DigiSign\DigiSign;
useDigitalCz\DigiSign\DigiSignClient;
useSymfony\Component\Cache\Adapter\FilesystemAdapter;
useSymfony\Component\Cache\Psr16Cache;
useSymfony\Component\HttpClient\Psr18Client;
$dgs = newDigiSign();
// To set your own PSR-18 HTTP Client, if not provided Psr18ClientDiscovery is used$dgs->setClient(newDigiSignClient(newPsr18Client()));
// If you already have the auth-token, i can use TokenCredentials$dgs->setCredentials(newTokenCredentials(newToken('...', 123)));
// Cache will be used to store auth-token, so it can be reused in later requests$dgs->setCache(newPsr16Cache(newFilesystemAdapter()));
// Use sandbox API (https://api.staging.digisign.org)$dgs->useSandbox(true);
// Overwrite API base$dgs->setApiBase('https://example.com/api');
// Set maximum age of webhook request to one minute$dgs->setSignatureTolerance(60);

Example configuration in Symfony

services:
DigitalCz\DigiSign\DigiSign:
$options:
# minimal configaccess_key: '%digisign.accessKey%'secret_key: '%digisign.secretKey%'# other optionscache: '@psr16.cache'http_client: '@psr18.http_client'sandbox: true # use sandbox API

Usage

Create and send Envelope

$dgs = newDigitalCz\DigiSign\DigiSign(['access_key' => '...', 'secret_key' => '...']);
$envelopes = $dgs->envelopes();
$envelope = $envelopes->create([
'emailSubject' => 'Please sign',
'emailBody' => 'Hello James, please sign these documents.',
'senderName' => 'John Smith',
'senderEmail' => 'john.smith@example.com'
]);
$recipient = $envelopes->recipients($envelope)->create([
'role' => 'signer',
'name' => 'James Brown',
'email' => 'james42@example.com',
'mobile' => '+420775300500',
]);
$stream = DigitalCz\DigiSign\Stream\FileStream::open('path/to/document.pdf');
$file = $dgs->files()->upload($stream);
$document = $envelopes->documents($envelope)->create([
'name' => 'Contract',
'file' => $file->self()
]);
$tag = $envelopes->tags($envelope)->create([
'type' => 'signature',
'document' => $document,
'recipient' => $recipient,
'page' => 1,
'xPosition' => 200,
'yPosition' => 340
]);
$envelopes->send($envelope->id());

See examples for more

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer csfix # fix codestyle
$ composer checks # run all checks # or separately
$ composer tests # run phpunit
$ composer phpstan # run phpstan
$ composer cs # run codesniffer

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email devs@digital.cz instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

PHP library - provides communication with https://api.digisign.org in PHP using PSR-18 HTTP Client.

Topics

Resources

Contributing

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages