NewDash Dots are hereMini apps in Dash, with payments built inLearn more

Products · Templates

Templates

Built-in steps for payments, the subscriber's name and number, and the server time.

Templates are built-in steps you add to a flow as a page. They do work that would otherwise need your own exchange endpoint.

Available Templates

TemplateWhat it does
collect_paymentAsks the subscriber to approve a mobile money payment with their PIN
get_subscriber_msisdnAsks the subscriber for permission to use their phone number
get_provider_kyc_nameGets the name the subscriber's account is registered under with their network
get_server_timeGets the current time

Page Structure

JSON
{
  "id": "page_id",
  "component": {
    "type": "template",
    "label": "Text shown to the subscriber",
    "template_name": "collect_payment",
    "template_data": {
      "payment_target_ref": "7150001234"
    }
  }
}
PropertyTypeRequiredDescription
typestringYesMust be "template"
template_namestringYesWhich template to run
labelstringFor collect_paymentThe question on screen. Only collect_payment (the PIN prompt) and get_subscriber_msisdn (the permission question) show a label. The other templates show nothing.
template_dataobjectFor collect_paymentSettings for the template. Templates that take none can leave it out.

What a Template Returns

Each template sets its page value. Read it with $(page.PAGE_ID.value):

TemplatePage value
collect_paymentThe transaction ID
get_subscriber_msisdnThe phone number, or empty if the subscriber said no
get_provider_kyc_nameThe registered name, or empty if the network has none
get_server_timeThe current time in UTC

There are no other keys. A reference like $(page.pay.payment_status) stops the flow with an error.

Example

This flow asks for an amount, takes the payment, and shows the transaction ID:

JSON
{
  "version": "1.0",
  "pages": [
    {
      "id": "enter_amount",
      "component": {
        "type": "prompt",
        "label": "Enter amount (SLE 100 to 10,000):",
        "data_type": "integer",
        "min_value": 100,
        "max_value": 10000
      }
    },
    {
      "id": "process_payment",
      "component": {
        "type": "template",
        "label": "Enter your $(session.network_provider_name) PIN to pay {{amount}} to Kroo Bay Clinic.",
        "template_name": "collect_payment",
        "template_data": {
          "payment_target_ref": "7150001234",
          "amount": "$(page.enter_amount.value)",
          "reference": "CLINIC-FEE",
          "receipt_name": "Kroo Bay Clinic fee"
        }
      }
    },
    {
      "id": "payment_done",
      "component": {
        "type": "display",
        "label": "Paid SLE $(page.enter_amount.value).\nRef: $(page.process_payment.value)"
      }
    }
  ]
}

Keep reading