1

Here is my code in 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);
    }

I tried a lot to get the url but can't figure out, how to achieve this? Can anyone provide some reference regarding this problem?

Larry K
  • 47,808
  • 15
  • 87
  • 140

2 Answers2

1

By design, that URL is not available via an API. If you want the signer to use embedded signing, you can create your own URL that you'll use to obtain an embedded signing URL when your url is invoked.

If you (eventually) want the signer to receive an email/sms invitation to sign (remote signer), then you could trigger DocuSign to send the email when you want.

Larry K
  • 47,808
  • 15
  • 87
  • 140
1

Like Larry said you cannot get the URL that DocuSign sends, but you can get another URL that you can use to embed in your own application.

The PHP code example can be found in GitHub - https://github.com/docusign/code-examples-php/blob/master/src/Services/Examples/eSignature/EmbeddedSigningService.php

Here is the relevant code, note the clientUserId must be used:

    $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);
Inbar Gazit
  • 12,566
  • 1
  • 16
  • 23