Thanks for the help. I have everything working now except for one small issue with the callback.
I have recorded callbacks with JobCompleted status but I’m having trouble due to inconsistent contents of the callback vars.
For debugging purposes I am recording just about everything about the esignature process.
Let me show you what I mean:
2014-06-25 11:42:00 - generation of envelope
esignature envelop var: {“result”:{“envelope”:{“id”:“6d7dc868377cc860f712fe49efa773e4”,“name”:“20140625-114153-newestform(1).pdf”,“creationDateTime”:“2014-06-25T16:41:56.4970000Z”,“updatedDateTime”:“2014-06-25T16:41:56.6322900ZZ”,“ownerGuid”:“2635e55e54866ba8”,“status”:-1,“statusDateTime”:“1970-01-01T00:00:00.0000000ZZ”,“reminderTime”:1,“stepExpireTime”:3,“envelopeExpireTime”:6,“ownerShouldSign”:false,“orderedSignature”:false,“emailSubject”:"",“emailBody”:"",“documentsCount”:1,“documentsPages”:1,“recipients”:[],“waterMarkText”:"",“waterMarkImage”:"",“attachSignedDocument”:false,“includeViewLink”:true,“canBeCommented”:true,“inPersonSign”:false,“ownerName”:“Emmanuel Sullivan”}},“status”:“Ok”,“error_message”:"",“composedOn”:“1403714516492”}
2014-06-25 11:42:00 - add the signers to envelope
here are the signers: [{“firstname”:“Mike”,“lastname”:“Hill”,“email”:“mwhill86@gmail.com”}]
2014-06-25 11:42:06 - first callback
{“SourceId”:“6d7dc868377cc860f712fe49efa773e4”,“EventType”:“JobProgress”,“SerializedData”:"{“StatusId”:1,“OwnerGuid”:“2635e55e54866ba8”}",“TimeStamp”:1403714527.1514683}
2014-06-25 11:42:22 - second callback
{“SourceId”:“6d7dc868377cc860f712fe49efa773e4”,“EventType”:“JobProgress”,“SerializedData”:"{“StatusId”:99,“OwnerGuid”:“2635e55e54866ba8”}",“TimeStamp”:1403714543.9673512}
2014-06-25 11:42:36 - third callback
{“SourceId”:“6d7dc868377cc860f712fe49efa773e4”,“EventType”:“JobProgress”,“SerializedData”:"{“StatusId”:5,“OwnerGuid”:“2635e55e54866ba8”}",“TimeStamp”:1403714557.5538769}
2014-06-25 11:42:36 - fourth callback
{“SourceId”:“6d7dc868377cc860f712fe49efa773e4”,“EventType”:“JobCompleted”,“SerializedData”:“null”,“TimeStamp”:1403714557.5738642}
Above you can see the contents of each callback and on the fourth callback there is an EventType of JobCompleted. Yes! this is what we needed. Except you can see the SerializedData on this callback is null. Also the SerializedData that are in the 1st through 3rd callbacks is an object but it doesn’t contain the var $participant = $serializedData[‘ParticipantGuid’];
Without this ParticipantGuid var I can’t get the signed documents. Am I missing something here?
Once more here is my code:
//handle the esignature callback
function handleGroupDocsEsignatureCallBack($json) {
//include and create the needed classes
if ( (class_exists(‘GroupDocsRequestSigner’)) && (class_exists(‘APIClient’)) &&
(class_exists(‘StorageApi’)) && (class_exists(‘SignatureApi’)) )
{ //instances already exist
//Create Signer, ApiClient and Storage Api objects
$signer = new GroupDocsRequestSigner($this->privateKey);
$apiClient = new APIClient($signer);
$storageApi = new StorageApi($apiClient);
$signatureApi = new SignatureApi($apiClient);
} else { //load the needed library files
include_once(JPATH_COMPONENT . ‘/libraries/groupdocs/APIClient.php’);
include_once(JPATH_COMPONENT . ‘/libraries/groupdocs/StorageApi.php’);
include_once(JPATH_COMPONENT . ‘/libraries/groupdocs/GroupDocsRequestSigner.php’);
include_once(JPATH_COMPONENT . ‘/libraries/groupdocs/FileStream.php’);
include_once(JPATH_COMPONENT . ‘/libraries/groupdocs/SignatureApi.php’);
$signer = new GroupDocsRequestSigner($this->privateKey);
$apiClient = new APIClient($signer);
$storageApi = new StorageApi($apiClient);
$signatureApi = new SignatureApi($apiClient);
}
//handle callback
$callBack_data = json_decode($json, true);
$this->logErrorDB($json);
//Get job id from array
$formId = $callBack_data[“SourceId”];
$jobStatus = trim($callBack_data[“EventType”]);
$serializedData = json_decode($callBack_data[‘SerializedData’], true);
//$this->logErrorDB($callBack_data[‘SerializedData’]);
$participant = $serializedData[‘ParticipantGuid’];
$this->logErrorDB($jobStatus);
//check to see if we’re done signing
if ($jobStatus == “JobCompleted” || $jobStatus == ‘JobCompleted’) {
//lets get the signed document
$this->logErrorDB(‘we are finally inside the dreaded jobcompleted conditional. jeez!’);
//$getDocInfo = $signatureApi->GetSignatureFormParticipant($formId, $participant);
//$this->logErrorDB(json_encode($getDocInfo));
try {
$getDocInfo = $signatureApi->GetSignatureFormParticipant($formId, $participant);
if ($getDocInfo->status == “Ok”) { //this is the signed document
$guid = $getDocInfo->result->participant->documentGuid; //signed docs guid
//
//lets log the contents of the getDocInfo call
$this->logErrorDB(‘We can get the signed document, everything is good’);
//return $getDocInfo; //return the information about signed document
} else {
throw new Exception($getDocInfo->error_message);
}
} catch (Exception $e) {
$error = "groupdocs.php line 749 something wrong with getDocInfo call: ".$getDocInfo->error_message;
$this->logErrorDB($error);
}
} else {
$error = 'groupdocs.php model line 402 jobStatus var does not equal JobCompleted, it equals '.$jobStatus;
$this->logErrorDB($error);
}
}