ini_set('soap.wsdl_cache_enabled', 0);
ini_set('soap.wsdl_cache_ttl', 0);
$documentSign = new DocumentSign();
$testDocumentPath = __DIR__ . '/testdokument.pdf';
$testDocument = file_get_contents($testDocumentPath);
$recipients = [
[
'Name'=>'your name',
'Email'=>'est@somesite.com'
]
];
$attachment =
[
'File'=>$testDocument,
'FileName'=>'Testdokument.pdf',
'Description'=>'Test',
'ActionType'=>'Sign'
];
$data = [
'DistributorSystemID'=>'Testing 123',
'Title'=>'Instant Signeringstest',
'Description'=>'Test av Signant InstantSign',
'UseWidget'=>true,
'Recipients'=>$recipients,
'AfterSignRedirectDelay'=>0,
'AfterSignRedirectUrl'=>'http://www.google.com',
'CancelUrl'=>'http://www.google.no/RequestCanceled',
'AfterSignAction'=>'Redirect',
'AttachmentToSign'=>$attachment
];
$documentSign->CreateInstantPosting($data);
exit;
class DocumentSign
{
protected $distributorID;
protected $accessCode;
protected $postingsServiceWsdl;
/* DocumentSign constructor. */
public function __construct()
{
$this->distributorID = 'Contact Signant for distributorID';
$this->accessCode = 'Contact Signant for accessCode';
$this->postingsServiceWsdl = 'https://test3.signant.no/ws/v1/InstantSignatureService.svc?wsdl';
}
/* Connects to the CreateInstantPosting service and sends a document. */
public function CreateInstantPosting($data)
{
require_once __DIR__ . '/nusoap/lib/nusoap.php';
try
{
$client = new SoapClient($this->postingsServiceWsdl, array('trace' => 1, 'encoding' => 'UTF-8'));
print_r($client);
print_r('<hr>');
$output = $client->CreateInstantPosting(array("DistributorID" => $this->distributorID, "AccessCode" => $this->accessCode, "Posting" => $data));
$result = $output->CreateInstantPosting;
print_r($output);
print_r('<hr>');
$success = $result->Success;
if (!$success) {
return false;
}
}
catch (Exception $e)
{
debug($e);
}
}
public function DownloadInstantAttachment($postingID, $attachmentID)
{
try
{
$client = new SoapClient($this->postingsServiceWsdl, array('trace' => 1, 'exception' => 0));
$output = $client->DownloadInstantAttachment(array("DistributorID" => $this->distributorID, "AccessCode" => $this->accessCode, "PostingID" => $postingID, "AttachmentID" => $attachmentID ));
$success = $output->DownloadInstantAttachmentResponse->Success;
$status = $output->DownloadInstantAttachmentResponse->Status;
if (!$success) {
return false;
}
debug($output);
}
catch (Exception $e)
{
debug($e);
}
}
}