如何通过Docsign API生成合同和签名?

问题描述 投票:0回答:1

我无法找到集成 Docsign 合同和签名 API 的正确方法。 我需要 php 中的文档参考和示例来在我的网站中交互这些 API。

官方文件对我来说很清楚,所以如果有人可以帮助我。

php docusignapi
1个回答
0
投票

这是执行此操作的 PHP 代码,它也在 GitHub 中:

但是,为了确保您立即成功,我建议您使用我们的快速入门下载为您配置了所有身份验证相关配置的 PHP 代码。

PHP 代码:

public static function make_envelope(array $args, string $demoPath, string $pdfFile): EnvelopeDefinition
    {
        # document 1 (pdf) has tag /sn1/
        #
        # The envelope has one recipient.
        # recipient 1 - signer
        #
        # Read the file
        $content_bytes = file_get_contents($demoPath . $pdfFile);
        $base64_file_content = base64_encode($content_bytes);

        # Create the document model
        $document = new Document(
            [ # create the DocuSign document object
                'document_base64' => $base64_file_content,
                'name' => 'Example 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
            ]
        );

        # Create the signer recipient model
        $signer = new Signer(
            [ # The signer
                'email' => $args['signer_email'],
                'name' => $args['signer_name'],
                'recipient_id' => "1",
                'routing_order' => "1",
                # Setting the client_user_id marks the signer as embedded
                'client_user_id' => $args['signer_client_id']
            ]
        );

        # Create a sign_here tab (field on the document)
        $sign_here = new SignHere(
            [ # DocuSign SignHere field/tab
                'anchor_string' => '/sn1/',
                'anchor_units' => 'pixels',
                'anchor_y_offset' => '10',
                'anchor_x_offset' => '20'
            ]
        );

        # Add the tabs model (including the sign_here tab) to the signer
        # The Tabs object wants arrays of the different field/tab types
        $signer->settabs(new Tabs(['sign_here_tabs' => [$sign_here]]));

        // Next, create the top level envelope definition and populate it.
        $envelope_definition = new EnvelopeDefinition(
            [
                'email_subject' => "Please sign this document sent from the PHP SDK",
                'documents' => [$document],
                # The Recipients object wants arrays for each recipient type
                'recipients' => new Recipients(['signers' => [$signer]]),
                'status' => "sent" # requests that the envelope be created and sent.
            ]
        );

        return $envelope_definition;
    }
© www.soinside.com 2019 - 2024. All rights reserved.