Remove default disclosure electronic signatures document while creating new doc
Monday, October 22, 2018 at 04:37amHello,
I am using PHP REST API.
First i create draft package, then upload form with data, and then publish it. But there is disclosure electronic signatures document get created. I don't want that form in sign process.
How to remove or disable that default document in PHP REST API?
Following is the code i am using.
'Package created from template through REST API', 'description' => 'Package created with the eSignLive REST API', 'emailMessage' => 'This message should be delivered to all signers', 'autocomplete' => true, 'type' => 'PACKAGE', 'visibility' => 'ACCOUNT', 'due' => NULL, 'language' => 'en', 'status' => 'DRAFT', 'roles' => array ( 0 => array ( 'id' => $placeholderId, 'attachmentRequirements' => array ( 0 => array ( 'status' => 'INCOMPLETE', 'description' => 'contract', 'required' => false, 'id' => 'attachment1', 'comment' => '', 'name' => 'Upload, if you have any contract document! Or Click Done.', 'data' => NULL, ), ), 'type' => 'SIGNER', 'signers' => array ( 0 => array ( 'id' => $placeholderId, 'firstName' => $firstName, 'lastName' => $lastName, 'email' => $email, ), ), 'name' => 'Signer', ), ), ); $packageJSON = json_encode($build); $packageId = json_decode($this->sendRequest($this->packageAppend . $templateId . '/clone', $packageJSON, NULL, 'application/json'), true); return $packageId; } //Create package public function buildPackage($application_id) { $application = Application::find($application_id); $title = $application->entity_name.' - '.date('d-m-Y'); /*if(empty($application->directors)){ return redirect('home/application/'.$application->unique_id.'/signature'); }*/ $roles = array(); $i = 1; //directors signers (ID: Signer1 & Signer2) if(!empty($application->directors)){ foreach (unserialize($application->directors) as $key => $value) { if(!empty($value['email'])){ $roles[] = array( 'id' => 'Signer'.$i, 'type' => 'SIGNER', 'signers' => array( array( 'email' => trim($value['email']), 'firstName' => trim($value['f_name']), 'lastName' => trim($value['l_name']), 'id' => 'Signer'.$i, ) ) , ); $i++; } } } //manager (ID: Manager1) $roles[] = array( 'id' => 'Manager1', 'type' => 'SIGNER', 'signers' => array( array( 'email' => '[email protected]', 'firstName' => 'Victor', 'lastName' => 'GR', 'id' => 'Manager1', ) ) , ); $build = array( 'type' => 'PACKAGE', 'status' => 'DRAFT', 'roles' => $roles, 'name' => $title, ); $packageJSON = json_encode($build); $packageId = json_decode($this->sendRequest($this->packageAppend, $packageJSON, NULL, NULL), true); return $packageId; } //Upload document public function buildDocument($packageId,$application_id) { $application = Application::find($application_id); $payment_term = PaymentTerm::where('application_id',$application->id)->first(); $director = unserialize($application->directors); $user = Auth::user(); $director_count = 1; $build = array( 'fields' => array( array( 'value' => $application->entity_name, 'name' => 'customer_name', ) , array( 'value' => $application->address, 'name' => 'customer_address', ) , array( 'value' => $application->phone, 'name' => 'telephone', ) , array( 'value' => $user->company_name, 'name' => 'supplier_name', ) , array( 'value' => $user->address, 'name' => 'supplier_address', ) , array( 'value' => $user->state.', '.$user->pincode, 'name' => 'supplier_address2', ) , array( 'value' => '', 'name' => 'email', ) , array( 'value' => $application->abn_number, 'name' => 'abn_number', ) , array( 'value' => $payment_term->installment, 'name' => 'installment', ) , array( 'value' => $payment_term->term, 'name' => 'month', ) , array( 'value' => $user->document_fee, 'name' => 'handling_fee', ) ) , 'extract' => true, 'name' => 'GRENKE - EQUIPMENT LEASE AGREEMENT FOR BUSINESS PURPOSES', 'id' => 'contract' ); if(isset($director[0]['f_name'])){ //directors $build['fields'][] = array( 'value' => $director[0]['f_name'].' '.$director[0]['l_name'], 'name' => 'director_name_1', ); } if(isset($director[1]['f_name'])){ $director_count = 2; $build['fields'][] = array( 'value' => $director[1]['f_name'].' '.$director[1]['l_name'], 'name' => 'director_name_2', ); } //items list foreach ($application->items as $key => $value) { if(($key+1) == 5){ break; } $build['fields'][] = array( 'value' => $value->category->name, 'name' => 'item_'.($key+1), ); $build['fields'][] = array( 'value' => $value->quantity, 'name' => 'qty_'.($key+1), ); } //items list second full if(count($application->items) > 4){ foreach ($application->items as $key => $value) { $build['fields'][] = array( 'value' => $value->category->name, 'name' => 'item_1_'.($key+1), ); $build['fields'][] = array( 'value' => $value->quantity, 'name' => 'qty_1_'.($key+1), ); } } $documentJSON = json_encode($build); if($director_count == 2){ $postdata = "--" . $this->MULTIPART_BOUNDARY . "\r\n"; $postdata .= "Content-Disposition: form-data; name=\"file\"; filename=\"application_pdf_form_d_2.pdf\"\r\n"; $postdata .= "Content-Type: application/pdf" . "\r\n\r\n"; $postdata .= file_get_contents(asset('upload/application_pdf_form_d_2.pdf')); $postdata .= "\r\n\r\n"; $postdata .= "--" . $this->MULTIPART_BOUNDARY . "\r\n"; $postdata .= "Content-Disposition: form-data; name=\"payload\"\r\n\r\n"; $postdata .= $documentJSON; $postdata .= "\r\n\r\n"; $postdata .= "--" . $this->MULTIPART_BOUNDARY . "--\r\n"; }else{ $postdata = "--" . $this->MULTIPART_BOUNDARY . "\r\n"; $postdata .= "Content-Disposition: form-data; name=\"file\"; filename=\"application_pdf_form_d_1.pdf\"\r\n"; $postdata .= "Content-Type: application/pdf" . "\r\n\r\n"; $postdata .= file_get_contents(asset('upload/application_pdf_form_d_1.pdf')); $postdata .= "\r\n\r\n"; $postdata .= "--" . $this->MULTIPART_BOUNDARY . "\r\n"; $postdata .= "Content-Disposition: form-data; name=\"payload\"\r\n\r\n"; $postdata .= $documentJSON; $postdata .= "\r\n\r\n"; $postdata .= "--" . $this->MULTIPART_BOUNDARY . "--\r\n"; } $status = $this->sendRequest($this->packageAppend . $packageId . '/documents', $documentJSON, $postdata, 'multipart/form-data; boundary=' . $this->MULTIPART_BOUNDARY); return $status; } //Send Package public function buildSend($packageId) { $build = array( 'status' => 'SENT' ); $sendJSON = json_encode($build); $this->sendRequest($this->packageAppend . $packageId, $sendJSON, NULL, 'application/json'); return NULL; } //Sender signs consent and contract documents public function buildSign($packageId) { $build = array( 'documents' => array( array( 'id' => 'contract', 'name' => 'Application Form' ) ) ); $signJSON = json_encode($build); $signatureAppend = $this->packageAppend . $packageId . '/documents/signed_documents'; $this->sendRequest($signatureAppend, $signJSON, NULL, 'application/json'); return NULL; } //Get a session token public function buildToken($packageId) { $build = array( 'packageId' => $packageId, 'signerId' => 'Manager1' ); $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 { $postfields = $document; } $headerOptions = array( 'Authorization: Basic ' . $this->key, 'Accept: application/json,application/zip,text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' ); 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_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; }; } //cURL function to send requests to eSignLive public function sendGetRequest($type) { $headerOptions = array( 'Content-Type: application/pdf', 'Authorization: Basic '.$this->key ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->url . $type); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_HTTPHEADER, $headerOptions); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $name = time().'.pdf'; $file = 'upload/filled/'.$name; $filename = 'filename.pdf'; file_put_contents($file, $response); header('Content-type: application/pdf'); header('Content-Disposition: inline; filename="' . $filename . '"'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . filesize($file)); header('Accept-Ranges: bytes'); return $name; } }?>
Reply to: Remove default disclosure electronic signatures document while creating new doc
Monday, October 22, 2018 at 05:14am