Has anyone tried to change the "fixed amount" of a "payment item" using the DocuSign rest API?
I'm using a template that's been designed and setup via the DocuSign web page.
The template consists of 2 template roles, one of which is the "Customer". It contains a payment item in which I would like to pre-fill the dollar amount, payment description item code, and payment description item details.
I found this in the documentation under 'formulaTabs':
"<paymentDetails>" +
"<lineItems>" +
"<paymentLineItem>" +
"<amountReference>\\*txtPayment</amountReference>" +
"<description>" + polNum + "</description>" +
"<itemCode>" + custId + "</itemCode>" +
"</paymentLineItem>" +
"</lineItems>" +
"</paymentDetails>" +
but, I'm not sure where to place it, I've tried using it within
<envelopeDefinition> </envelopeDefinition>
and
<text> </text>
But, I keep coming up with a PAYMENTTABS_LINEITEM_AMOUNT_IS_MISSING error.
I have a text field on the template labeled txtPayment (which I don't really need).
The payment item is labeled txtPaymentItem.
I'm open to using other means if necessary.
Thanks,
I am hoping that you are able to use Payment using WEBApp but struggling in using API, so the correct JSON structure to use DocuSignPayment API is,
"formulaTabs": [{
"ConcealValueOnDocument": "false",
"Formula": "([PaymentItem1]) * 100",
"IsPaymentAmount": "false",
"Locked": "true",
"Name": "paymentsFormulaTab",
"PaymentDetails": {
"currencyCode": "USD",
"gatewayAccountId": "a7dcd60d-d963-4a81-bc72-68b71aad2062",
"lineItems": [{
"amountReference": "PaymentItem1",
"description": "951900;Tims 6.2;4444;1002",
"itemCode": "base",
"name": "salesDeposit"
}
]
},
"Required": "true",
"RoundDecimalPlaces": "2"
}
],
"numberTabs": [{
"FontColor": "DarkRed",
"IsPaymentAmount": "true",
"Locked": "true",
"TabLabel": "PaymentItem1",
"Value": "2500.00"
}
]
If you see above JSON structure, it has two tabs, formula and Number Tab and formula Tab uses the Number Tab reference. In this case, it refers to PaymentItem1. Hope above JSON will resolve your issue.
Thanks to Amit K Bist this worked to update a payment item tab after it's dropped into a template.
When creating a Template, add your Payment Item, select "Signer Entered" option under Payment Amount and put a value of 0.
Then capture the data label from the Payment Item. It should look similar to this: PaymentCustom 5e7e552c-2d0e-4364-b4d2-bb1784330191
Then add this to your request body:
"<envelopeDefinition xmlns=\"http://www.docusign.com/restapi\">" +
"<status>sent</status>" +
"<emailSubject>Turner Pest Control - Termite Bond Quote</emailSubject>" +
"<templateId>" + templateId + "</templateId>" +
"<templateRoles>" +
"<templateRole>" +
"<name>" + custName + "</name>" +
"<email>" + custEmail + "</email>" +
"<roleName>Customer</roleName>" +
"<tabs>" +
"<numberTabs>" +
"<number>" +
"<fontColor>DarkRed</fontColor>" +
"<locked>true</locked>" +
"<tabLabel>PaymentCustom 5e7e552c-2d0e-4364-b4d2-bb1784330191</tabLabel>" +
"<value>" + txtPayment + "</value>" +
"</number>" +
"</numberTabs>" +
"</tabs>" +
"</templateRole>" +
"</templateRoles>" +
"</envelopeDefinition>";
How a Payment Item gets turned into a number tab is beyond me, but, it works!
I'm still working on updating the payment details via API. Getting a Card declined error so I can't confirm if the payment details are getting updated.
Related
I am trying to make payments through Telegram bots by contacting directly on Telegram. But when I get the "pre_checkout_query" and I answer it (I think correctly), but it gives me error. I leave here the code because I do not know what is wrong.
I have two parts, the first one where I deny the payment simply to be able to test easier if I answer correctly or not and the second one the code that I would use to answer correctly and accept the payment.
I am developing it in Apps Script.
Thanks!
if (contenido.pre_checkout_query != null) {
tg.enviarMensaje(telegramUrl, idAdri, "dentroif", "HTML")
var idoperacion = contenido.pre_checkout_query.id
UrlFetchApp.fetch(telegramUrl + '/answerShippingQuery?shipping_query_id =' + idoperacion + '&ok=False' + "&error_message=Test")
/*var precios = [
{
"label": "Listado Usuarios Karma",
"amount": "145"
},
{
"label": "Listado Usuarios Karma",
"amount": "150"
}
]
var opcionesprecio = [
{
"id": idoperacion,
"title": "Titulo",
"prices": encodeURIComponent(JSON.stringify(precios))
},
]
UrlFetchApp.fetch(telegramUrl + '/answerPreCheckoutQuery?shipping_query_id=' + idoperacion + '&ok=True' + "ShippingOption=" + encodeURIComponent(JSON.stringify(opcionesprecio)))
*/
}
A possible solution to the problem
Im have used Django-PayPal for one time payment and its work good. Now i want to convert it into Subscription that will automatically resubscribe the package on same day of next month or next year.
This is the code of one time payment which is working fine:
paypal_dict = {
'business': mailpaypal,
'amount': request.POST.get('amount'),
'item_name': 'Order {}'.format(pack.packagename),
'invoice': 'Package'+str(request.POST.get("package_id"))+str(genralsetting_views.systemtimezone(request)),
'custom': str(transactionid)+"_Package_"+str(request.POST.get("package_id"))+'_'+str(genralsetting_views.systemtimezone(request))+'_'+str(endtime)+ '_' + str(viddd)+'_'+str(request.session['id'])+'_'+str(request.session['currency']),
'currency_code': GeneralSetting.objects.get(userid__usertype="superadmin").currency,
"notify_url": request.build_absolute_uri('/') + 'SubscriptionPaypalIPN',
"return": request.build_absolute_uri('/') + 'index',
"cancel_return": request.build_absolute_uri('/') + 'RegistrationPackages',
}
form = PayPalPaymentsForm(initial=paypal_dict)
return render(request, 'Vendor/Packages/RegistrationPackages/paypalpayment.html', {'cur':GeneralSetting.objects.get(userid__usertype="superadmin").currency,"session": request.session, 'form': form,"Data":data})
In the Django-Paypal documentation they showed the way to do subscription,as shown below:
paypal_dict = {
"cmd": "_xclick-subscriptions",
"business": 'receiver_email#example.com',
"a3": "9.99", # monthly price
"p3": 1, # duration of each unit (depends on unit)
"t3": "M", # duration unit ("M for Month")
"src": "1", # make payments recur
"sra": "1", # reattempt payment on payment error
"no_note": "1", # remove extra notes (optional)
"item_name": "my cool subscription",
"notify_url": "http://www.example.com/your-ipn-location/",
"return": "http://www.example.com/your-return-location/",
"cancel_return": "http://www.example.com/your-cancel-location/",
}
# Create the instance.
form = PayPalPaymentsForm(initial=paypal_dict, button_type="subscribe")
# Output the button.
form.render()
I have write the code same as they said in documentation
paypal_dict = {
"cmd": "_xclick-subscriptions",
"business": mailpaypal,
"a3": "9.99", # monthly price
"p3": 1, # duration of each unit (depends on unit)
"t3": "M", # duration unit ("M for Month")
"src": "1", # make payments recur
"sra": "1", # reattempt payment on payment error
"no_note": "1", # remove extra notes (optional)
"item_name": "my cool subscription",
"notify_url": request.build_absolute_uri('/') + 'SubscriptionPaypalIPN',
"return": request.build_absolute_uri('/') + 'index',
"cancel_return": request.build_absolute_uri('/') + 'RegistrationPackages',
}
form = PayPalPaymentsForm(initial=paypal_dict, button_type="subscribe")
return render(request, 'Vendor/Packages/RegistrationPackages/paypalpayment.html', {'cur':GeneralSetting.objects.get(userid__usertype="superadmin").currency,"session": request.session, 'form': form,"Data":data})
But when i click on subscribe button ,paypal says "Things don't appear to be working at the moment. Please try again later."
when i click on subscribe button it redirects to this link "https://www.sandbox.paypal.com/cgi-bin/webscr" , while when doing one time payment it redirects to this link "https://www.sandbox.paypal.com/webapps/hermes?token=8F359638A8728725A&useraction=commit&mfid=159438098_a982*3bb48 "
Can anyone tell me the solution to how to do the subscription with paypal-django?
This error happens for a number of different reasons.
1- Are you using a sandbox to test ? if yes, did you use the appropriate email ids in the python dict as well as during login ? You need to use a sandbox business account in python dict and personal sandbox account email to login during making the test payment.
2- Did your sandbox accounts you setup have the correct currency configuration ?
With docusign is there a way to send custom data to the document.
The use-case we have is that we are having customers sign an embedded form. We populate all of their data from our Database.
So the main contract is the same but we need to send some values such as contract number, name, address, and price to the document we are having signed. What would be the best way to accomplish this?
I have seen customer tags mentioned for this purpose but it seems like we can only do this in classic view which makes it seem like this will not be a supported feature in the new version.
Update:
I am still at a stand still on this issue.
I have tried doing what was suggested and setting textCustomFields
However, no matter what I pass in the label I set up does not show up.
For example.
I have the Name field on my Document and I also have a Text Field with the Data Label of: contractid
Then I try passing the data in in my envelope as described in the documentation (I have yet to find an example of this anywhere)
string requestBody =
"<envelopeDefinition xmlns=\"http://www.docusign.com/restapi\">" +
"<status>sent</status>" +
"<emailSubject>DocuSign API - Embedded Signing example</emailSubject>" +
"<templateId>" + templateId + "</templateId>" +
"<templateRoles>" +
"<templateRole>" +
"<email>" + recipientEmail + "</email>" +
"<name>" + recipientName + "</name>" +
"<roleName>" + templateRole + "</roleName>" +
"<clientUserId>1</clientUserId>" + // user-configurable
"</templateRole>" +
"</templateRoles>" +
"<customFields>" +
"<textCustomFields>" +
"<fieldId>contractid</fieldId>" +
"<name>contractid</name>" +
"<required>true</required>" +
"<show>true</show>" +
"<value>123</value>" +
"</textCustomFields>" +
"</customFields>" +
"</envelopeDefinition>";
The name field shows up correctly in the contract, but that is a custom field predefined by Docusign
However, the contractid field just shows blank as no data has been passed into it.
I even tried adding the information into the call to my view for when I show the embeded contract and that does not do anything either.
I may be going about this the wrong way but so far I can find no good documentation on how to send custom data into the contract via the REST API.
Edit:
Here is a Screen Shot of my setup and I have attempted to add the Text Tabs into both the envelope and the document view request.
I have to say I have worked with Multiple Rest API's including working with Twilio, Phaxio, Twitter and this Rest API implementation seems to be the most confusing I have every ran across as far as what does what
We are working through our DocuSign implementation and are able to do what you are looking for with textTabs added to the signers object. I've attached my POC code in PowerShell that shows the tabs being formatted.
We generate contracts in Word 2013 and use anchors to place everything. The source document will have something like //SIGNATURE// in the text, but before release it is highlighted and changed to white font so the final contract renders nicely in DocuSign.
Results in this (except I chopped out the name and title)
Put your API Key and credentials into the logon function and set up the recipient info at the top. The script creates and sends an envelope with document called "contract.docx"
[string]$recipientEmail = "mr.mann#bluesbrothers.com"
[string]$recipientName = "Mr. Mann"
[string]$recipientFirstName = "Mann"
[string]$recipientTitle = "CEO, Mann, Inc."
function boundry {
[System.Guid]::NewGuid().ToString()
}
function encodeFile {
param ([string]$fileName)
[System.Convert]::ToBase64String([IO.File]::ReadAllBytes((Resolve-Path $fileName).ProviderPath))
}
function logonParams {
[string] $userName = 'YOUR USER NAME'
[string] $password = 'YOUR PASSWORD'
[string] $integratorKey = 'YOUR INTEGRATOR KEY'
#"
{
"Username" : "$userName",
"Password" : "$password",
"IntegratorKey" : "$integratorKey"
}
"#
}
function logon {
[string] $loginURL = 'https://demo.docusign.net/restapi/v2/login_information'
$headers =
#{
"X-DocuSign-Authentication"=$(logonParams);
"accept"="application/json";
"content-type"="application/json";
}
$r = Invoke-WebRequest -uri $loginURL -headers $headers -method GET
$responseInfo = $r.content | ConvertFrom-Json
$baseURL = $responseInfo.loginAccounts.baseURL
$baseURL
}
function createEnvelope {
param ([string]$contractFile,
[string]$baseURL
)
[string]$boundry = boundry
$headers =
#{
"X-DocuSign-Authentication"=$(logonParams);
"accept"="application/json";
"content-type"="multipart/form-data; boundary=$boundry";
}
[string]$formData = #"
--$boundry
Content-Type: application/json
{
"status":"sent",
"emailBlurb":"$recipientFirstName, Here is a test contract that I uploaded to DocuSign and routed through their webservice API.",
"emailSubject": "Test Contract $(date)",
"authoritativeCopy" : "true",
"documents": [
{
"name": "$contractFile",
"documentId":"1",
"order":"1"
}
],
"recipients": {
"signers" : [{
"email" : "$recipientEmail",
"name" : "$recipientName",
"title" : "$recipientTitle",
"recipientId":"1",
"tabs" : {
"signHereTabs" : [{
"anchorString" : "//SIGNATURE//"
}],
"fullNameTabs" : [{
"anchorString" : "//SIGNATURE_NAME//",
"font" : "Calibri",
"fontSize" : "Size11",
"anchorYOffset" : -10
}],
"titleTabs" : [{
"anchorString" : "//SIGNATURE_TITLE//",
"font" : "Calibri",
"fontSize" : "Size11",
"anchorYOffset" : -10
}],
"dateTabs" : [{
"anchorString" : "//SIGNATURE_DATE//",
"font" : "Calibri",
"fontSize" : "Size11",
"anchorYOffset" : -10
}],
"textTabs" : [
{
"anchorString" : "//INVOICE_NAME//",
"font" : "Calibri",
"fontSize" : "Size11",
"anchorYOffset" : -10,
"value" : "My Invoice Name",
},
{
"anchorString" : "//INVOICE_ADDRESS1//",
"font" : "Calibri",
"fontSize" : "Size11",
"anchorYOffset" : -10,
"value" : "My Invoice Address 1",
},
{
"anchorString" : "//INVOICE_ADDRESS2//",
"font" : "Calibri",
"fontSize" : "Size11",
"anchorYOffset" : -10,
"value" : "My Invoice Address 2",
},
{
"anchorString" : "//INVOICE_ADDRESS3//",
"font" : "Calibri",
"fontSize" : "Size11",
"anchorYOffset" : -10,
"value" : "My Invoice Address 3",
},
{
"anchorString" : "//INVOICE_EMAIL//",
"font" : "Calibri",
"fontSize" : "Size11",
"anchorYOffset" : -10,
"value" : "somebody#somewhere.com"
}
],
}
}]
}
}
--$boundry
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
Content-Transfer-Encoding: base64
Content-Disposition: file; filename="$mainFile";documentid=1
$(encodeFile $contractFile)
--$boundry--
"#
$envelopeURL = "$baseURL/envelopes"
Invoke-WebRequest -uri $envelopeURL -headers $headers -body $formData -method POST
}
$baseURL = logon
createEnvelope "contract.docx" $baseURL
For those using XML and trying to auto fill in the data
string requestBody =
"<envelopeDefinition xmlns=\"http://www.docusign.com/restapi\">" +
"<status>sent</status>" +
"<emailSubject>DocuSign API - Embedded Signing example</emailSubject>" +
"<templateId>" + templateId + "</templateId>" +
"<templateRoles>" +
"<templateRole>" +
"<email>" + recipientEmail + "</email>" +
"<name>" + recipientName + "</name>" +
"<roleName>" + templateRole + "</roleName>" +
"<clientUserId>1</clientUserId>" + // user-configurable
"<tabs>" +
"<textTabs>" +
"<text>" +
"<anchorString>follows:</anchorString>" +
"<value>Initial Data Goes</value>" +
"</text>" +
"</textTabs>" +
"</tabs>" +
"</templateRole>" +
"</templateRoles>" +
"</envelopeDefinition>";
Then anywhere in your document you have the words follows: you will have the text show up and you can modify it to display it where you want using other fields.
This would be done through the DocuSign API. You can build a template based on that contract and add the fields that needs data in them. Then when creating the envelope you can set the data that is populated within those fields.
More info can be found here.
EDIT:
Sample code can be found here
Custom Fields refer to Envelope Custom Fields which are an element that can be used to record information about the envelope, help search for envelopes and track information, not for tabs.
You'll want textTab:
<textTabs>
<text>
<anchorIgnoreIfNotPresent>sample string 35</anchorIgnoreIfNotPresent>
<anchorString>sample string 31</anchorString>
<anchorUnits>sample string 34</anchorUnits>
<anchorXOffset>sample string 32</anchorXOffset>
<anchorYOffset>sample string 33</anchorYOffset>
<conditionalParentLabel>sample string 39</conditionalParentLabel>
<conditionalParentValue>sample string 40</conditionalParentValue>
<documentId>sample string 26</documentId>
<pageNumber>sample string 28</pageNumber>
<recipientId>sample string 27</recipientId>
<tabId>sample string 36</tabId>
<templateLocked>sample string 37</templateLocked>
<templateRequired>sample string 38</templateRequired>
<xPosition>sample string 29</xPosition>
<yPosition>sample string 30</yPosition>
<bold>sample string 21</bold>
<font>sample string 20</font>
<fontColor>sample string 24</fontColor>
<fontSize>sample string 25</fontSize>
<italic>sample string 22</italic>
<tabLabel>sample string 19</tabLabel>
<underline>sample string 23</underline>
<concealValueOnDocument>sample string 16</concealValueOnDocument>
<disableAutoSize>sample string 17</disableAutoSize>
<locked>sample string 15</locked>
<maxLength>18</maxLength>
<name>sample string 10</name>
<originalValue>sample string 12</originalValue>
<required>sample string 14</required>
<value>sample string 11</value>
<width>13</width>
<requireAll>sample string 9</requireAll>
<requireInitialOnSharedChange>sample string 7</requireInitialOnSharedChange>
<senderRequired>sample string 8</senderRequired>
<shared>sample string 6</shared>
<validationMessage>sample string 5</validationMessage>
<validationPattern>sample string 4</validationPattern>
<formula>sample string 3</formula>
<height>1</height>
<isPaymentAmount>sample string 2</isPaymentAmount>
</text>
</textTabs>
I have the Embedded Signing API. The document shows up fine and the user is allowed to sign and finish. All that is working fine.
Now the business users have a requirement where they want to ensure that the user has to enter their name. Is that possible ?
I tried not sending in the '' attribute in the xml or sending in a blank value for
'<name>'
But they all come back with an error.
I have to send in a value for
'<name>'
in the request and that is the name that is shown up automatically in the signature field to be selected. Is it possible to ensure that the user has to enter name in the field and then accept that as a signature ?
Thanks
Update
I am using C# and I have this xml :
"<envelopeDefinition xmlns=\"http://www.docusign.com/restapi\">" +
"<status>sent</status>" +
"<emailSubject>DocuSign API - Embedded Signing example</emailSubject>" +
"<templateId>" + templateId + "</templateId>" +
"<templateRoles>" +
"<templateRole>" +
"<email>" + recipientEmail + "</email>" +
"<name>" + recipientName + "</name>" +
"<roleName>" + templateRole + "</roleName>" +
"<clientUserId>" + clientUserId + "</clientUserId>" +
"<tabs>" +
"<textTabs>" +
"<anchorString>Full Name</anchorString>" +
"<tabLabel>Full Name</tabLabel>" +
"<documentId>1</documentId>" +
"<pageNumber>1</pageNumber>" +
"<recipientId>1</recipientId>" +
"<xPosition>24</xPosition>" +
"<yPosition>153</yPosition>" +
"<value>" + "Enter Name here" +"<value>" +
"<required>true</required>" +
"</textTabs>" +
"</tabs>" +
"</templateRole>" +
"</templateRoles>" +
"</envelopeDefinition>";
And I get this error:
<errorCode>INVALID_REQUEST_BODY</errorCode>
<message>The request body is missing or improperly formatted. The XML request does not match the expected format. </message>
What exactly is your business use-case that requires users to type in their name? Are you trying to create some extra form of acknowledgement or agreement by having them write in their full name into a text field? If so why not just put a radio button into your envelopes which says something like "I agree to blah blah blah..." and let them choose Yes or No and go from there? You could even have a conditional field then pop up if they select the Yes button and have them fill in the field then, etc.
With all that said, if still want to set a required, editable data field for signers to type their name into you can do this through the API, you just need to fix the issues I listed in my above comment. Here's sample XML and JSON that you could use:
<textTabs>
<text>
<tabLabel>Full Name</tabLabel>
<locked>true</locked>
<required>true</required>
<documentId>1</documentId>
<pageNumber>1</pageNumber>
<recipientId>1</recipientId>
<xPosition>24</xPosition>
<yPosition>153</yPosition>
<value>Enter Name here</value>
</text>
</textTabs>
And here's the JSON version:
"textTabs": [
{
"tabLabel": "Full Name",
"locked": "false",
"required": "true",
"pageNumber": "1",
"documentId": "1",
"xPosition": "200",
"yPosition": "200",
"value": "Enter Name here"
},
I working on signup process that require new user to sign on documents. I am using DocuSign embed signing workflow for that
I have created template with pdf document in docusign admin panel and added 1 test route:
and in the backend I am performing following api calls:
STEP 1 - Login API Call (used to retrieve your baseUrl) - restapi/v2/login_information
STEP 2 - Create an Envelope from Template and Send - baseURL + "/envelopes"
STEP 3 - Launch the Embedded Signing view (aka recipient view) - baseURL + uri + "/views/recipient"
and as parameters for email, username if I am sending test#mail.com, test2 (like in route) then
when I go to the retrieved recipient view url I see that form already has the placeholder for Sign and Initials since I have added these tags for test2 user in admin panel and form looks like:
Which is GREAT!
But not if I will send test3 and test3#mail.com as username and email params in this case I see form like this:
Here user can place his sign and other elements where he wants(which is BAD)
I need that behavior for all usernames and emails of new users that will signup(like all user will see these tags to sign and initial) I can't add them into admin panel to route since I don't know emails of new users that will came to site.
Is there a way to accomplish that ?
RequestBody for STEP2 for #AndrewWilson's request
"<envelopeDefinition xmlns=\"http://www.docusign.com/restapi\">" +
"<status>sent</status>" +
"<emailSubject>DocuSign API - Embedded Signing example</emailSubject>" +
"<templateId>" + TEMPLATE_ID + "</templateId>" +
"<templateRoles>" +
"<templateRole>" +
"<email>" + recipientEmail + "</email>" +
"<name>" + recipientName + "</name>" +
"<roleName>test2</roleName>" +
"<clientUserId>1</clientUserId>"
"</templateRole>" +
"</templateRoles>" +
"</envelopeDefinition>";
recipientEmail, recipientName it will be dynamic, templateId constant for doc
Here is a sample call that would fill out your recipient information on a template that has roleName of Awesome Role, while email and name are both blank
{
"emailSubject": "Super Awesome DocuSign Integration",
"templateId": "{templateId}",
"status": "sent",
"templateRoles": [
{
"email": "person#email.com",
"name": "First Last",
"roleName": "Awesome Role",
"clientUserId": 123456
}
]
}
If you want to start adding additional tags dynamically, you'd want to start using compositeTemplates, these increase the difficulty of the call, but here is a sample call using the same template but adding a Signature tag for the recipient.
{
"emailSubject": "Super Awesome DocuSign Integration",
"status": "sent",
"templateId": "{templateId}",
"templateRoles": [
{
"email": "person#email.com",
"name": "First Last",
"roleName": "Awesome Role",
"clientUserId":123456
}
],
"compositeTemplates": [
{
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"email": "person#email.com",
"name": "First Last",
"clientUserId":123456,
"recipientId": "1",
"defaultRecipient": "true",
"tabs": {
"signHereTabs": [
{
"xPosition": "200",
"yPosition": "200",
"documentId": "1",
"pageNumber": "1"
}
]
}
}
]
}
}
]
}
]
}
More on Composite Templates in the DocuSign REST API Guide