Advanced Tutorial Using purchase-order-failure Template

If you'd like to try a more advanced template, add the purchase-order-failure Smart Clause to your contract on Clause. This Smart Clause will determine if a purchase order is received past the due date and issue a payment obligation for a penalty if late. The Smart Clause is stateful and will keep track of the total number of late purchase orders. When the number reaches the integer set as maxFailures, an additional charge will be added to the penalty.

Firstly ensure you have configured the DocuSign listener as described here.

You can configure your Smart Clause to send an email with the amount owed (see below) or even trigger a Stripe payment to be made, described here.

{
  "$class": "io.clause.outbound.physical.alerts.email.EmailMessage",
  "contractId": metadata.contractId,
  "to": "<EMAIL>",
  "subject": "Late Payment Penalty",
  "message": "The owed amount is " & event.amount.doubleValue & " " & event.amount.currencyCode
}

The next step is to sign your Smart Legal Contract in Clause and retrieve the triggerURL and bearerToken from the running Smart Clause.

Once you have signed a contract running on Clause with the purchase-order-failure Smart Clause, you can issue purchase order agreements from your DocuSign account. Each DocuSign envelope should include the following custom envelope fields: triggerUrl, bearerToken. You can create a template that pre-populates the triggerUrl and bearerToken with those from the Smart Clause. When the agreement is signed (signalling receipt of the order), the Smart Clause will be triggered and will check the time of receipt against the delivery date and emit a payment obligation if late.

Creating a Purchase Order Template

  1. The first stage to creating a template in DocuSign is to create a Word document that will be used to overlay the DocuSign fields that the recipient will enter data into. The Word document does not have to conform to a specific layout for format, so here is an example used this tutorial:
  2. In DocuSign, go to the Templates tab and click Create A Template.
  3.  Upload the Word document you just created.
  4. Add a recipient and ensure that they are marked as needing to sign, and click Next.
  5. Under the Custom Fields tab, create the following fields, ensuring that they have the exact names and configuration as specified below:

    actualPrice: Text type with Numbers validation enabled

    deliveryDate: Text type with Date validation enabled

    currencyCode: Text type with no validation


    For example, the actualPrice field will be configured as follows:

  6. Next drag each custom field onto the document where you want the input field to appear.  

  7. Add a signature field to the document from the Standard Fields palette.

  8. Click the Next button, then give the template a name and save.


Creating and Signing a Purchase Order


  1. In the templates view, select the Use option under the template that has just been created.
  2. Add a recipient who will be asked to enter the purchase order details and sign the document, and click Send.
  3. An email will be sent, inviting the recipient to review and sign the document. Click on Review Document.
  4. Fill in the details on the document and sign it. If you enter a date in the past, this will trigger a penalty payment that will result in an email being generated by the Clause action setup earlier. Then click Finish.
  5. At this point the Clause will be trigger by DocuSign and a request will be sent with the default envelope data as well as the data entered by the recipient. This should result in an email being generated by the Clause action setup earlier, detailing the penalty amount calculated by your Smart Clause.