我不是一个非常有经验的程序员,并且发现很难使DocuSign API集成按客户希望的方式工作。 我的问题是找到一个稳定的解决方案,以便在丢失合同的情况下再次将合同重新发送给同一收件人。我花了一段时间才找到可以创建新电子邮件的内容,而不仅仅是偶尔发送。 在我的案例中,技巧是添加注释的。
以下是任何人都可以使用的代码:
class DocuSignSample
{
public function ResendEmail($args)
{
global $docusign_args;
$username = $docusign_args['username'];
$password = $docusign_args['password'];
$integrator_key = $docusign_args['integrator_key'];
// change to production (www.docusign.net) before going live
$host = $docusign_args['host'];
// create configuration object and configure custom auth header
$config = new DocuSign\eSign\Configuration();
$config->setHost($host);
$config->addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" . $username . "\",\"Password\":\"" . $password . "\",\"IntegratorKey\":\"" . $integrator_key . "\"}");
// instantiate a new docusign api client
$apiClient = new DocuSign\eSign\ApiClient($config);
$accountId = null;
try
{
//*** STEP 1 - Login API: get first Account ID and baseURL
$authenticationApi = new DocuSign\eSign\Api\AuthenticationApi($apiClient);
$options = new \DocuSign\eSign\Api\AuthenticationApi\LoginOptions();
$loginInformation = $authenticationApi->login($options);
if(isset($loginInformation) && count($loginInformation) > 0)
{
$loginAccount = $loginInformation->getLoginAccounts()[0];
$host = $loginAccount->getBaseUrl();
$host = explode("/v2",$host);
$host = $host[0];
// UPDATE configuration object
$config->setHost($host);
// instantiate a NEW docusign api client (that has the correct baseUrl/host)
$apiClient = new DocuSign\eSign\ApiClient($config);
if(isset($loginInformation))
{
$accountId = $loginAccount->getAccountId();
if(!empty($accountId))
{
// Set Up Recipient Data, Update note with current date
$Recipient = new \stdClass();
$Recipient->RecipientId='1'; // In my case it is always No. 1
$Recipient->Email=$args['signer_email'];
$Recipient->name=$args['signer_name'];
$Recipient->Note='Resent on '.date("d.m.Y")." at ".date("H:i:s");
// Set Up Options - Put Recipients in Array
$options->Signers[] = $Recipient;
$options->resend_envelope='true';
$options->status='signed';
$options=json_encode($options);
// Update the Envelope Recipients
$envelopeApi = new DocuSign\eSign\Api\EnvelopesApi($apiClient);
$results = $envelopeApi->updateRecipients($accountId, $args['envelope_id'],$options);
// Get Envelope Recipients Details
$results2 = $envelopeApi->listRecipients($accountId, $args['envelope_id']);
echo "<br><br>";
print_r($results2);
if(!empty($results))
{
return "$results";
}
}
}
}
}
catch (DocuSign\eSign\ApiException $ex)
{
$error= $ex->getResponseBody()->errorCode . " " . $ex->getResponseBody()->message;
echo "$error";
}
}
}
答案 0 :(得分:0)
感谢您的解决方案和使用DocuSign。如果您只想发送有关正在等待签名的当前信封的提醒电子邮件,则推荐的技术是使用Envelopes::update并将查询参数resend_envelope
设置为true。
我会先尝试使用空的请求对象,或者只提供信封ID。
对于PHP,未经测试的代码:
$envelopeApi = new DocuSign\eSign\Api\EnvelopesApi($apiClient);
$options = new DocuSign\EnvelopesApi\UpdateOptions([resend_envelope => true]);
$body = new DocuSign\eSign\Model\Envelope([envelope_id => $envelope_id]);
$results = $envelopeApi->update($accountId, $envelope_id, $body, $options);