php 我想获取docusign发送给签名人的电子邮件中用于签署文档的URL

ztigrdn8  于 2023-02-21  发布在  PHP
关注(0)|答案(2)|浏览(126)

下面是我在laravel的代码:

public function send()
    {
        $apiClient = new ApiClient();
        $apiClient->getOAuth()->setOAuthBasePath(env('DS_AUTH_SERVER'));
        try {
            $accessToken = $this->getToken($apiClient);
        } catch (\Throwable $th) {
            return back()->withError($th->getMessage())->withInput();
        }
       
        $userInfo = $apiClient->getUserInfo($accessToken);
        $accountInfo = $userInfo[0]->getAccounts();
        $apiClient->getConfig()->setHost($accountInfo[0]->getBaseUri() . env('DS_ESIGN_URI_SUFFIX'));
       
        $envelopeDefenition = $this->buildEnvelope();
        try {
            $envelopeApi = new EnvelopesApi($apiClient);
            $result = $envelopeApi->createEnvelope($accountInfo[0]->getAccountId(), $envelopeDefenition);
            $envelopeId = $result->getEnvelopeId();
            $envelope = $envelopeApi->getEnvelope($accountInfo[0]->getAccountId(), $envelopeId);
            // $signingUrl = $envelope->getRecipientViewUrl($envelope->getRecipients()[0]); 
            // dd($signingUrl);

        } catch (\Throwable $th) {
            return back()->withError($th->getMessage())->withInput();
        }
        return view('backend.response')->with('result', $result);
    }

我尝试了很多方法来获取网址,但是我想不出,如何实现这个目标?有谁能提供一些参考吗?

zfycwa2u

zfycwa2u1#

根据设计,该URL无法通过API获得。如果您希望签名者使用嵌入式签名,则可以创建自己的URL,以便在调用您的URL时用于获取嵌入式签名URL。
如果您(最终)希望签名人收到电子邮件/短信邀请签名(远程签名人),则您可以触发DocuSign在需要时发送电子邮件。

y4ekin9u

y4ekin9u2#

就像Larry说的,您无法获得DocuSign发送的URL,但您可以获得另一个URL,您可以使用它来嵌入到您自己的应用程序中。
PHP代码示例可以在GitHub -https://github.com/docusign/code-examples-php/blob/master/src/Services/Examples/eSignature/EmbeddedSigningService.php中找到
下面是相关代码,注意必须使用clientUserId

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

public function getRecipientViewRequest($authentication_method, $envelope_args): RecipientViewRequest
{
    return new 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']
        ]
    );
}

        $envelope_api = $this->getEnvelopeApi();
        $viewUrl = $envelope_api->createRecipientView($account_id, $envelope_id, $recipient_view_request);

相关问题