Beispiel #1
0
def invoice_sign(request, uuid):
    invoice = get_object_or_404(Invoice, uuid=uuid)
    client = HSClient(api_key=HELLOSIGN_API_KEY)
    try:
        response = client.get_signature_request('%s' % invoice.signature_request_id)
        client.cancel_signature_request(invoice.signature_request_id)
    except (NotFound, Gone):
        pass
    filename = request.POST.get('filename', invoice.uuid)
    filename = '%s/%s' % (HELLOSIGN_PRESIGN_DIR, filename)
    fields = [
        [
            {
                "api_id": "uniqueIdHere_2",
                "name": "",
                "type": "signature",
                "x": 450,
                "y": 310,
                "width": 240,
                "height": 60,
                "required": True,
                "signer": 0
            }
        ]
    ]

    if os.path.exists(filename):
        response = client.send_signature_request_embedded(
            test_mode=HELLOSIGN_TEST_MODE,
            client_id=HELLOSIGN_CLIENT_ID,
            title=invoice.uuid,
            signers=[
                {
                    'email_address': invoice.email,
                    'name': invoice.company_name,
                }
            ],
            form_fields_per_document=json.dumps(fields),
            files=[filename]
        )
        invoice.signature_request_id = response.signature_request_id
    else:
        return http.HttpResponse(json.dumps({'sign_url': False}), content_type="application/json")
    signature = response.signatures[0]
    invoice.signature_id = signature.signature_id
    invoice.save()
    data = client.get_embedded_object(signature.signature_id)

    return http.HttpResponse(json.dumps(data.json_data), content_type="application/json")
Beispiel #2
0
def sendsigrequest(request):

    apikey = creds['alexmcferronAPIKEY']
    clientID = creds['alexmcferronClientID']
    client = HSClient(api_key=apikey)
    #account = client.get_account_info()
    #emailaddress = client.account.email_address

    response = client.send_signature_request_embedded(
        test_mode=True,
        client_id=clientID,
        files=["slowpdf2.pdf"],
        title="embedded",
        subject="Ticket 277902",
        message="Ticket 277902",
        signers=[{
            'email_address': '*****@*****.**',
            'name': 'andrew'
        }
                 #{'email_address': '*****@*****.**', 'name': 'freedom'}
                 ],
        use_text_tags=False,
    )

    exploreSignatureRequestResponseObject(response)
    print(response)

    message = utilTimeStampAndMessage(
        "TIME SIGNATURE REQUEST CREATED - call is finished")
    print(message)

    sigRequestURL = 'notSet'

    if len(listOfSignRequests) > 0:
        mySignatureID = listOfSignRequests.pop(0)
        sigRequestURL = client.get_embedded_object(mySignatureID)
        print(mySignatureID + " =signatureID")
        print(_myDictSignatureRequestID_ToEmail[mySignatureID])

    urlOnly = sigRequestURL.sign_url

    results = {}
    results.update({'TempUrl': urlOnly})
    results.update({'clientID': clientID})

    message = utilTimeStampAndMessage("CALLING THE IFRAME NOW ALEX M")
    print(message)
    return render(request, "sign.html", results)
Beispiel #3
0
def index():
	client = HSClient(api_key=HS_APP_KEY)
	embedded_sign = client.send_signature_request_embedded_with_template(
		test_mode=True,
		client_id=HS_CLIENT_ID,
		template_id=TEMPLATE_ID,
		subject='<subject>',
		message='<message>',
		signers=[{ 
			'role_name': '<role>', 
			'email_address': '<email>', 
			'name': '<name>' 
			}])
	embed_id = client.get_embedded_object(embedded_sign.signatures[0].signature_id)
	sign_url = str(embed_id.sign_url)
	return render_template('index.html', client_id=HS_CLIENT_ID, sign_url=sign_url)
Beispiel #4
0
    def get_signer_signing_url(self, signer):
        signature_id = None
        signatures = self.signatures
        signer_email = signer.email.lower()

        try:
            ## convert to lower jsut incase hellosign one day fixes their error
            signature_id = [s for s in signatures if s.get('signer_email_address').lower() == signer_email][0].get('signature_id', None)
        except IndexError:
            logger.error('Could not find signer: %s in %s' % (signer_email, signatures))
            
        if signature_id is not None:
            HS_CLIENT = HSClient(api_key=settings.HELLOSIGN_API_KEY)
            embedded_signing_object = HS_CLIENT.get_embedded_object(signature_id)

            return embedded_signing_object.sign_url
        return None
Beispiel #5
0
def embedded_signing(request):
    ''' Embedded signing demo '''
    if request.method == 'POST':
        try:

            user_email = request.POST['email']
            user_name = request.POST['name']
            hsclient = HSClient(api_key=API_KEY)

            files = [
                os.path.dirname(os.path.realpath(__file__)) + "/docs/nda.pdf"
            ]
            signers = [{"name": user_name, "email_address": user_email}]
            cc_email_addresses = []
            sr = hsclient.send_signature_request_embedded(
                test_mode=True,
                client_id=CLIENT_ID,
                files=files,
                title="NDA with Acme Co.",
                subject="The NDA we talked about",
                message=
                "Please sign this NDA and then we can discuss more. Let me know if you have any questions.",
                signers=signers,
                cc_email_addresses=cc_email_addresses)
            embedded = hsclient.get_embedded_object(
                sr.signatures[0].signature_id)
        except KeyError:
            return render(
                request, 'hellosign/embedded_signing.html',
                {'error_message': "Please enter both your name and email."})
        except NoAuthMethod:
            return render(
                request, 'hellosign/embedded_signing.html', {
                    'error_message':
                    "Please update your settings to include a value for API_KEY."
                })
        else:
            return render(request, 'hellosign/embedded_signing.html', {
                'client_id': CLIENT_ID,
                'sign_url': str(embedded.sign_url)
            })
    else:
        return render_to_response('hellosign/embedded_signing.html',
                                  context_instance=RequestContext(request))
Beispiel #6
0
def embedded_signing_with_template(request):
    try:
        hsclient = HSClient(api_key=API_KEY)
    except NoAuthMethod:
        return render(
            request, 'hellosign/embedded_signing_with_template.html', {
                'error_message':
                "Please update your settings to include a value for API_KEY."
            })
    if request.method == 'POST':
        try:
            signers = []
            post_dict = parser.parse(request.POST.urlencode())
            template_id = post_dict["template"]
            for (key, value) in post_dict["signerRole"].iteritems():
                if value:
                    value['role_name'] = key
                    signers.append(value)

            ccs = []
            if 'ccRole' in post_dict and len(post_dict['ccRole']) > 0:
                for (key, value) in post_dict["ccRole"].iteritems():
                    # if value:
                    ccs.append({'role_name': key, 'email_address': value})

            custom_fields = []
            if 'cf' in post_dict and len(post_dict['cf']) > 0:
                for (key, value) in post_dict["cf"].iteritems():
                    if value:
                        custom_fields.append({key: value})

            sr = hsclient.send_signature_request_embedded_with_template(
                test_mode=True,
                client_id=CLIENT_ID,
                template_id=template_id,
                title="NDA with Acme Co.",
                subject="The NDA we talked about",
                message=
                "Please sign this NDA and then we can discuss more. Let me know if you have any questions.",
                signing_redirect_url=None,
                signers=signers,
                ccs=ccs,
                custom_fields=custom_fields)
            embedded = hsclient.get_embedded_object(
                sr.signatures[0].signature_id)

        # TODO: need some more validations here
        # except KeyError:
        #     return render(request, 'hellosign/embedded_signing_with_template.html', {
        #         'error_message': "Please enter both your name and email.",
        #     })
        except NoAuthMethod:
            pass
        else:
            return render(request,
                          'hellosign/embedded_signing_with_template.html', {
                              'client_id': CLIENT_ID,
                              'sign_url': str(embedded.sign_url)
                          })
    else:
        template_list = hsclient.get_template_list()
        templates = []
        for template in template_list:
            template_data = dict(template.json_data)
            del template_data['accounts']
            templates.append(template_data)
        templates = json.dumps(templates)
        return render(request, 'hellosign/embedded_signing_with_template.html',
                      {'templates': templates})