【问题标题】:PHP Laravel DocuSign Embedded Signing: Input string was not in a correct formatPHP Laravel DocuSign 嵌入式签名:输入字符串的格式不正确
【发布时间】:2018-11-27 18:28:27
【问题描述】:

目前使用: Laravel 5.5

"tucker-eric/docusign-rest-client": "^1.0",

"tucker-eric/laravel-docusign": "^0.1.1"

目的是生成一个 URL,以便所有客户/代理当场签名

这是我目前所拥有的

我先创建客户端

$client = new DocuSign\Rest\Client([
        'username'       => env('DOCUSIGN_USERNAME'),
        'password'       => env('DOCUSIGN_PASSWORD'),
        'integrator_key' => env('DOCUSIGN_INTEGRATOR_KEY'),
        'host'           => env('DOCUSIGN_HOST')
    ]);

我为每个签名者指定他们的姓名和电子邮件

    $templateRole1 = $client->templateRole([
        'email'     => 'abc@gmail.com',
        'name'      => 'abc',
        'role_name' => 'Agent'
    ]);

    $templateRole2 = $client->templateRole([
        'email'     => 'abc123@gmail.com',
        'name'      => 'abc',
        'role_name' => 'Purchaser 1'
    ]);

    $templateRole3 = $client->templateRole([
        'email'     => 'abc124@gmail.com',
        'name'      => 'abc124',
        'role_name' => 'Purchaser 2'
    ]);

    $templateRole4 = $client->templateRole([
        'email'     => 'abc125@gmail.com',
        'name'      => 'abc125',
        'role_name' => 'Seller'
    ]);

我创建了信封(不知道为什么要发送它,我还不想发送它

    $envelopeDefinition = $client->envelopeDefinition([
        'status'         => 'sent',
        'email_subject'  => '[DocuSign PHP SDK] - Signature Request Sample',
        'template_id'    => '***abc-123-',
        'template_roles' => [
            $templateRole1,
            $templateRole2,
            $templateRole3,
            $templateRole4,
        ],
    ]);

信封选项只是因为即使我没有任何

    $envelopeOptions = $client->envelopes->createEnvelopeOptions([]);

创建最终信封

    $envelopeSummary = $client->envelopes->createEnvelope($envelopeDefinition, $envelopeOptions);

准备嵌入,以便我可以提取 URL

        $envelopeApi = $client->envelopes;
        $recipient_view_request = new \DocuSign\eSign\Model\RecipientViewRequest();
        $recipient_view_request->setReturnUrl('https://www.example.net/callback/docusign');
        $recipient_view_request->setClientUserId((string) $client->getAccountId());
        $recipient_view_request->setAuthenticationMethod("None");

    try {
            $signingView = $envelopeApi->createRecipientView($client->getAccountId(), $envelopeSummary->getEnvelopeId(), $recipient_view_request);
        } catch (DocuSign\eSign\ApiException $e){        
            echo "Error connecting Docusign : " . $e->getResponseBody()->errorCode . " " . $e->getResponseBody()->message;
        }

返回:

object(DocuSign\eSign\Model\ErrorDetails)#419 (1) { ["container":protected]=> array(2) { ["error_code"]=> string(20) "INVALID_REQUEST_BODY" ["message"]=> string(94) "The request body is missing or improperly formatted. Input string was not in a correct format." } } Error connecting Docusign : INVALID_REQUEST_BODY The request body is missing or improperly formatted. Input string was not in a correct format.done

我的问题是我做错了什么才能返回此错误,为什么它会将电子邮件发送给签名的人,因为我没有明确告诉它

谢谢

【问题讨论】:

  • 嘿,$envelopeDefinition 中的状态参数是“已发送”,这可能是导致发送的原因吗?还有哪些可用的选项。至于您的错误,您发送的请求不是它期望的格式,请查看此方法 createRecipientView 的 API,并确保您发送所有正确的参数。
  • 是的,我为你找到了这个github.com/docusign/docusign-php-client/blob/master/test/… 看看第 95 行还有一些代码可能会有所帮助。

标签: php laravel docusignapi


【解决方案1】:

我不熟悉 Eric Tucker 的 DocuSign Laravel 外观。如果您需要添加超出 Eric 外观提供的属性,那么您需要派生该项目以添加对其他属性的支持。

您有一个服务器常驻模板。您想使用它在您的 Laravel 应用中为签名者提供嵌入式签名仪式。

要将签名者收件人标记为嵌入式签名者,请将client_user_id 属性设置为签名者对象。例如:

$templateRole1 = $client->templateRole([
    'email'     => 'abc@gmail.com',
    'name'      => 'abc',
    'role_name' => 'Agent',
    'client_user_id' => '1000'
]);

请注意,client_user_id 应该将此签名者唯一标识为您的应用程序中的用户。

回复:为什么签名者会收到电子邮件邀请签名?

设置client_user_id 将禁止向签名者发送电子邮件通知。

Re:信封应该寄出还是处于草稿状态?

您需要sent 状态,使收件人能够通过您接下来将创建的嵌入式签名仪式进行签名。

Re:用于创建信封的信封选项。

通常,使用 PHP SDK 创建信封时不提供 EnvelopeOptions。但是,Eric Tucker 可能会合并呼叫或其他什么。你需要检查他的代码。

这是一个发送信封的标准 PHP 调用:

    $config = new \DocuSign\eSign\Configuration();
    $config->setHost($args['base_path']);
    $config->addDefaultHeader('Authorization', 'Bearer ' . $args['ds_access_token']);
    $api_client = new \DocuSign\eSign\ApiClient($config);
    $envelope_api = new \DocuSign\eSign\Api\EnvelopesApi($api_client);
    $results = $envelope_api->createEnvelope($args['account_id'], $envelope_definition);
    $envelope_id = $results->getEnvelopeId();

获取嵌入式签名仪式的重定向 URL

正常的 PHP 方法是调用 createRecipientView 方法。您需要在创建信封步骤中提供签名者的姓名、电子邮件和 client_user_id,以及您的应用程序用来识别签名者的身份验证方法。当然,还有信封 ID。

例子:

    # Create the Recipient View request object
    $authentication_method = 'None'; # How is this application authenticating
    # the signer? See the `authenticationMethod' definition
    # https://developers.docusign.com/esign-rest-api/reference/Envelopes/EnvelopeViews/createRecipient

    $recipient_view_request = new \DocuSign\eSign\Model\RecipientViewRequest([
        'authentication_method' => $authentication_method,
        'client_user_id' => $envelope_args['signer_client_id'],
        'recipient_id' => '1',
        'return_url' => $envelope_args['ds_return_url'],
        'user_name' => $envelope_args['signer_name'], 
        'email' => $envelope_args['signer_email']
    ]);
    # 4. Obtain the recipient_view_url for the signing ceremony
    # Exceptions will be caught by the calling function
    $results = $envelope_api->createRecipientView($args['account_id'], $envelope_id,
        $recipient_view_request);

    $redirect_url = $results['url'];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    • 2013-08-22
    相关资源
    最近更新 更多