Esempio n. 1
0
    def get(self, request, *args, **kwargs):
        api_client = get_api_client()
        bulk_envelopes_api = BulkEnvelopesApi(api_client)
        recipient_1 = BulkSendingCopyRecipient(role_name='signer', name='Aaqib 1', email='*****@*****.**')
        recipient_2 = BulkSendingCopyRecipient(role_name='signer', name='Aaqib 2', email='*****@*****.**')
        bulk_copies = [
            BulkSendingCopy(recipients=[recipient_1], custom_fields=[]),
            BulkSendingCopy(recipients=[recipient_2], custom_fields=[]),
        ]
        bulk_sending_list = BulkSendingList(name='employee_contract', bulk_copies=bulk_copies)
        bulk_list = bulk_envelopes_api.create_bulk_send_list(ACCOUNT_ID, bulk_sending_list=bulk_sending_list)
        bulk_list_id = bulk_list.list_id

        envelopes_api = EnvelopesApi(api_client)
        with open(f'{BASE_DIR}/document.pdf', 'rb') as pdf_file:
            content_bytes = pdf_file.read()
        base64_file_content = base64.b64encode(content_bytes).decode('ascii')
        document = Document(document_base64=base64_file_content, name='Employee Contract',
                            file_extension='pdf', document_id='1')
        envelope_definition = EnvelopeDefinition(email_subject='Please sign this document set', documents=[document],
                                                 recipients={}, status='created', envelope_id_stamping='true')
        envelope = envelopes_api.create_envelope(account_id=ACCOUNT_ID, envelope_definition=envelope_definition)
        envelope_id = envelope.envelope_id

        text_custom_fields = TextCustomField(name='mailingListId', required='false', show='false', value=bulk_list_id)
        custom_fields = CustomFields(list_custom_fields=[], text_custom_fields=[text_custom_fields])
        envelopes_api.create_custom_fields(account_id=ACCOUNT_ID, envelope_id=envelope_id, custom_fields=custom_fields)

        signer = Signer(name='Multi Bulk Recipient::signer', email='*****@*****.**',
                        role_name='signer', note='', routing_order='1', status='created', delivery_method='email',
                        recipient_id='13', recipient_type='signer')
        envelopes_api.create_recipient(ACCOUNT_ID, envelope_id, recipients=Recipients(signers=[signer]))
        bulk_send_request = BulkSendRequest(envelope_or_template_id=envelope_id)
        batch = bulk_envelopes_api.create_bulk_send_request(ACCOUNT_ID, bulk_list_id,
                                                            bulk_send_request=bulk_send_request)

        time.sleep(10)
        from_date = (datetime.utcnow() - timedelta(seconds=60)).isoformat()
        envelopes = envelopes_api.list_status_changes(ACCOUNT_ID, status='sent', from_date=from_date).envelopes
        for envelope in envelopes:
            env, created = SigEnvelope.objects.get_or_create(envelope_id=envelope.envelope_id)
            if created:
                sign_request = SignRequest.objects.create(envelope=env, status_date_time=envelope.status_date_time)
                recipients = envelopes_api.list_recipients(ACCOUNT_ID, envelope.envelope_id)
                Recipient.objects.create(sign_request=sign_request, email=recipients.signers[0].email,
                                         recipient_id=recipients.signers[0].recipient_id)
        return redirect('esign:envelope_list')
Esempio n. 2
0
def embedded_signing_ceremony():
    """
    The document <file_name> will be signed by <signer_name> via an
    embedded signing ceremony.
    """

    #
    # Step 1. The envelope definition is created.
    #         One signHere tab is added.
    #         The document path supplied is relative to the working directory
    #

    envDef = EnvelopeDefinition()
    envDef.email_subject = 'PLEASE GOD HELP ME, I NEED THIS WORKING!!'
    envDef.template_id = 'd5e617be-da0a-4431-9014-4575282f61d4'

    tRole = TemplateRole()
    tRole.role_name = 'Manager'
    tRole.name = 'Manuel Galvez'
    tRole.email = '*****@*****.**'
    tRole.client_user_id = clientUserId

    text_example = Text()
    text_example.tab_label = 'example'
    text_example.value = 'SIIII GRACIAS DIOS!! -- EXAMPLE'

    text_name = Text()
    text_name.tab_label = 'name'
    text_name.value = 'SIIII GRACIAS DIOS!! -- NAME'

    # text.document_id = '1'
    # text.page_number = '1'
    # text.recipient_id = '1'
    # text.x_position = '100'
    # text.y_position = '100'
    # text.scale_value = '0.5'

    tabs = Tabs()
    tabs.text_tabs = [text_example, text_name]

    tRole.tabs = tabs  # Tabs(text_tabs=[Text(name='example', value='SIiiiiiii Gracias DIOS')])

    envDef.template_roles = [tRole]

    name = TextCustomField(field_id='name', name='name', value='Manuel')
    last_name = TextCustomField(field_id='lastname',
                                name='lastname',
                                value='Galvez')
    testing = TextCustomField(field_id='testing', name='testing', value='Elks')
    manu = TextCustomField(field_id='manu', name='manu', value='manu')
    example = TextCustomField(field_id='example',
                              name='example',
                              value='Siiiiiiii')

    custom_fields = CustomFields(
        text_custom_fields=[example, name, last_name, testing, manu])

    envDef.custom_fields = custom_fields
    '''recipients = Recipients()

    # Create the signer recipient model
    signer = Signer(  # The signer
        email='*****@*****.**', name='Andres Vasquez', recipient_id="1", routing_order="1",
        client_user_id=clientUserId,  # Setting the client_user_id marks the signer as embedded
    )

    text = Text()
    text.document_id = '1'
    text.page_number = '1'
    text.recipient_id = '1'
    text.x_position = '100'
    text.y_position = '100'
    text.scale_value = '0.5'

    tabs = Tabs()
    tabs.text_tabs = [text]

    signer.tabs = tabs

    recipients.signers = [signer]
    envDef.recipients = recipients'''

    envDef.status = 'sent'

    api_client = ApiClient()
    api_client.host = base_path
    api_client.set_default_header("Authorization", "Bearer " + access_token)

    envelope_api = EnvelopesApi(api_client)
    envelopeSummary = envelope_api.create_envelope(account_id,
                                                   envelope_definition=envDef)
    envelope_id = envelopeSummary.envelope_id

    print("Envelope {} has been sent to {} : {}".format(
        envelope_id, tRole.email, envelopeSummary))
    '''recipient_view_request = RecipientViewRequest(
        authentication_method='None', client_user_id=clientUserId,
        recipient_id='1', return_url=base_url + '/dsreturn',
        user_name='Andres Vasquez', email='*****@*****.**'
    )

    results = envelope_api.create_recipient_view(account_id, envelope_id, recipient_view_request=recipient_view_request)'''

    return ''  #results.url
    def make_envelope(cls, args):
        """
        Creates envelope
        args -- parameters for the envelope:
        signer_email, signer_name, signer_client_id
        returns an envelope definition
        """

        # Set the values for the fields in the template
        # List item
        list1 = List(value="green",
                     document_id="1",
                     page_number="1",
                     tab_label="list")

        # Checkboxes
        check1 = Checkbox(tab_label="ckAuthorization", selected="true")

        check3 = Checkbox(tab_label="ckAgreement", selected="true")

        radio_group = RadioGroup(
            group_name="radio1",
            radios=[Radio(value="white", selected="true")])

        text = Text(tab_label="text", value="Jabberywocky!")

        # We can also add a new tab (field) to the ones already in the template:
        text_extra = Text(document_id="1",
                          page_number="1",
                          x_position="280",
                          y_position="172",
                          font="helvetica",
                          font_size="size14",
                          tab_label="added text field",
                          height="23",
                          width="84",
                          required="false",
                          bold="true",
                          value=args["signer_name"],
                          locked="false",
                          tab_id="name")

        # Add the tabs model (including the SignHere tab) to the signer.
        # The Tabs object wants arrays of the different field/tab types
        # Tabs are set per recipient / signer
        tabs = Tabs(checkbox_tabs=[check1, check3],
                    radio_group_tabs=[radio_group],
                    text_tabs=[text, text_extra],
                    list_tabs=[list1])

        # create a signer recipient to sign the document, identified by name and email
        # We"re setting the parameters via the object creation
        signer = TemplateRole(  # The signer
            email=args["signer_email"],
            name=args["signer_name"],
            # Setting the client_user_id marks the signer as embedded
            client_user_id=args["signer_client_id"],
            role_name="signer",
            tabs=tabs)

        cc = TemplateRole(email=args["cc_email"],
                          name=args["cc_name"],
                          role_name="cc")

        # create an envelope custom field to save our application"s
        # data about the envelope

        custom_field = TextCustomField(
            name="app metadata item",
            required="false",
            show="true",  # Yes, include in the CoC
            value="1234567")

        cf = CustomFields(text_custom_fields=[custom_field])

        # Next, create the top level envelope definition and populate it.
        envelope_definition = EnvelopeDefinition(
            email_subject="Please sign this document sent from the Python SDK",
            # The Recipients object wants arrays for each recipient type
            template_id=session["template_id"],
            template_roles=[signer, cc],
            custom_fields=cf,
            status="sent"  # requests that the envelope be created and sent.
        )

        return envelope_definition
Esempio n. 4
0
def embedded_signing_ceremony():
    """
    The document <file_name> will be signed by <signer_name> via an
    embedded signing ceremony.
    """

    #
    # Step 1. The envelope definition is created.
    #         One signHere tab is added.
    #         The document path supplied is relative to the working directory
    #
    '''with open(os.path.join(APP_PATH, file_name_path), "rb") as file:
        content_bytes = file.read()'''
    base64_file_content = ''  #base64.b64encode(content_bytes).decode('ascii')

    # Create the document model
    '''document = Document( # create the DocuSign document object 
        document_base64 = base64_file_content, 
        name = 'Example document', # can be different from actual file name
        file_extension = 'pdf', # many different document types are accepted
        document_id = 1 # a label used to reference the doc
    )'''
    '''text_field = docusign.Text(
        tab_label='name',  # tab_label must exactly match the field you created in the Docusign GUI
        value='Manuel'  # value, as far as I can tell, must be a string.
    )

    docusign.Tabs(text_tabs=[text_field])'''

    patient_first_name = TextCustomField(name='name',
                                         value='Allen',
                                         show='true',
                                         required='false')
    patient_last_name = TextCustomField(name='lastname',
                                        value='Elks',
                                        show='true',
                                        required='false')
    custom_fields = CustomFields(
        text_custom_fields=[patient_first_name, patient_last_name])

    # envelope_definition.custom_fields = custom_fields

    # Custome fields
    custom_fields_old = CustomFields(['name'], ['Manuel'])

    # Create the signer recipient model
    signer = Signer(  # The signer
        email=signer_email,
        name=signer_name,
        recipient_id="1",
        routing_order="1",
        client_user_id=
        client_user_id,  # Setting the client_user_id marks the signer as embedded
    )

    # Create a sign_here tab (field on the document)
    sign_here = SignHere(  # DocuSign SignHere field/tab
        document_id='1',
        page_number='3',
        recipient_id='1',
        tab_label='SignHereTab',
        x_position='175',
        y_position='320')

    # Add the tabs model (including the sign_here tab) to the signer
    signer.tabs = Tabs(sign_here_tabs=[
        sign_here
    ])  # The Tabs object wants arrays of the different field/tab types

    # Next, create the top level envelope definition and populate it.
    '''envelope_definition = EnvelopeDefinition(
        email_subject = "Please sign this document sent from the Python SDK",
        documents = [document], # The order in the docs array determines the order in the envelope
        recipients = Recipients(signers = [signer]), # The Recipients object wants arrays for each recipient type
        status = "sent", # requests that the envelope be created and sent.
        custom_fields = custom_fields
    )'''

    envDef = EnvelopeDefinition()
    envDef.email_subject = 'PLEASE GOD HELP ME, I NEED THIS WORKING!!'
    envDef.template_id = 'd5e617be-da0a-4431-9014-4575282f61d4'

    tRole = TemplateRole()
    tRole.role_name = 'Manager'
    tRole.name = 'Manuel Alejandro Galvez'
    tRole.email = '*****@*****.**'

    envDef.template_roles = [tRole]
    envDef.status = 'sent'
    envDef.custom_fields = custom_fields

    #
    #  Step 2. Create/send the envelope.
    #
    api_client = ApiClient()
    api_client.host = base_path
    api_client.set_default_header("Authorization", "Bearer " + access_token)

    envelope_api = EnvelopesApi(api_client)
    results = envelope_api.create_envelope(account_id,
                                           envelope_definition=envDef)

    #
    # Step 3. The envelope has been created.
    #         Request a Recipient View URL (the Signing Ceremony URL)
    #
    envelope_id = results.envelope_id
    recipient_view_request = RecipientViewRequest(
        authentication_method=authentication_method,
        client_user_id=client_user_id,
        recipient_id='1',
        return_url=base_url + '/dsreturn',
        user_name=signer_name,
        email=signer_email)

    results = envelope_api.create_recipient_view(account_id, envelope_id)
    #recipient_view_request = recipient_view_request)

    #
    # Step 4. The Recipient View URL (the Signing Ceremony URL) has been received.
    #         Redirect the user's browser to it.
    #
    return results.url
Esempio n. 5
0
    def make_envelope(cls, args):
        """
        Creates envelope
        args -- parameters for the envelope:
        signer_email, signer_name, signer_client_id
        returns an envelope definition
        """

        # Document 1 (PDF) has tag /sn1/
        #
        # The envelope has one recipient:
        # recipient 1 - signer
        with open(path.join(demo_docs_path, DS_CONFIG["doc_salary_docx"]), "rb") as file:
            content_bytes = file.read()
        base64_file_content = base64.b64encode(content_bytes).decode("ascii")

        # Create the document model
        document = Document(  # Create the DocuSign document object
            document_base64=base64_file_content,
            name="Lorem Ipsum",  # Can be different from the actual filename
            file_extension="docx",  # Many different document types are accepted
            document_id=1  # A label used to reference the doc
        )

        # Create the signer recipient model
        signer = 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"]
        )

        # Create a SignHere tab (field on the document)
        sign_here = SignHere(  # DocuSign SignHere field/tab
            anchor_string="/sn1/", anchor_units="pixels",
            anchor_y_offset="10", anchor_x_offset="20"
        )

        text_legal = Text(
            anchor_string="/legal/", anchor_units="pixels",
            anchor_y_offset="-9", anchor_x_offset="5",
            font="helvetica", font_size="size11",
            bold="true", value=args["signer_name"],
            locked="false", tab_id="legal_name",
            tab_label="Legal name")

        text_familar = Text(
            anchor_string="/familiar/", anchor_units="pixels",
            anchor_y_offset="-9", anchor_x_offset="5",
            font="helvetica", font_size="size11",
            bold="true", value=args["signer_name"],
            locked="false", tab_id="familar_name",
            tab_label="Familiar name")

        salary = 123000

        text_salary = Text(
            anchor_string="/salary/",
            anchor_units="pixels",
            anchor_y_offset="-9",
            anchor_x_offset="5",
            font="helvetica",
            font_size="size11",
            bold="true",
            value="${:.2f}".format(salary),
            locked="true",
            tab_id="salary",
            tab_label="Salary")

        salary_custom_field = TextCustomField(
            name="salary",
            required="false",
            show="true",  # Yes, include in the CoC
            value=str(salary)
        )
        cf = CustomFields(text_custom_fields=[salary_custom_field])
        # Add the tabs model (including the SignHere tab) to the signer
        # The Tabs object wants arrays of the different field/tab types
        signer.tabs = Tabs(sign_here_tabs=[sign_here], text_tabs=[text_legal, text_familar, text_salary])

        # Create the top level envelope definition and populate it
        envelope_definition = EnvelopeDefinition(
            email_subject="Please sign this document sent from the Python SDK",
            documents=[document],
            # The Recipients object wants arrays for each recipient type
            recipients=Recipients(signers=[signer]),
            custom_fields=cf,
            status="sent"  # Requests that the envelope be created and sent
        )

        return envelope_definition
Esempio n. 6
0
    def worker(cls, args):
        """
        1. Create an api client and construct API clients
        2. Create and submit a bulk sending list
        3. Create a draft envelope
        4. Add custom fields to the envelope
        5. Add recipients to the envelope
        6. Initiate bulk envelope sending
        7. Confirm sending success
        """

        # Step 2. Construct your API headers
        api_client = create_api_client(base_path=args["base_path"],
                                       access_token=args["access_token"])

        # Step 3. Submit a bulk list
        bulk_envelopes_api = BulkEnvelopesApi(api_client)
        bulk_sending_list = cls.create_bulk_sending_list(args["signers"])
        bulk_list = bulk_envelopes_api.create_bulk_send_list(
            account_id=args["account_id"], bulk_sending_list=bulk_sending_list)
        bulk_list_id = bulk_list.list_id

        # Step 4. Create an envelope
        envelope_api = EnvelopesApi(api_client)
        envelope_definition = cls.make_draft_envelope()
        envelope = envelope_api.create_envelope(
            account_id=args["account_id"],
            envelope_definition=envelope_definition)
        envelope_id = envelope.envelope_id

        # Step 5. Attach your bulk list id to the envelope
        text_custom_fields = TextCustomField(name="mailingListId",
                                             required="false",
                                             show="false",
                                             value=bulk_list_id)
        custom_fields = CustomFields(list_custom_fields=[],
                                     text_custom_fields=[text_custom_fields])
        envelope_api.create_custom_fields(account_id=args["account_id"],
                                          envelope_id=envelope_id,
                                          custom_fields=custom_fields)

        # Step 6. Add placeholder recipients
        cc = Signer(name="Multi Bulk Recipient::cc",
                    email="*****@*****.**",
                    role_name="cc",
                    note="",
                    routing_order="1",
                    status="created",
                    delivery_method="email",
                    recipient_id="12",
                    recipient_type="signer")

        signer = Signer(name="Multi Bulk Recipient::signer",
                        email="*****@*****.**",
                        role_name="signer",
                        note="",
                        routing_order="1",
                        status="created",
                        delivery_method="email",
                        recipient_id="13",
                        recipient_type="signer")

        envelope_api.create_recipient(
            account_id=args["account_id"],
            envelope_id=envelope_id,
            recipients=Recipients(signers=[signer, cc]))

        # Step 7. Initiate bulk send
        bulk_send_request = BulkSendRequest(
            envelope_or_template_id=envelope_id)
        batch = bulk_envelopes_api.create_bulk_send_request(
            account_id=args["account_id"],
            bulk_send_list_id=bulk_list_id,
            bulk_send_request=bulk_send_request)
        batch_id = batch.batch_id

        # Step 8. Confirm successful batch send
        response = bulk_envelopes_api.get(account_id=args["account_id"],
                                          batch_id=batch_id)

        return response
def embedded_signing_ceremony():
    """
    The document <file_name> will be signed by <signer_name> via an
    embedded signing ceremony.
    """

    #
    # Step 1. The envelope definition is created.
    #         One signHere tab is added.
    #         The document path supplied is relative to the working directory
    #

    envDef = EnvelopeDefinition()
    envDef.email_subject = 'PLEASE GOD HELP ME, I NEED THIS WORKING!!'
    envDef.template_id = 'd5e617be-da0a-4431-9014-4575282f61d4'

    tRole = TemplateRole()
    tRole.role_name = 'Manager'
    tRole.name = 'Lending Front'
    tRole.email = '*****@*****.**'
    tRole.client_user_id = client_user_id

    text_example = Text()
    text_example.tab_label = 'example'
    text_example.value = 'SIIII GRACIAS DIOS!! -- EXAMPLE'

    text_name = Text()
    text_name.tab_label = 'name'
    text_name.value = 'SIIII GRACIAS DIOS!! -- NAME'

    text_name2 = Text()
    text_name2.tab_label = 'name2'
    text_name2.value = 'SIIII GRACIAS DIOS!! -- NAME2'

    text = Text()
    text.document_id = '1'
    text.page_number = '1'
    text.recipient_id = '1'
    text.x_position = '100'
    text.y_position = '100'
    text.scale_value = '0.5'
    text.value = 'THANKS GOD!!'

    title_label = Title()
    title_label.tab_label = 'lablel_example'
    title_label.value = 'LendingFront'

    tabs = Tabs()
    tabs.text_tabs = [text_example, text_name, text_name2, text]
    tabs.title_tabs = [title_label]
    tRole.tabs = tabs

    envDef.template_roles = [tRole]
    envDef.status = 'sent'

    name = TextCustomField(field_id='name', name='name', value='Manuel')
    last_name = TextCustomField(field_id='lastname',
                                name='lastname',
                                value='Galvez')
    testing = TextCustomField(field_id='testing', name='testing', value='Elks')
    manu = TextCustomField(field_id='manu', name='manu', value='manu')
    example = TextCustomField(field_id='example',
                              name='example',
                              value='Siiiiiiii')
    '''item_name = ListItem(text='name', value='Allen')
    item_lastname = ListItem(text='lastname', value='Galvez')
    item_testing = ListItem(text='testing', value='testing')
    item_manu = ListItem(text='manu', value='manu')

    listcf = ListCustomField(list_items=[item_name, item_lastname, item_testing, item_manu])'''

    custom_fields = CustomFields(
        text_custom_fields=[example, name, last_name, testing, manu])

    envDef.custom_fields = custom_fields
    # envDef.recipients

    #
    print('*&**&*^&*&^%$#$%^&*(*&^%$#@!@#$%^&')
    print('')

    #
    #  Step 2. Create/send the envelope.
    #
    api_client = ApiClient()
    api_client.host = base_path
    api_client.set_default_header("Authorization", "Bearer " + access_token)

    envelope_api = EnvelopesApi(api_client)
    envelopeSummary = envelope_api.create_envelope(account_id,
                                                   envelope_definition=envDef)
    envelope_id = envelopeSummary.envelope_id

    print("Envelope {} has been sent to {}".format(envelope_id, tRole.email))
    '''client_user_id = '2939'


    return_url = 'http://www.docusign.com/developer-center'
    recipient_view_request = docusign.RecipientViewRequest()
    recipient_view_request.return_url = return_url
    recipient_view_request.client_user_id = client_user_id
    recipient_view_request.authentication_method = 'email'
    recipient_view_request.user_name = 'Manuel Galvez'
    recipient_view_request.email = '*****@*****.**'

    view_url = envelope_api.create_recipient_view(account_id, envelope_id, recipient_view_request=recipient_view_request) '''

    recipient_view_request = RecipientViewRequest(
        authentication_method='None',
        client_user_id=client_user_id,
        recipient_id='1',
        return_url=base_url + '/dsreturn',
        user_name='Lending Front',
        email='*****@*****.**')

    results = envelope_api.create_recipient_view(
        account_id, envelope_id, recipient_view_request=recipient_view_request)

    return results.url
def send_envelope():
    check_token()

    # document 1 (html) has sign here anchor tag **signature_1**
    # document 2 (docx) has sign here anchor tag /sn1/
    # document 3 (pdf)  has sign here anchor tag /sn1/
    #
    # The envelope has two recipients.
    # recipient 1 - signer
    # recipient 2 - cc
    # The envelope will be sent first to the signer.
    # After it is signed, a copy is sent to the cc person.

    args = {
        'signer_email': ds_config("DS_SIGNER_EMAIL"),
        'signer_name': ds_config("DS_SIGNER_NAME"),
        'cc_email': ds_config("DS_CC_EMAIL"),
        'cc_name': ds_config("DS_CC_NAME"),
    }

    # create the envelope definition
    env = EnvelopeDefinition(email_subject='Document sent from the Test Mode')
    doc1_b64 = base64.b64encode(bytes(create_document1(args),
                                      'utf-8')).decode('ascii')
    # read files 2 and 3 from a local directory
    # The reads could raise an exception if the file is not available!
    with open(path.join(demo_docs_path, DOC_2_DOCX), "rb") as file:
        doc2_docx_bytes = file.read()
    doc2_b64 = base64.b64encode(doc2_docx_bytes).decode('ascii')
    with open(path.join(demo_docs_path, DOC_3_PDF), "rb") as file:
        doc3_pdf_bytes = file.read()
    doc3_b64 = base64.b64encode(doc3_pdf_bytes).decode('ascii')

    # Create the document models
    document1 = Document(  # create the DocuSign document object
        document_base64=doc1_b64,
        name='Order acknowledgement',
        # can be different from actual file name
        file_extension='html',  # many different document types are accepted
        document_id='1'  # a label used to reference the doc
    )
    document2 = Document(  # create the DocuSign document object
        document_base64=doc2_b64,
        name='Battle Plan',  # can be different from actual file name
        file_extension='docx',  # many different document types are accepted
        document_id='2'  # a label used to reference the doc
    )
    document3 = Document(  # create the DocuSign document object
        document_base64=doc3_b64,
        name='Lorem Ipsum',  # can be different from actual file name
        file_extension='pdf',  # many different document types are accepted
        document_id='3'  # a label used to reference the doc
    )
    # The order in the docs array determines the order in the envelope
    env.documents = [document1, document2, document3]

    # Create the signer recipient model
    signer1 = Signer(email=args['signer_email'],
                     name=args['signer_name'],
                     recipient_id="1",
                     routing_order="1")
    # routingOrder (lower means earlier) determines the order of deliveries
    # to the recipients. Parallel routing order is supported by using the
    # same integer as the order for two or more recipients.

    # create a cc recipient to receive a copy of the documents
    cc1 = CarbonCopy(email=args['cc_email'],
                     name=args['cc_name'],
                     recipient_id="2",
                     routing_order="2")

    # 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. So the
    # signHere2 tab will be used in both document 2 and 3 since they
    #  use the same anchor string for their "signer 1" tabs.
    sign_here1 = SignHere(anchor_string='**signature_1**',
                          anchor_units='pixels',
                          anchor_y_offset='10',
                          anchor_x_offset='20')
    sign_here2 = SignHere(anchor_string='/sn1/',
                          anchor_units='pixels',
                          anchor_y_offset='10',
                          anchor_x_offset='20')

    # Add the tabs model (including the sign_here tabs) to the signer
    # The Tabs object wants arrays of the different field/tab types
    signer1.tabs = Tabs(sign_here_tabs=[sign_here1, sign_here2])

    # Add the recipients to the envelope object
    recipients = Recipients(signers=[signer1], carbon_copies=[cc1])
    env.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"
    env.status = "sent"

    # Creates the Salse order Custom Field
    text_custom_field = TextCustomField(name='Sales order',
                                        value='Test_Mode',
                                        show='true',
                                        required='true')
    custom_fields = CustomFields(text_custom_fields=[text_custom_field])
    env.custom_fields = custom_fields

    envelope_api = EnvelopesApi(api_client)
    results = envelope_api.create_envelope(get_account_id(),
                                           envelope_definition=env)

    return results