PHP code example of noardcode / laravel-signhost

1. Go to this page and download the library: Download noardcode/laravel-signhost library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

noardcode / laravel-signhost example snippets


use Illuminate\Support\Facades\Storage;
use Noardcode\LaravelSignhost\Enums\Language;
use Noardcode\LaravelSignhost\Facades\Signhost;
use Noardcode\LaravelSignhost\ValueObjects\Transaction as TransactionVO;
use Noardcode\LaravelSignhost\ValueObjects\Transactions\FileUpload;
use Noardcode\LaravelSignhost\Collections\TransactionSignersCollection;
use Noardcode\LaravelSignhost\ValueObjects\Transactions\Signer;
use Noardcode\LaravelSignhost\ValueObjects\Transactions\Verifications\Scribble;

// Define your signer(s)
$signers = new TransactionSignersCollection([
    new Signer(
        email: '[email protected]',
        verifications: [
            new Scribble(
                load file(s) to Signhost
$storedTransaction = Signhost::signing()->createFiles($storedTransaction);

// 3) Start the transaction – this triggers sending of the signing link
Signhost::signing()->startTransaction($storedTransaction);

use Illuminate\Support\Facades\Storage;
use Noardcode\LaravelSignhost\Enums\Language;
use Noardcode\LaravelSignhost\Facades\Signhost;
use Noardcode\LaravelSignhost\ValueObjects\Transaction as TransactionVO;
use Noardcode\LaravelSignhost\ValueObjects\Transactions\FileUpload;
use Noardcode\LaravelSignhost\Collections\TransactionSignersCollection;
use Noardcode\LaravelSignhost\ValueObjects\Transactions\Signer;
use Noardcode\LaravelSignhost\ValueObjects\Transactions\Verifications\Scribble;
use Noardcode\LaravelSignhost\ValueObjects\Transactions\FileEntries\FileMetaData;
use Noardcode\LaravelSignhost\ValueObjects\Transactions\FileEntries\FileMetaData\FormSet;

// Define your signer(s)
$signers = new TransactionSignersCollection([
    new Signer(
        email: '[email protected]',
        verifications: [
            new Scribble(
                ',
    fieldTypes: [
        new FormSet\FieldType(
            name: 'FirstNameInput',
            formSetType: FormSetType::Signature,
            location: new FormSet\Location(
                search: 'FirstName: ',
                occurence: 1,
            )
        ), 
        new FormSet\FieldType(
            name: 'Signature',
            formSetType: FormSetType::Check,
            location: new FormSet\Location(
                search: 'Signature here: ',
                occurence: 1,
            )
        )
    ]
);

// Set the formSet to use on the fileUploadVO
$fileUploadVO->setFormSet($formset);

// Specify which signer(s) should use which formSet
$signerFormSets = array_map(
    fn($signer) => new FileMetaData\Signer(
        id: $signer->getId(),
        formSets: ['DummyFormSet']
    ),
    $signers
);

// Set the fileMetaData to use the specified formSet
$fileUploadVO->setFileMetaData(
    new FileMetaData(
        displayOrder: 0,
        displayName: 'My Contract',
        setParaph: false,
        signers: new TransactionFileMetaDataSignersCollection($signerFormSets)
    )
);

// After this we can create the transaction as normal


use Illuminate\Support\Facades\Storage;
use Noardcode\LaravelSignhost\Enums\Language;
use Noardcode\LaravelSignhost\Facades\Signhost;
use Noardcode\LaravelSignhost\ValueObjects\Transaction as TransactionVO;
use Noardcode\LaravelSignhost\ValueObjects\Transactions\FileUpload;
use Noardcode\LaravelSignhost\Collections\TransactionSignersCollection;
use Noardcode\LaravelSignhost\ValueObjects\Transactions\Signer;

// 1) After the signer completes, download the signed document(s)
Signhost::signing()->getSignedFiles($storedTransaction);

// 2) Download the signing receipt for verification
Signhost::signing()->getReceipt($storedTransaction);


use Noardcode\LaravelSignhost\Facades\Signhost;
use Noardcode\LaravelSignhost\Enums\Language;
use Noardcode\LaravelSignhost\ValueObjects\IdProof as IdProofVO;
use Noardcode\LaravelSignhost\ValueObjects\Transactions\Signer;

// 1) Create your own identifier for the signer
$identifier = 'your-own-identifier';

// 2) Redirect the user to the Signhost verification page
return Signhost::idproof()->redirectToSignhost($identifier);


use Noardcode\LaravelSignhost\Facades\Signhost;
use Noardcode\LaravelSignhost\Events\SignhostIdProofCreated;
use Noardcode\LaravelSignhost\Models\Transaction;
use Illuminate\Support\Facades\Event;

// Subscribe to the event and retrieve the dossier
Event::listen(SignhostIdProofCreated::class, function (Transaction $transaction) {
    // Do your custom logic here to retrieve the dossier
    YourCustomJob::dispatch($transaction);
});

use Noardcode\LaravelSignhost\Facades\Signhost;

// Retrieve dossier
Signhost::idproof()->getDossier($transactionId, $fileId);


use Noardcode\LaravelSignhost\Facades\Signhost;

// Retrieve dossier
Signhost::idproof()->getReceipt($transactionId);

bash
php artisan vendor:publish --tag="signhost-config"

config/signhost.php
bash
php artisan migrate
bash
php artisan vendor:publish --tag="signhost-migrations"
bash
php signhost:fake-webhook 8bbcb7df-dc34-4bac-9637-631b447cf610
bash
php artisan signhost:fake-id-proof-webhook order-12345 --transaction-id=123e4567-e89b-12d3-a456-426614174000
php artisan signhost:fake-id-proof-webhook order-12345 --postback-url="https://example.test/webhooks/signhost"