Я хочу подписать документы в моем веб-приложении с помощью docusign - PullRequest
1 голос
/ 20 января 2020

Я столкнулся с серьезной проблемой, касающейся API DocuSign.

Я хочу подписать документы в моем веб-приложении с использованием встроенной церемонии подписания, но без аутентификации моих пользователей, поскольку большинство пользователей моего приложения не будут иметь любые учетные записи DocuSign с ними.

Итак, дело в том.

Пользователь заходит на мой сайт и делает подпись с помощью DocuSign, и когда я закончу, я сохраню документ на своем сервере и продолжу.

Прямо сейчас я использую github Пример кода для получения документов, подписанных с использованием потока JWT GRant

php пример

Что я делаю:

$this->checkToken();

# create the envelope definition

$signer_name = DSConfig::signer_name();
$signer_email = DSConfig::signer_email();

$demo_docs_path = getcwd() . '/' . self::DEMO_DIR . '/';

$content_bytes = file_get_contents($demo_docs_path . self::DOC_3_PDF);
$doc3_b64 = base64_encode($content_bytes);
# Create the document models

$clientUserId=5;
$document1 = new \DocuSign\eSign\Model\Document([  # create the DocuSign document object
    'document_base64' => $doc3_b64,
    'name' => 'Test Document',  # can be different from actual file name
    'file_extension' => 'pdf',  # many different document types are accepted
    'document_id' => '1',  # a label used to reference the doc
    'client_user_id' => $clientUserId
]);
# The order in the docs array determines the order in the envelope
//$envelope_definition->setDocuments([$document1]);
# Create the signer recipient model
$signer1 = new \DocuSign\eSign\Model\Signer([
    'email' => "mahjoor_samiullah@hotmail.com", 'name' => "Samiullah Mahjoor",
    'recipient_id' => "1", 'routing_order' => "1"]);
# routingOrder (lower means earlier) determines the order of deliveries
# to the recipients. Parallel routing order is supported by using the
# same integer as the order for two or more recipients.
# create a cc recipient to receive a copy of the documents

$sign_here1 = new \DocuSign\eSign\Model\SignHere(['document_id' => '1', 'page_number' => '1', 'recipient_id' => '1', 
'tab_label' => 'SignHereTab', 'x_position' => '35', 'y_position' => '680']);
# Add the tabs model (including the sign_here tabs) to the signer
# The Tabs object wants arrays of the different field/tab types
$signer1->setTabs(new \DocuSign\eSign\Model\Tabs([
    'sign_here_tabs' => [$sign_here1]]));
# Add the recipients to the envelope object
//$recipients = new \DocuSign\eSign\Model\Recipients(['signers' => [$signer1]]);
//$envelope_definition->setRecipients($recipients);
# Request that the envelope be sent by setting |status| to "sent".
# To request that the envelope be created as a draft, set to "created"
//$envelope_definition->setStatus("sent");

$envelopeDefinition = new DocuSign\eSign\Model\EnvelopeDefinition([
    'email_subject' => "Please sign this document",
    'documents' => [$document1], # The order in the docs array determines the order in the envelope
    # The Recipients object wants arrays for each recipient type
    'recipients' => new DocuSign\eSign\Model\Recipients(['signers' => [$signer1]]), 
    'status' => "sent" # requests that the envelope be created and sent.
]);

$envelopeApi = new DocuSign\eSign\Api\EnvelopesApi(self::$apiClient);
$results = $envelopeApi->createEnvelope(self::$accountID, $envelopeDefinition);
$envelopeId = $results['envelope_id'];

$recipientViewRequest = new DocuSign\eSign\Model\RecipientViewRequest([
'authentication_method' => 'None', 'client_user_id' => self::$apiClient,
'recipient_id' => '1', 'return_url' => "http://www.dev.overheadlending.com/app/docusign/main.php",
'user_name' => "Samiullah", 'email' => "mahjoor_samiullah@hotmail.com"
    ]);
$results = $envelopeApi->createRecipientView(self::$accountID, $envelopeId,
    $recipientViewRequest);


return $results;

Затем перенаправляем пользователя with:

header('Location: ' . $result['url']);

В качестве URL-адреса будет использоваться URL-адрес перенаправления для встраивания подписи.

Вот URL-адрес, на котором отображается ошибка:

Вызов неопределенного метода DocuSign \ eSign \ ApiClient :: swaggerTypes () в /home4/b4fgf4xx/dev.overheadlending.com/app/docusign/vendor/docusign/esign-client/src/ObjectSerializer.php:62 трассировки стека: # 0 / home4 /b4fgf4xx/dev.overheadlending.com/app/docusign/vendor/docusign/esign-client/src/ObjectSerializer.php(65): DocuSign \ eSign \ ObjectSerializer :: sanitizeForSerialization (Object (DocuSign \ eSign \ ApiClient))

1 /home4/b4fgf4xx/dev.overheadlending.com/app/docusign/vendor /docusign/esign-client/src/ApiClient.php(159):

DocuSign \ eSign \ ObjectSerializer :: sanitizeForSerialization (Object (DocuSign \ eSign \ Model \ RecipientViewRequest))

2 /home4/b4fgf4xx/dev.overheadlending.com/app/docusign/vendor/docusign/esign-client/src/Api/EnvelopesApi.php(3222):

DocuSign \ eSign \ ApiClient-> callApi ('/ v2 / account / 98 ...', 'POST', Array, Object (DocuSign \ eSign \ Model \ RecipientViewRequest), Array, '\ DocuSign \ eSign ...', '/ v2 / accounts / { a ... ') # 3 /home4/b4fgf4xx/dev.overheadlending.com/app/docusign/vendor/docusign/esign-client/src/Api/Envelo в /home4/b4fgf4xx/dev.overheadlending.com/app/ docusign / vendor / docusign / esign-client / src / ObjectSerializer. php on line 62

, если кто-то может помочь и предоставить мне пример кода для вышеуказанной проблемы.

Спасибо!

Ответы [ 2 ]

0 голосов
/ 21 января 2020

Хорошо, я также заметил две другие проблемы, поскольку вы хотите использовать встроенную подпись.

Вам необходимо указать client_user_id для получателя подписи в вашем конверте :: запрос на создание:

# Create the signer recipient model
$signer1 = new \DocuSign\eSign\Client\Model\Signer([
    'email' => "mahjoor_samiullah@hotmail.com", 'name' => "Samiullah Mahjoor",
    'recipient_id' => "1", 'routing_order' => "1",
    'client_user_id' => "1000"
]);

Вам необходимо указать то же значение client_user_id в вызове представления создания получателей:

$recipientViewRequest = new DocuSign\eSign\Client\Model\RecipientViewRequest([
    'authentication_method' => 'None', 
    'client_user_id' => "1000",
    'recipient_id' => '1', 
    'return_url' => "http://www.dev.overheadlending.com/app/docusign/main.php",
    'user_name' => "Samiullah", 'email' => "mahjoor_samiullah@hotmail.com"
]);

Также обратите внимание, что client_user_id должно иметь значение, совпадающее с идентификатором записи вашего собственного приложения для подписывающего лица .

0 голосов
/ 20 января 2020

К сожалению, пример кода eg-03- php -auth-code-grant еще не обновлен для соответствия текущей версии DocuSign PHP SDK. (См. выпуск 6 )

Исправление должно изменить

\DocuSign\eSign\Api\
to
\DocuSign\eSign\Client\Api\

везде в вашем коде.

Кроме того, чтобы предложить встроенную подпись для Посетив ваш веб-сайт / веб-портал, вы реализуете правильный шаблон:

  1. Используйте JWT Grant для получения токена доступа, который олицетворяет «отправителя» конверта.
  2. Создайте конверт.
  3. Создайте получателя, который позволит посетителю сайта подписать конверт.

Посетителю вашего сайта (подписавшему лицу) не нужна аккаунт на DocuSign.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...