VAS products

Lists the value-added service (VAS) products configured for your organisation — the products you're entitled to sell, the providers behind each, and the format hints to validate user input against before sending a purchase.

List enabled products

http
GET /v1/vas-products
curl
bash
curl https://api.scratchpower.com/v1/vas-products \
  -H "Authorization: Bearer $TOKEN"

Response

200 OK
json
[
  {
    "product_type": "ELECTRICITY",
    "display_name": "Electricity",
    "subscriber_id_label": "Meter Number",
    "subscriber_id_min_length": 11,
    "subscriber_id_max_length": 13,
    "subscriber_id_pattern": "^[0-9]{11,13}$",
    "subscriber_id_hint": null,
    "providers": [
      { "code": "BPC", "name": "Botswana Power Corporation" }
    ]
  }
]

Fields

FieldTypeNotes
product_typestringOne of ELECTRICITY, AIRTIME, WATER
display_namestringLocalised label safe to show to users
subscriber_id_labelstring | nullWhat to label the input ("Meter Number", "Phone Number", ...)
subscriber_id_min_lengthinteger | nullMinimum number of characters
subscriber_id_max_lengthinteger | nullMaximum number of characters
subscriber_id_patternstring | nullJS-compatible regex the value must match
subscriber_id_hintstring | nullFree-form admin-curated description (overrides auto-derived hint)
providersarrayProviders offering this product to your org

Subscriber ID validation

Apply length AND pattern in tandem on the client. For displaying the hint to users, prefer subscriber_id_hint when it's set, otherwise synthesise from min/max:

Node — minimal validator
js
function validate(product, value) {
  const min = product.subscriber_id_min_length;
  const max = product.subscriber_id_max_length;
  const pat = product.subscriber_id_pattern;
  if (min != null && value.length < min) return false;
  if (max != null && value.length > max) return false;
  if (pat && !new RegExp(pat).test(value)) return false;
  return true;
}

Different providers within the same product type may have different subscriber ID formats. The format on the product is the loosest envelope — providers may further validate during the call to /purchases/validate.