yogeshjangid | Posts: 5

Unhandled Server Error

0 votes

Hi, 

Hi, I have download code from onespan "esignlive", i already replaced my sandbox key but code not work now. i can't understand what is issue with that. can you help me


Attachments
Duo_Liang | Posts: 3776

Reply to: Unhandled Server Error

0 votes

Hi Yogesh,

 

I don't have a problem signing the contract and redirect to stripe.html. Hence could you elaborate a bit more about the issue you are facing, a screenshot of the error trace could be helpful?

 

Duo


Duo_Liang | Posts: 3776

Reply to: Unhandled Server Error

0 votes

BTW, if you want to navigate the page only when signing has completed, you can register a javascript notifier and monitor "ESL:MESSAGE:SUCCESS:SIGNER_COMPLETE" event, instead of invoking an server side API everytime.

 

Duo


yogeshjangid | Posts: 5

Reply to: Unhandled Server Error

0 votes

i was checked in in linux and window but same issue with both, please check screenshoot

I have uploaded new code, can you let me know what is wrong with that.


Attachments
yogeshjangid | Posts: 5

Reply to: Unhandled Server Error

0 votes

Code


yogeshjangid | Posts: 5

Reply to: Unhandled Server Error

0 votes

'PACKAGE', 'status' => 'DRAFT', 'roles' => array( array( 'id' => 'Signer1', 'type' => 'SIGNER', 'signers' => array( array( 'email' => $email, 'firstName' => $firstName, 'lastName' => $lastName, 'id' => 'Signer1', ) ) , ) , array( 'id' => 'Sender1', 'type' => 'SENDER', 'signers' => array( array( 'email' => '[email protected]', 'firstName' => 'Haris', 'lastName' => 'Haidary', 'id' => 'Sender1', ) ) , ) , ) , 'name' => 'PHP Application Example', ); $packageJSON = json_encode($build); $packageId = json_decode($this->sendRequest($this->packageAppend, $packageJSON, NULL, NULL), true); return $packageId; } //Upload document public function buildDocument($packageId) { $build = array( 'extract' => true, 'name' => 'Sample Contract', 'id' => 'contract' ); $doc = file_get_contents("documents/purchase_order.pdf"); $documentJSON = json_encode($build); $status = $this->sendRequest($this->packageAppend . $packageId['id'] . '/documents', $documentJSON, $doc, 'multipart/form-data'); return $status; } //Send Package public function buildSend($packageId) { $build = array( 'status' => 'SENT' ); $sendJSON = json_encode($build); $this->sendRequest($this->packageAppend . $packageId['id'], $sendJSON, NULL, 'application/json'); return NULL; } //Sender signs consent and contract documents public function buildSign($packageId) { $build = array( 'documents' => array( array( 'id' => 'default-consent', 'name' => 'Electronic Disclosures and Signatures Consent' ) , array( 'id' => 'contract', 'name' => 'Sample Contract' ) ) ); $signJSON = json_encode($build); $signatureAppend = $this->packageAppend . $packageId['id'] . '/documents/signed_documents'; $see = $this->sendRequest($signatureAppend, $signJSON, NULL, 'application/json'); return NULL; } //Get a session token public function buildToken($packageId) { $build = array( 'packageId' => $packageId['id'], 'signerId' => 'Signer1' ); $tokenJSON = json_encode($build); $token = json_decode($this->sendRequest($this->tokenAppend, $tokenJSON, NULL, 'application/json'), true); return $token; } //cURL function to send requests to eSignLive private function sendRequest($type, $json, $document, $contentType) { if (is_null($document) && is_null($contentType)) { $postfields = array( "payload" => $json ); } else if (is_null($document) && !is_null($contentType)) { $postfields = $json; } else if (!is_null($document) && $contentType == 'multipart/form-data') { $postfields = array( "file" => $document, "payload" => $json ); } $headerOptions = array( 'Authorization: Basic ' . $this->key ); if (!is_null($contentType)) { $headerOptions[] = "Content-Type: $contentType"; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->url . $type); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,0); curl_setopt($ch, CURLOPT_TIMEOUT, 400); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); if (!is_null($postfields)) { curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); if (!is_array($postfields)) { $headerOptions[] = 'Content-Length: ' . strlen($postfields); } } curl_setopt($ch, CURLOPT_HTTPHEADER, $headerOptions); $response = curl_exec($ch); $err = curl_error($ch); curl_close($ch); if ($err) { return $err; } else { return $response; }; } } ?>


Duo_Liang | Posts: 3776

Reply to: Unhandled Server Error

0 votes

Hi Yogesh,

 

I was testing on Windows machine, XAMPP stack. Just a quick confirmation first, you did have replaced the API Key with your own at line 8, ESLPackageCreation.php, right?

If so, could you console log below variables in contract.php? - $packageId, $value

 

Duo


Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off