dos8244 2018-11-27 18:28
浏览 97

PHP Laravel DocuSign嵌入式签名:输入字符串的格式不正确

Currently Using: Laravel 5.5

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

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

Intention is to generate a URL so all customers / agents sign on the spot

Here is what I have so far

I first create the client

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

For each signer I assign their name and email

    $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'
    ]);

I create the envelope (not sure why it sends it, I dont want it sent yet

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

Envelope options just because even tho I don't have any

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

Creates the final envelope

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

Prepare the embedding so I can extract the 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;
        }

Which returns:

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

My question is what I'm doing wrong to get this error returned, and why is it sending the email to the people signing as I didn't explicitly tell it

Thanks

  • 写回答

1条回答 默认 最新

  • doubao12345 2018-11-28 04:53
    关注

    I'm not familiar with the DocuSign Laravel facades by Eric Tucker. If you need to add attributes beyond what Eric's facades provide then you'll need to fork that project to add support for the additional attributes.

    You have a server-resident template. You want to use it to provide an embedded signing ceremony in your Laravel app for the signers.

    For a signer recipient to be marked as an embedded signer, set the client_user_id attribute to the signer object. For example:

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

    Note that the client_user_id should uniquely identify this signer as a user within your application.

    Re: Why are the signers receiving email invites to sign?

    Setting the client_user_id will suppress the email notification to the signer.

    Re: should the envelope be sent or be in draft status?

    You want sent status, which enables recipients to sign via the embedded signing ceremony you'll be next creating.

    Re: Envelope Options for creating the envelope.

    Normally, you don't supply an EnvelopeOptions when creating an envelope with the PHP SDK. However, Eric Tucker could be combining calls or something. You'll need to check his code.

    Here is a standard PHP call to send an envelope:

        $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();
    

    Obtaining the redirect URL for the embedded signing ceremony

    Normal PHP way to do this is to call the createRecipientView method. You need to provide the signer's name, email, and client_user_id from the create envelope step, along with the authentication method your app is using to identify the signer. And, of course, the envelope id too.

    Example:

        # 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'];
    
    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭