Send receipts by email or text message

Provide customers with paperless receipts by sending them via email or short message service (SMS).

The InStore colleague app supports sending a receipt at checkout using email or SMS. To enable paperless receipts, send a receipt template (for example, your existing Sales receipt) and cart data to the Receipt Print Server API.
Use the Allow_Defaulted_Customer_Email_Override and Allow_Defaulted_Customer_Phone_Override administration parameters to control whether a customer can use an email address or phone number on an ad-hoc basis.
Listen for the user's selected delivery method (print, email, or SMS) via the inStoreCore-receiptChoice event. For details, see Events.

Overview

The paperless receipt feature consists of the following components:

  • A receipt template written with Handlebars syntax.
  • A data object that contains receipt fields (for example, line items, total, and location data).
  • A request to the Receipt Print Server API that compiles the template and returns both markdown and Scalable Vector Graphics (SVG) output.

You can use the returned markdown to populate your outbound email or SMS system. You can display the returned SVG during checkout or when reprinting a receipt.

Generate an SVG receipt

The svg endpoint generates an SVG representation of a receipt without printing it. The builder utility processes the template and data, and converts currency values to Dinero format for consistent currency rendering.

Request

Send a POST request with the following fields to the Receipt Print Server API:

Requestbash
POST /api/svg
{
  "template": "Handlebars receipt template string",
  "data": "JSON receipt data object",
  "currency": "USD",
  "locale": "en-US",
  "currencyFormat": "$0,0.00"
}
Example request bodyjson
{
  "template": "^{{location.location_name}}^\n{{location.address_line_1}}\n-----------------\n{{#each line_items}}\n{{description}} {{quantity}} @ {{price}}\n{{/each}}\n-----------------\nTotal: {{total}}",
  "data": {
    "location": {
      "location_name": "COFFEE SHOP",
      "address_line_1": "123 Main Street"
    },
    "line_items": [
      {
        "description": "Cappuccino",
        "quantity": 1,
        "price": "$4.50"
      },
      {
        "description": "Croissant",
        "quantity": 2,
        "price": "$3.75"
      }
    ],
    "total": "$12.00"
  },
  "currency": "USD",
  "locale": "en-US",
  "currencyFormat": "$0,0.00"
}

Response

The server returns the status and receipt markdown that you can use to populate your own HTML template, which is suitable for sending from your outbound email or SMS system.

Response structurejson
{
  "markdown": "Compiled receipt markdown",
  "svg": "SVG representation of the receipt",
  "success": true
}

Example response:

Example responsejson
{
  "markdown": "^COFFEE SHOP^\n123 Main Street\n-----------------\nCappuccino 1 @ $4.50\nCroissant 2 @ $3.75\n-----------------\nTotal: $12.00",
  "svg": "<svg width=\"576px\" height=\"210px\" viewBox=\"0 0 576 210\" preserveAspectRatio=\"xMinYMin meet\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1.1\"><style type=\"text/css\"><![CDATA[@import url(\"https://fonts.googleapis.com/css2?family=Courier+Prime&display=swap\");]]></style><defs><filter id=\"receiptlineinvert\" x=\"0\" y=\"0\" width=\"100%\" height=\"100%\"><feFlood flood-color=\"#000\"/><feComposite in=\"SourceGraphic\" operator=\"xor\"/></filter></defs><g font-family=\"'Courier Prime', 'Courier New', 'Courier', monospace\" fill=\"#000\" font-size=\"22\" dominant-baseline=\"text-after-edge\" text-anchor=\"middle\"><g transform=\"translate(0,24)\"><text transform=\"scale(2,1)\"><tspan x=\"84\">C</tspan><tspan x=\"96\">O</tspan><tspan x=\"108\">F</tspan><tspan x=\"120\">F</tspan><tspan x=\"132\">E</tspan><tspan x=\"144\">E</tspan><tspan x=\"156\">&#xa0;</tspan><tspan x=\"168\">S</tspan><tspan x=\"180\">H</tspan><tspan x=\"192\">O</tspan><tspan x=\"204\">P</tspan></text></g><g transform=\"translate(0,54)\"><text><tspan x=\"204\">1</tspan><tspan x=\"216\">2</tspan><tspan x=\"228\">3</tspan><tspan x=\"240\">&#xa0;</tspan><tspan x=\"252\">M</tspan><tspan x=\"264\">a</tspan><tspan x=\"276\">i</tspan><tspan x=\"288\">n</tspan><tspan x=\"300\">&#xa0;</tspan><tspan x=\"312\">S</tspan><tspan x=\"324\">t</tspan><tspan x=\"336\">r</tspan><tspan x=\"348\">e</tspan><tspan x=\"360\">e</tspan><tspan x=\"372\">t</tspan></text></g><!-- SVG truncated for brevity -->",
  "success": true
}
The ^ characters in the template apply styling (typically emphasis or larger text) within the rendering engine. The template uses Handlebars syntax for dynamic content. For more information about available data fields, see Receipt data fields.