Skip to content
Wire Ghapi

Introduction

Learn how to connect your website or app to the Wire Gh Pay API.

API basics

Before you begin

You need a free Wire Gh account. Open Wire Pay from your dashboard and your test keys are ready at once, so you can start calling the API right away.

The Wire Gh Pay API lets you collect payments, confirm them, manage customers and send refunds from your own code. It is a REST API: you send standard HTTP requests with JSON bodies, and every response is JSON.

All requests must use HTTPS. Requests over plain HTTP are refused.

Base URL

Send every request to:

https://api.wiregh.com

The same base URL serves test and live mode. The key you send decides which one you are using.

Test and live mode

Every business has two sets of keys. Use your test keys while you build. Test payments move no real money, and you can trigger every outcome with our test numbers. Live keys appear on your dashboard after your business is approved, and they collect real money.

KeyStarts withWhere to use it
Test public keywg_pk_test_Your website or app, for the popup
Test secret keywg_sk_test_Your server only
Live public keywg_pk_live_Your website or app, for the popup
Live secret keywg_sk_live_Your server only

Records are kept apart by mode. A transaction made with a test key can only be seen with a test key.

Requests and responses

Send request bodies as JSON with the header Content-Type: application/json. Every response has the same envelope:

{
  "status": true,
  "message": "Verification successful",
  "data": { }
}
  • status is true when the request worked and false when it did not.
  • message is a short summary you can log or show.
  • data holds the result. List endpoints also return meta, see pagination.
Amounts are in pesewas

All amounts are whole numbers in pesewas, the smallest unit of the Ghana cedi. GHS 1.00 is 100, and GHS 250.50 is 25050. Decimals are refused.

Every response carries an x-request-id header. Include it when you contact support about a request.

Authentication

Authenticate every request by sending your secret key as a Bearer token in the Authorization header:

Authorization: Bearer wg_sk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Example request
curl https://api.wiregh.com/balance \
-H "Authorization: Bearer YOUR_SECRET_KEY" \
-X GET
Keep your secret key secret

Your secret key can move money on your account. Use it only on your server. Never put it in a web page, a mobile app, a public code repository or a support message. If it leaks, open API & Sandbox on your dashboard and regenerate it at once.

Your public key is safe to use in the browser, but it can only start a payment with the popup and read the list of networks. A request with a missing or wrong key gets a 401 response.

For extra protection you can require signed requests on your secret keys and limit each secret key to the IP addresses of your servers. Both switches are on the API and Sandbox page of your dashboard.

Rate limits

Limits keep the API fast and protect your account from abuse. When you go over a limit you get a 429 response with a Retry-After header that says how many seconds to wait.

LimitRequests per minute
Per secret key300
Per public key120
Per IP address600

An IP address that sends many requests with wrong keys is blocked for a while. Repeated failed charges on one Mobile Money number are also paused for an hour, to protect your customers.

If you need higher limits, contact support.

Pagination

List endpoints return results a page at a time, newest first. Use these query parameters:

Query parameters

perPageIntegeroptional
Records per page, from 1 to 100. Defaults to 50.
pageIntegeroptional
The page to return. Defaults to 1.

The meta object tells you where you are:

"meta": {
  "total": 120,
  "perPage": 50,
  "page": 1,
  "pageCount": 3
}

Errors

When a request fails, status is false, message explains what went wrong, and code is a stable value you can check in your code:

{
  "status": false,
  "message": "amount must be a whole number in pesewas (e.g. 5000 for GHS 50.00).",
  "code": "invalid_request"
}

HTTP status codes

CodeMeaning
200The request worked.
400Something in the request is wrong or missing. Read message.
401The key is missing, wrong, or the wrong type for this endpoint.
403The request is not allowed, for example live mode is not activated yet.
404The record or endpoint does not exist.
409The request clashes with one already in progress.
429Too many requests. Wait for the number of seconds in Retry-After.
500, 503A problem on our side. Wait a moment and retry with the same Idempotency-Key.

Error codes

CodeHTTPMeaning
invalid_request400A parameter is missing or not valid. message names it.
invalid_json400The request body is not valid JSON.
duplicate_reference400You already used this reference. References must be unique.
transaction_closed400The transaction is already complete, failed or abandoned.
expired400The transaction expired before it was paid. Start a new one.
attempts_exceeded400The transaction has had too many charge attempts.
otp_not_expected400This charge is not waiting for an OTP.
unsupported_channel400This payment channel cannot be used here.
starter_limit_reached400A Starter business has reached its collection limit. Upgrade to a Registered business.
not_refundable400Only successful transactions can be refunded.
refund_exceeds400The refund is more than the amount not yet refunded.
insufficient_balance400Your balance cannot cover this refund.
unauthorized401No Authorization header was sent.
invalid_key401The key is not valid. Check that you copied it fully.
wrong_key_type401This endpoint needs your secret key, not your public key.
bad_signature401The request signature is missing, old or wrong. See signed requests.
https_required403The request was not sent over HTTPS.
live_not_enabled403Your business is not approved for live payments yet.
merchant_inactive403Your business account is suspended. Contact support.
ip_not_allowed403This key only accepts requests from certain IP addresses.
ip_blocked403Requests from this IP address are blocked.
not_found404The record or endpoint does not exist.
method_not_allowed405The endpoint exists but not with this HTTP method.
charge_in_progress409A charge is already running for this transaction. Verify it or wait.
idempotency_conflict409This Idempotency-Key was used with a different request, or that request is still running.
body_too_large413The request body is larger than 64KB.
rate_limited429Too many requests. Slow down and retry later.
velocity_limit429Too many failed charges on this number. Try again later.
otp_attempts429Too many wrong OTP attempts on this charge.
provider_unavailable503The Mobile Money network is not responding. Retry shortly.
server_error500Something went wrong on our side. message includes a reference for support.