How to Automate eSignatures After Online Payment

"How to Automate eSignatures After Online Payment" header image

How to Automate eSignatures After Online Payment

Businesses need to get paid. It’s why they do what they do. Contracts are amazing tools for specifying dues and due dates, along with party responsibilities and risks. Every business needs an efficient way to handle contracts so they get exactly what they are owed, on time and with minimal expense. A business can't be slowed down by having to manually cross the T’s and dot the I’s on physical paperwork; digital is the name of the game now. HelloSign helps businesses automate the process of generating digital contracts.


In this article, we'll be looking at a hypothetical service marketplace that connects professional house painters with customers. They want to automatically send customized contracts to customers on behalf of the service providers when customers pay the down payment. Each customer then completes their signature to officially confirm the painting service. HelloSign will be used to automatically provide the eSignature request via the HelloSign API using information received from the payment processor.


Use Webhooks to Begin the eSignature Process

First, let's talk about payment services. Businesses want to know the moment payments come in so they can be processed immediately. A webhook is a common way to listen for incoming payments via your payment service provider and trigger an automated response. Whether the payment service you support is Stripe, Paypal, or another one entirely, as long as the service supports webhooks, it can be used to begin the automatic creation of the eSignature process. That being said, while most will support webhooks in some form or another, you’ll need look into how your specific payment processor handles webhook implementations.


Webhooks are often referred to as reverse APIs. While using an API involves your app sending information to a service, a webhook is where the service provides information to your app instead. It’s likely that the payment processor willl be able to provide charge details as JSON data. The payment information will look something like the following, an abridged version of what someone receives from Stripe when a charge is captured. Please note that this is just a snippet of what Stripe actually returns.

  
    {
      "type":"charge.captured",
      "object":"event",
      "data":{
        "object":{
          "object":"charge",
          "amount":100,
          "billing_details":{
            "address":{
              "city":"Forks",
              "country":"United States",
              "line1":"12345 SW 123 PL",
              "line2":null,
              "postal_code":"98331",
              "state":"WA"
            },
            "email":"alice@email.com",
            "name":"Alice Smith",
            "phone":"555 - 555 - 5555"
          }
        }
      }
    }
  

Now let's look at how this fits into our example of a house painter marketplace. Once a customer connects with a painter and makes a payment using a payment processor such as Stripe, the marketplace will receive information pertinent to the transaction from Stripe's webhook.


This information can then be extracted from the JSON in a straightforward manner, like so, if you were using Python.

  
    if event.type == 'charge.captured':
            customer_data = event.data.object

    customer_address = customer_data.billing_details.address
    customer_email = customer_data.email
    customer_name = customer_data.name
  

This information can then be used to begin the eSignature process by making use of the HelloSign API.

Send Documents For Signatures with HelloSign

With the transaction details in hand, your app has everything it needs to collect signatures. This will be done through the HelloSign API.


Before using the HelloSign API, you'll need to create an account, and grab an API key from the HelloSign web app. Usually, accessing the HelloSign API requires a payment plan. However, you can make use of the free test mode HelloSign provides to develop your workflow.


Protip: HelloSign is a Dropbox company, so Dropbox users can simply use their existing account to log in and keep their credentials consolidated.


For using Python, you'll need Python 3 and the HelloSign Python SDK. For more details on getting started using HelloSign in a Python environment, check out our guide. We'll still touch on everything you need here, as well.


Import the HelloSign SDK and use the API key to instantiate the client like so:

  
    from hellosign_sdk import HSClient
    client = HSClient(api_key='SIGN_IN_AND_CREATE_API_KEY_FIRST')
    client.get_account_info()
  

The `get_account_info()` call is a quick way to verify that the HSClient is correctly implemented. In this example, we'll assume there is a standard contract that is used for all the house painters in the marketplace. The contract in our example will be called "contract.pdf".


The service marketplace app can use the Send Signature Request endpoint to send a signature request with specific information regarding the signers and files. For the signer information, they can use the transaction details returned in the webhook payload from the payment processor. In this case, we're using the parameters `customer_email` and `customer_name`.

  
    from hellosign_sdk import HSClient
    client = HSClient(api_key='<API-KEY>')
    client.send_signature_request(
        test_mode=True,
        title="Painting Contract",
        message="Please sign this.",
        signers=[{ 'email_address': customer_email, 'name': customer_name }],
        files=['contract.pdf']
    )
  

By using the `Send Signature Request` endpoint in the application, the flow looks like this: Once the payment process is completed and the webhook sent, HelloSign sends out the contract template to the customer with their specific information pulled in via the webhook. The signers of the document are notified via email that their signatures are required.


Of course, sending the signature request is not the end of a signature flow. When the application makes a request, there will be a corresponding `signature_request_id`. This will be used to finish the process.


Provide Tools to Monitor Document Statuses

The current status of a contract document as it passes through its lifecycle provides actionable information. In our house painting example, we would like to dispatch painters to a paint job only if the underlying contract document has been signed by all parties. Thus, tools to track the status of a contract document are essential for process automation.


A fully-fleshed out service marketplace will provide additional features for businesses to help manage their digital paperwork. We'll look at just a few ways the HelloSign API can be used to offer additional services.


First, business owners will likely want to be able to view the status of their documents on demand. You can use the `List Signature Requests` endpoint to let businesses view the documents they're connected to.

  
    signature_request_list = client.get_signature_request_list()
  

Furthermore, the API can be used to find all the signature requests that contain a specific name, or any other attribute for that matter, and grab those signature requests’ information to show in a filtered view somewhere on the application. Searching for a specific signer can be done like so:

  
    relevant_signature_objects = []
    name = input('Search for a name')

    for signature_request in signature_request_list:
        if signature_request.signatures[0].signer_name.lower() == name.lower():
            relevant_signature_objects.append(signature_request)
  

And finally, you can give them the ability to download the signed files as well, incorporating the `get_signature_request_file` endpoint.

  
    client.get_signature_request_file(
        signature_request_id='SIGNATURE_REQUEST_ID',
        filename='mySignedDocument.pdf'
    )
  

Throughout this article, we examined eSignature functionality through the lens of a service marketplace that connects house painters with customers. By making use of a payment processor's webhooks, we received data about a transaction and used it to create a new signature request with the HelloSign API. We also added some functionality to monitor the status of signature requests.


These are just some of the building blocks of creating a robust eSignature workflow in a service marketplace. As you build out eSignature functionality to fully conform to your specific needs, you'll want to check out the full HelloSign API documentation. We're sure that whatever your goals, the HelloSign API can help you achieve them.

Ready to integrate signatures into your app or website?

Let us help you build a custom API plan that fits your unique business needs.

Get news, insights and posts directly in your inbox

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form
Oops! Something went wrong while submitting the form.