Esempio n. 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")
Esempio n. 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)
Esempio n. 3
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))