PHP code example of registrucentras / onesign
1. Go to this page and download the library: Download registrucentras/onesign 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/ */
registrucentras / onesign example snippets
use RegistruCentras\OneSign\Client;
$client = new Client();
$client->configure(
'api_endpoint_adresas',
'jums_suteiktas_id',
\file_get_contents(__DIR__ . '/../Keys/private.key'), // jūsų sugeneruotas private raktas
'private_key_passprahse',
\file_get_contents(__DIR__ . '/../Keys/public.key') // jums perduotas public raktas GoSign.lt administratoriaus
);
use RegistruCentras\OneSign\Entity\Signer;
use RegistruCentras\OneSign\Entity\File;
use RegistruCentras\OneSign\Entity\SignatureConfiguration;
use RegistruCentras\OneSign\Entity\Configuration;
use RegistruCentras\OneSign\Entity\SigningType;
$signer = (new Signer())
->setPersonalCode('asmens_kodas')
;
$file = (new File())
->setName('failo_pavadinimas')
->setContent(\file_get_contents(__DIR__ . '/../Files/sample.pdf'))
;
$signatureConfiguration = new SignatureConfiguration();
$configuration = (new Configuration())
->setResponseUrl('http://example.com/backlink')
->setSigningType(SigningType::SIGNATURE_WITH_TIMESTAMP_OCSP)
;
$response = $client
->init($signer, $file, $signatureConfiguration, $configuration)
;
$transactionId = $response->getTransactionId();
$signingUrl = $response->getSigningUrl();
use RegistruCentras\OneSign\Entity\Transaction;
use RegistruCentras\OneSign\HttpClient\Message\Response\Status\SigningResponseStatus;
$transaction = (new Transaction())
->setTransactionId($transactionId)
;
$response = $client
->result($transactionId)
;
$status = $response->getStatus();
$signerCertificate = $response->getSignerCertificate();
$fileName = $response->getFile()->getFileName();
$fileContent = $response->getFile()->getContent();
$signerCertificate = $response->getSignerCertificate();
$signerCertificateTrusted = $response->getSignerCertificateTrusted();
use RegistruCentras\OneSign\Entity\Transaction;
use RegistruCentras\OneSign\HttpClient\Message\Response\Status\CancelSigningResponseStatus;
$transaction = (new Transaction())
->setTransactionId($transactionId)
;
$response = $client
->cancel($transactionId)
;
$status = $response->getStatus();