title: Payment field not working
body: <p>I have used SOAP API to create Embedded signing. I am using template (CreateEnvelopeFromTemplates) to create envelope. I have added a payment field on template which works fine if I send envelope request from docusign website. I get a popup to enter payment information. BUT when I am sending the same template from API then Payment functionality is not working. Payment field is appearing as number. </p>
  
  <p><a href="https://i.stack.imgur.com/8QwFM.png" rel="nofollow noreferrer">screenshot</a></p>
  
  <p>Here is my code</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>public class DS_Recipe_Signer_View_Controller {
      // Embedded signing of an envelope
      // Copyright (c) 2016 DocuSign, Inc. 
      // LICENSE: The MIT License, see https://opensource.org/licenses/MIT
  
      // SETTINGS
  //    Private static string integration_key = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
  //    Private static string account_id =      'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'; 
      Private static string integration_key = 'XXXXXXXXXX-98333677e8bd';
      Private static string account_id =      'XXXXXXXXXXX-5f66c17b7f9f'; 
          // NOTE: You MUST use the long form of the account id. It's has 32 digits 
          // with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). 
          // This version of the account id is shown in the APIs and Connects section
          // of your DocuSign Administration tool
  
      Public string signer_email {get;set;}   // Required
      Public string signer_name {get;set;}    // Required 
      Public string email_message {get;set;}  // Required
      Public string signer_user_id {get;set;}    // Required for embedded signing
      Public string signer_return_url {get;set;} // Required. Where DS redirects to after the signing ceremony  
  
      Public string output {get;set;}
      Public string envelope_id {get;set;}
      Public string signer_view_url {get;set;} // Redirect to this url  
      Public string error_code {get;set;} // Null means no error
      Public string error_message {get;set;}
  
      // Using Legacy authentication via an SFDC Named Credential
      Private static string ds_server = 'callout:DocuSign_Legacy_Demo/api/3.0/dsapi.asmx'; 
      // If you choose to not use a named credential:
       //Private static string ds_server = 'https://requestb.in/119qunn1';
      //Private static string ds_server ='https://demo.docusign.net/api/3.0/dsapi.asmx';
      
      Private static string trace_value = 'SFDC_002_SOAP_embedded_signing'; // Used for tracing API calls
      Private static string trace_key = 'X-ray';
      Private DocuSignTK.APIServiceSoap api_sender = new DocuSignTK.APIServiceSoap();
  
      Public DS_Recipe_Signer_View_Controller(){}
      
      Public void send(){
          configure_sender();
          send_envelope();
          embedded_signing();
  
          if (no_error()) {
              output = '&lt;p&gt;The envelope was sent, Envelope ID: ' + envelope_id + '&lt;/p&gt;';
              output += '&lt;p&gt;&lt;/p&gt;&lt;p&gt;Signer: ' + signer_name + ' &amp;lt;' + signer_email + '&amp;gt;&lt;/p&gt;';
              output += '&lt;p&gt;&lt;b&gt;To sign the envelope, redirect the user to the &lt;a href = "' + 
                        signer_view_url + '" target="_blank"&gt;DocuSign Signing Ceremony&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;';
              output += '&lt;p&gt;The redirect address is ' + signer_view_url + '&lt;/p&gt;';
              output += '&lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; the Signing Ceremony url can only be used for a couple of minutes after ' +
                        'it has been created. Do NOT store the url for later use. Instead, ' +
                        'generate the URL immediately before you redirect the user\'s browser.&lt;/p&gt;';
              output += '&lt;p&gt;After the signer has completed the signing ceremony, his ' +
                        'browser will be redirected back to your app with some query fields added. Example: &lt;/p&gt;' +
                        '&lt;p&gt;http://www.foo.com/?event=signing_complete&lt;/p&gt;';
          } else {
              output = '&lt;h3&gt;Problem&lt;/h3&gt;&lt;p&gt;' + error_message + '&lt;/p&gt;';
          }
      }
  
      Private void configure_sender(){
          api_sender.endpoint_x = ds_server;
          api_sender.inputHttpHeaders_x = new Map&lt;String, String&gt;();
          String auth =   '&lt;DocuSignCredentials&gt;&lt;Username&gt;{!$Credential.Username}&lt;/Username&gt;' 
                        + '&lt;Password&gt;{!$Credential.Password}&lt;/Password&gt;' 
                        + '&lt;IntegratorKey&gt;' + integration_key + '&lt;/IntegratorKey&gt;&lt;/DocuSignCredentials&gt;';
  
          api_sender.inputHttpHeaders_x.put('X-DocuSign-Authentication', auth);
          api_sender.inputHttpHeaders_x.put(trace_key, trace_value);
      }
  
      Private void embedded_signing() {
          // Obtains the embedded Signing Ceremony URL for an envelope's recipient (the signer).
          // To use embedded signing:
          // 1. The signer must have been added to the envelope as a "captive signer"
          // 2. You need the following values:
          //    1. EnvelopeID
          //    2. Signer's Email that was provided when the signer was added to the envelope.
          //    3. Signer's name (UserName field)
          //    4. The Signer's User ID (client id) within your app. Must uniquely identify the signer. 
          // 3. You also need to create an "Assertion" object where you provide information on how
          //    your app authenticated the signer. This information is stored by DocuSign so you can
          //    later use the data in case of a dispute.
  
          // Incoming variables used:
          // envelope_id, signer_user_id, signer_email, signer_name
  
          // Maintaining state: when DocuSign redirects back to your app after the signing ceremony
          // ended, how does your app know what is going on? You can include additional query parameters
          // in the signer_return_url that you supply. Eg the recipient ID, envelope ID, etc.
          // You can include your app's sessionID. You can use the cookie system to store either
          // specific information or your stack's session id for your app.
  
          // Step 1. Create the assertion
          DocuSignTK.RequestRecipientTokenAuthenticationAssertion assertion = 
              new DocuSignTK.RequestRecipientTokenAuthenticationAssertion();
          assertion.AssertionID = '1'; // A unique identifier of the authentication 
              // event executed by your application.
          assertion.AuthenticationInstant = Datetime.now(); // The date/time that the end-user was authenticated.
          assertion.AuthenticationMethod = 'Password';      // How did your app authenticate the signer?
          // Options: Password, Email, PaperDocuments, HTTPBasicAuth, SSLMutualAuth, X509Certificate, Kerberos, 
          // SingleSignOn_CASiteminder, SingleSignOn_InfoCard, SingleSignOn_MicrosoftActiveDirectory, SingleSignOn_Passport, 
          // SingleSignOn_SAML, SingleSignOn_Other, Smartcard, RSASecureID, Biometric, None, KnowledgeBasedAuth
          assertion.SecurityDomain = 'DS_Recipe_Signer_View_Controller'; // The "domain" (app, sso system, etc) 
              // to which the user authenticated
  
          // Step 2. Create the redirect URLs for the different outcomes of the Signing Ceremony
          DocuSignTK.RequestRecipientTokenClientURLs urls = new DocuSignTK.RequestRecipientTokenClientURLs();
          String return_url_base = signer_return_url;
          // The supplied url may already include one or more query parameters. In that case, we're appending 
          // one more query parameters. Otherwiser, we're adding the first set of query parameters.
          // Look for a ? to see if the url already includes query parameters
          If (return_url_base.contains('?')) {
              return_url_base += '&amp;event=';
          } Else {
              return_url_base += '?event=';
          }
          urls.OnSigningComplete  = return_url_base + 'signing_complete';
          urls.OnViewingComplete  = return_url_base + 'viewing_complete';
          urls.OnCancel           = return_url_base + 'cancel';
          urls.OnDecline          = return_url_base + 'decline';
          urls.OnSessionTimeout   = return_url_base + 'session_timeout';
          urls.OnTTLExpired       = return_url_base + 'ttl_expired';
          urls.OnException        = return_url_base + 'exception';
          urls.OnAccessCodeFailed = return_url_base + 'failed_access_code';
          urls.OnIdCheckFailed    = return_url_base + 'failed_id_check';
          urls.OnFaxPending       = return_url_base + 'fax_pending';
  
          // Step 3. Make the call
          try {
              signer_view_url = api_sender.RequestRecipientToken(
                  envelope_id, signer_user_id, signer_name, signer_email, assertion, urls);
              System.debug('Received signer_view_url: = ' + signer_view_url);
          } catch ( CalloutException e) {
              System.debug('Exception - ' + e );
              error_code = 'Problem: ' + e;
              error_message = error_code;
          }      
      }
  
  
      Private void send_envelope() {
          // Sends an envelope. The first signer is "captive," so he can sign embedded
  
          // Check input
          if (String.isBlank(signer_email) || String.isBlank(signer_name) || !signer_email.contains('@')) {
              error_message = 'Please fill in the email and name fields';
              error_code = 'INPUT_PROBLEM';
              return;
          }
  
          // Check configuration
          if (integration_key == 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' ||
              account_id == 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx') { 
              error_message = 'Please configure the Apex class DS_Recipe_Send_Env_Email_Controller with your integration key and account id.';
              error_code = 'CONFIGURATION_PROBLEM';
              return;
          }
  
          DocuSignTK.Recipient recipient = new DocuSignTK.Recipient();
          recipient.Email = signer_email; 
              
          recipient.UserName = signer_name;
          recipient.ID = 1;
          recipient.Type_x = 'Signer';
          recipient.RoutingOrder = 1;
          recipient.RoleName = 'Signer'; 
          // We want this signer to be "captive" so we can use embedded signing with him
          recipient.CaptiveInfo = new DocuSignTK.RecipientCaptiveInfo();
          recipient.CaptiveInfo.ClientUserID = signer_user_id; // Must uniquely identify the 
  
          DocuSignTK.ArrayOfRecipient1 recipients = new DocuSignTK.ArrayOfRecipient1();
          recipients.Recipient = new DocuSignTK.Recipient[1];
          recipients.Recipient[0] = recipient;
           
          // Create the template reference from a server-side template ID
          DocuSignTK.TemplateReference templateReference = new DocuSignTK.TemplateReference();
          templateReference.Template =  '37041580-9d59-4b41-a7c4-7c9bfa3b26c8';//'d0d80082-612b-4a04-b2a1-0672eb720491'; 
          templateReference.TemplateLocation = 'Server';
          //templateReference.Sequence = 1; 
          
          DocuSignTK.ArrayOfTemplateReferenceRoleAssignment Roles = new DocuSignTK.ArrayOfTemplateReferenceRoleAssignment();
          Roles.RoleAssignment = new DocuSignTK.TemplateReferenceRoleAssignment[1];
          
          DocuSignTK.TemplateReferenceRoleAssignment role = new DocuSignTK.TemplateReferenceRoleAssignment();
          role.RoleName = 'Signer';
          role.RecipientID = 1;
          Roles.RoleAssignment[0] = role;
          templateReference.RoleAssignments = Roles; 
          
          // Construct the envelope information
          DocuSignTK.EnvelopeInformation envelopeInfo = new DocuSignTK.EnvelopeInformation();
          envelopeInfo.AccountId = account_Id;
          envelopeInfo.Subject = 'Subject';
          envelopeInfo.EmailBlurb = 'Email content';
  
  
          DocuSignTK.TemplateReferenceFieldDataDataValue fd2 = new
          DocuSignTK.TemplateReferenceFieldDataDataValue();
          fd2.TabLabel = 'name';
          fd2.Value = 'recipient.UserName';
          
          DocuSignTK.TemplateReferenceFieldDataDataValue fd3 = new
          DocuSignTK.TemplateReferenceFieldDataDataValue();
          fd3.TabLabel = 'company';
          fd3.Value = 'company';
  
  
          templateReference.FieldData = new DocuSignTK.TemplateReferenceFieldData();
          templateReference.FieldData.DataValues = new
          DocuSignTK.ArrayOfTemplateReferenceFieldDataDataValue();
          templateReference.FieldData.DataValues.DataValue = new
          DocuSignTK.TemplateReferenceFieldDataDataValue[2];
          templateReference.FieldData.DataValues.DataValue[0] = fd2;
          templateReference.FieldData.DataValues.DataValue[1] = fd3;
          
          // Make the call
          try {
              //DocuSignTK.EnvelopeStatus result = api_sender.CreateAndSendEnvelope(envelope);
              // Create draft with all the template information
              DocuSignTK.ArrayOfTemplateReference TemplateReferenceArray = new DocuSignTK.ArrayOfTemplateReference();
              TemplateReferenceArray.TemplateReference = new DocuSignTK.TemplateReference[1];
              TemplateReferenceArray.TemplateReference[0] = templateReference;
              DocuSignTK.EnvelopeStatus result = api_sender.CreateEnvelopeFromTemplates( TemplateReferenceArray, recipients, envelopeInfo, true);
              envelope_id = result.EnvelopeID;
              System.debug('Returned successfully, envelope_id = ' + envelope_id );
          } catch ( CalloutException e) {
              System.debug('Exception - ' + e );
              error_code = 'Problem: ' + e;
              error_message = error_code;
          }      
      }
  
      Private Boolean no_error() {
          return (String.isEmpty(error_code));
      }
  
  }</code></pre>
  </div>
  </div>
  </p>