我已经创建了信封,他们正在发送,但这不是我的客户想要的。他们想要发送 URL 以供用户签名。通过此方法可以正确生成 URL,但是当我打开它时,我没有看到任何签名选项;它只显示信封。我要发送邮件的用户可能没有 Docusign 帐户。我正在使用 Docusign 作为他们的签名。
我的信封生成方法:
public async Task<string> MakeRecipientViewRequest(string envelopeId, string signerEmail, string signerName, string returnUrl,
/*string signerClientId,*/ string pingUrl = null)
{
RecipientViewRequest viewRequest = new RecipientViewRequest();
viewRequest.ReturnUrl = returnUrl + "?state=123";
viewRequest.AuthenticationMethod = "none";
viewRequest.Email = signerEmail;
viewRequest.UserName = signerName;
// viewRequest.RecipientId = "1"; // This should match the RecipientId you used when creating the envelope.
// viewRequest.ClientUserId = "1001";
if (pingUrl != null)
{
viewRequest.PingFrequency = "600"; // seconds
viewRequest.PingUrl = pingUrl; // optional setting
}
var accessToken = await GetAccessToken();
var docuSignClient = new DocuSignClient(_configuration.GetValue<string>("DocuSignBaseUri"));
docuSignClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken.access_token);
EnvelopesApi envelopesApi = new EnvelopesApi(docuSignClient);
ViewUrl results1 = envelopesApi.CreateRecipientView(_configuration.GetValue<string>("DocuSignAccountId")
, envelopeId, viewRequest);
string redirectUrl = results1.Url;
return (redirectUrl);
}
public async Task<string> MakeEnvelope(string buyermail, string sellermail, IFormFile file, int offer_id
, string sellername, string buyername, string cycletitle)
{
// byte[] buffer = File.ReadAllBytes(docPdf);
byte[] fileBytes = null;
EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition();
envelopeDefinition.EmailSubject = "Please sign this document";
Document doc1 = new Document();
using (var memoryStream = new MemoryStream())
{
file.CopyToAsync(memoryStream);
fileBytes = memoryStream.ToArray();
string base64String = Convert.ToBase64String(fileBytes);
}
string doc1b64 = Convert.ToBase64String(fileBytes);
doc1.DocumentBase64 = doc1b64;
doc1.Name = file.Name;
doc1.FileExtension = "pdf";
doc1.DocumentId = "1";
// The order in the docs array determines the order in the envelope
envelopeDefinition.Documents = new List<Document> { doc1 };
var signer1 = new Signer
{
Email = sellermail,
Name = sellername,
RecipientId = "1",
RoutingOrder = "1" // This specifies the order in which recipients will sign
};
var signer2 = new Signer
{
Email = buyermail,
Name = buyername,
RecipientId = "2",
RoutingOrder = "2" // Change the order as needed
};
signer1.Tabs = new Tabs();
signer2.Tabs = new Tabs();
signer1.Tabs.SignHereTabs = new List<SignHere>();
signer2.Tabs.SignHereTabs = new List<SignHere>();
// Create signHere fields (also known as tabs) on the documents,
// We're using anchor (autoPlace) positioning
//
// The DocuSign platform searches throughout your envelope's
// documents for matching anchor strings.
signer1.Tabs = new Tabs();
signer2.Tabs = new Tabs();
signer1.Tabs.SignHereTabs = new List<SignHere>();
signer2.Tabs.SignHereTabs = new List<SignHere>();
SignHere signHere1 = new SignHere();
signHere1.DocumentId = "1";
signHere1.PageNumber = "1";
signHere1.RecipientId = "1";
signHere1.XPosition = "470";
signHere1.YPosition = "235";
signer1.Tabs.SignHereTabs.Add(signHere1);
SignHere signHere2 = new SignHere();
signHere2.DocumentId = "1";
signHere2.PageNumber = "1";
signHere2.RecipientId = "1";
signHere2.XPosition = "75";
signHere2.YPosition = "235";
signer2.Tabs.SignHereTabs.Add(signHere2);
envelopeDefinition.Recipients = new Recipients
{
Signers = new List<Signer> { signer1, signer2 }
};
// Add the recipient to the envelope object
Recipients recipients = new Recipients
{
Signers = new List<Signer> { signer1, signer2 },
};
envelopeDefinition.Recipients = recipients;
// Request that the envelope be sent by setting |status| to "sent".
// To request that the envelope be created as a draft, set to "created"
envelopeDefinition.Status = "sent";
var accessToken = await GetAccessToken();
var docuSignClient = new DocuSignClient(_configuration.GetValue<string>("DocuSignBaseUri"));
docuSignClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken.access_token);
EnvelopesApi envelopesApi = new EnvelopesApi(docuSignClient);
EnvelopeSummary results = envelopesApi.CreateEnvelope(_configuration.GetValue<string>("DocuSignAccountId"), envelopeDefinition);
string envelopeId = results.EnvelopeId;
return envelopeId;
}
我尝试了不同的参数,但没有帮助。
很可能您的信封状态不正确。
您在最后一行之前的envelopeId必须是一个信封,其中有一个收件人(签名者),其中“1001”作为clientUserId以及您输入的姓名/电子邮件。
此外,被注释掉的这一行是错误的:
//viewRequest.ClientUserId = "1001";
您可以在 GitHub
中找到完整的工作代码您提供的代码缺少必要的“此处签名”选项卡。请包含它们并再次验证。
{
"recipients": {
"signers": [`{
"clientUserId": "1001",
"email": "",
"name": "",
"recipientId": 1,
"routingOrder": "1",
"tabs": {
"signHereTabs": [
{
"anchorIgnoreIfNotPresent": "false",
"anchorString": "Signature_anchor_1",
"anchorUnits": "pixels",
"anchorYOffset": "0",
"name": "Please sign here",
"recipientId": "1"
}
]
}`