Skip to content

Quick start

This round-trips one payment on the test environment: get a token, look up a bill, pay it. It’s the whole payment processor integration in one program. Service providers: see Publish bills and Collect payments instead.

  1. Get test credentials from your Axis Solutions contact: a client_id and client_secret for https://test.unipay.co.zw. For a bill to pay, use one from the sandbox in Test data — SBXOWEUSD always owes.

  2. Set them in your environment:

    Terminal window
    export UNIPAY_BASE_URL=https://test.unipay.co.zw
    export UNIPAY_CLIENT_ID=your-client-id
    export UNIPAY_CLIENT_SECRET=your-client-secret
  3. Run the example for your language with the bill number and an amount. It prints what the bill’s holder owes, pays, and prints the result:

    Sandbox Owing USD owes 999875.0000 USD (Sandbox: owing in USD)
    EX1790704100495: Payment Saved (new record: True)

Each tab is a complete program; its first lines say how to run it. The same code is split step by step through the rest of the docs.

#!/usr/bin/env bash
# UniPay payment processor example: get a token, look up a bill, pay it.
# bash + curl + jq.
#
# export UNIPAY_BASE_URL=https://test.unipay.co.zw
# export UNIPAY_CLIENT_ID=... UNIPAY_CLIENT_SECRET=...
# ./payment_processor.sh <billNo> <amount>
set -euo pipefail
BASE_URL="${UNIPAY_BASE_URL:-https://test.unipay.co.zw}"
BILL_NO="$1"
AMOUNT="$2"
# Tokens last 30 minutes: reuse one for every call in that window.
TOKEN=$(curl -sS --fail-with-body -X POST "$BASE_URL/connect/token" \
--data-urlencode "grant_type=client_credentials" \
--data-urlencode "client_id=$UNIPAY_CLIENT_ID" \
--data-urlencode "client_secret=$UNIPAY_CLIENT_SECRET" \
--data-urlencode "scope=unipay:bills" | jq -r .access_token)
LOOKUP=$(curl -sS --fail-with-body -X POST "$BASE_URL/api/app/payment-processor/lookup" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "{\"billNo\": \"$BILL_NO\"}")
echo "$LOOKUP" | jq '{successful, message, name: .bill.name, currency: .bill.currency, payableNow, acceptedCurrencies}'
CURRENCY=$(echo "$LOOKUP" | jq -r .bill.currency)
RRN="EX$(date +%s%3N)" # your unique reference: reuse it on every retry of this payment
curl -sS --fail-with-body -X POST "$BASE_URL/api/app/payment-processor/payment-details" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"billNo\": \"$BILL_NO\",
\"rrn\": \"$RRN\",
\"paymentDate\": \"$(date +%Y-%m-%dT%H:%M:%S%:z)\",
\"currency\": \"$CURRENCY\",
\"amount\": $AMOUNT
}"
# → {"successful":true,"message":"Payment Saved","isNewRecord":true,...}

These examples are run against a UniPay instance before each docs release.

UniPay API v1 · build e1eb5c49 · Powered by Axis Solutions