/**
* Create document from template
* Based on official Digio API documentation
*/
public function create_document_from_template($signer_data, $template_values = array()) {
error_log('=== DIGIO API: Create Document ===');
// OFFICIAL DIGIO ENDPOINT
$endpoint = $this->api_url . '/client/document/uploadpdf';
error_log('Endpoint: ' . $endpoint);
error_log('Template: ' . $this->template_key);
// Create request payload
$request_data = array(
'signers' => json_encode(array(
array(
'identifier' => $signer_data['email'],
'name' => $signer_data['name'],
'reason' => 'Terms and Conditions Agreement'
)
)),
'expire_in_days' => 7,
'display_on_page' => '1',
'send_sign_link' => 'true',
'sign_type' => 'aadhaar'
);
// Add template
$request_data['template_name'] = $this->template_key;
// Add template values
foreach ($template_values as $key => $value) {
$request_data[$key] = $value;
}
error_log('Request data: ' . print_r($request_data, true));
// Build multipart form data
$boundary = wp_generate_password(24, false);
$body = '';
foreach ($request_data as $key => $value) {
$body .= "--{$boundary}\r\n";
$body .= "Content-Disposition: form-data; name=\"{$key}\"\r\n\r\n";
$body .= $value . "\r\n";
}
$body .= "--{$boundary}--\r\n";
// Make request
$response = wp_remote_post($endpoint, array(
'headers' => array(
'Authorization' => 'Basic ' . base64_encode($this->client_id . ':' . $this->client_secret),
'Content-Type' => 'multipart/form-data; boundary=' . $boundary
),
'body' => $body,
'timeout' => 120,
'sslverify' => true
));
if (is_wp_error($response)) {
error_log('ERROR: ' . $response->get_error_message());
return array(
'success' => false,
'message' => $response->get_error_message()
);
}
$status_code = wp_remote_retrieve_response_code($response);
$response_body = wp_remote_retrieve_body($response);
$response_data = json_decode($response_body, true);
error_log('Status: ' . $status_code);
error_log('Response: ' . $response_body);
if ($status_code !== 200 && $status_code !== 201) {
return array(
'success' => false,
'message' => $response_data['message'] ?? 'API Error'
);
}
// Get document ID and sign link
$document_id = $response_data['id'] ?? '';
$sign_link = $response_data['signing_parties'][0]['sign_link'] ?? '';
return array(
'success' => true,
'document_id' => $document_id,
'sign_link' => $sign_link,
'data' => $response_data
);
}
Deprecated: Creation of dynamic property TUTOR_PRO\init::$course_duplicator is deprecated in /home/u494217993/domains/vijaythakkar.com/public_html/wp-content/plugins/tutor-pro/classes/init.php on line 68
Deprecated: Creation of dynamic property TUTOR_PRO\init::$instructor_percentage is deprecated in /home/u494217993/domains/vijaythakkar.com/public_html/wp-content/plugins/tutor-pro/classes/init.php on line 69
Deprecated: Creation of dynamic property TUTOR_PRO\init::$enrollment_expiry is deprecated in /home/u494217993/domains/vijaythakkar.com/public_html/wp-content/plugins/tutor-pro/classes/init.php on line 70
Deprecated: Creation of dynamic property TUTOR_PRO\init::$dashboard is deprecated in /home/u494217993/domains/vijaythakkar.com/public_html/wp-content/plugins/tutor-pro/classes/init.php on line 71
Deprecated: Creation of dynamic property TUTOR_PRO\init::$shortcode is deprecated in /home/u494217993/domains/vijaythakkar.com/public_html/wp-content/plugins/tutor-pro/classes/init.php on line 72
Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the tutor
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/u494217993/domains/vijaythakkar.com/public_html/wp-includes/functions.php on line 6121
Deprecated: Return type of Google\Model::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u494217993/domains/vijaythakkar.com/public_html/wp-content/plugins/tutor-pro/vendor/google/apiclient/src/Model.php on line 256
Deprecated: Return type of Google\Model::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u494217993/domains/vijaythakkar.com/public_html/wp-content/plugins/tutor-pro/vendor/google/apiclient/src/Model.php on line 261
Deprecated: Return type of Google\Model::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u494217993/domains/vijaythakkar.com/public_html/wp-content/plugins/tutor-pro/vendor/google/apiclient/src/Model.php on line 268
Deprecated: Return type of Google\Model::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u494217993/domains/vijaythakkar.com/public_html/wp-content/plugins/tutor-pro/vendor/google/apiclient/src/Model.php on line 278
Deprecated: Return type of Google\Collection::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u494217993/domains/vijaythakkar.com/public_html/wp-content/plugins/tutor-pro/vendor/google/apiclient/src/Collection.php on line 22
Deprecated: Return type of Google\Collection::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u494217993/domains/vijaythakkar.com/public_html/wp-content/plugins/tutor-pro/vendor/google/apiclient/src/Collection.php on line 38
Deprecated: Return type of Google\Collection::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u494217993/domains/vijaythakkar.com/public_html/wp-content/plugins/tutor-pro/vendor/google/apiclient/src/Collection.php on line 30
Deprecated: Return type of Google\Collection::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u494217993/domains/vijaythakkar.com/public_html/wp-content/plugins/tutor-pro/vendor/google/apiclient/src/Collection.php on line 43
Deprecated: Return type of Google\Collection::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u494217993/domains/vijaythakkar.com/public_html/wp-content/plugins/tutor-pro/vendor/google/apiclient/src/Collection.php on line 14
Deprecated: Return type of Google\Collection::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/u494217993/domains/vijaythakkar.com/public_html/wp-content/plugins/tutor-pro/vendor/google/apiclient/src/Collection.php on line 49
Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the unlimited-elements-for-elementor
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/u494217993/domains/vijaythakkar.com/public_html/wp-includes/functions.php on line 6121
Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the woo-checkout-field-editor-pro
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/u494217993/domains/vijaythakkar.com/public_html/wp-includes/functions.php on line 6121
Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the woo-discount-rules
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/u494217993/domains/vijaythakkar.com/public_html/wp-includes/functions.php on line 6121
Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the woo-discount-rules-pro
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/u494217993/domains/vijaythakkar.com/public_html/wp-includes/functions.php on line 6121
Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the ooohboi-steroids
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/u494217993/domains/vijaythakkar.com/public_html/wp-includes/functions.php on line 6121
Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the woocommerce-order-status-control
domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init
action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/u494217993/domains/vijaythakkar.com/public_html/wp-includes/functions.php on line 6121
Warning: Constant ALLOW_UNFILTERED_UPLOADS already defined in /home/u494217993/domains/vijaythakkar.com/public_html/wp-config.php on line 110
Warning: Cannot modify header information - headers already sent by (output started at /home/u494217993/domains/vijaythakkar.com/public_html/wp-content/plugins/tutor-pro/classes/init.php:72) in /home/u494217993/domains/vijaythakkar.com/public_html/wp-includes/pluggable.php on line 1450
Warning: Cannot modify header information - headers already sent by (output started at /home/u494217993/domains/vijaythakkar.com/public_html/wp-content/plugins/tutor-pro/classes/init.php:72) in /home/u494217993/domains/vijaythakkar.com/public_html/wp-includes/pluggable.php on line 1453