View Voucher
POST {api-url}/viewVoucher?ns={community}
View a voucher in the specified community.
Parameters
Section titled βParametersβ| Field | Type | Requirement | Description |
|---|---|---|---|
VoucherNo | String | Required | The voucher number that was sent to the recipient. |
Metadata | String | Optional | Any other detail that the merchant wishes to store on this transaction. |
Example Body
Section titled βExample Bodyβ{ "VoucherNo": "168-78439-48310", "Metadata": "{\"ActorUserIDs\": \"547828938941114\"}"}Parameters
Section titled βParametersβ| Field | Type | Description |
|---|---|---|
TID | String | TID (Transaction ID) of the executed payment response. |
Owner | String | The unique username of the owner for this voucher. |
VoucherNo | String | The voucher number that was sent to the recipient. |
VoucherType | String | The voucher type (e.g., 168Cash). |
Title | String | The amount, currency, voucher type & voucher number in a formatted string. |
Amount | String | Voucher amount in cents. If Amount > 0, voucher is active. |
Locked | String | Whether the voucher is locked or not. A locked voucher cannot be spent. |
AutoLock | String | Whether new, subsequent vouchers are locked automatically, after spend/settle. |
VSettle | String | Whether the voucher will generate a brand new voucher number on spend/settle. |
VAccumulate | String | Whether new vouchers of the same type will accumulate their value into a single voucher. |
WithdrawFee | String | The withdraw fee for this voucher in cents. |
State | String | Transaction state (Success or Failed). |
Status | String | Transaction status code (1 or negative error code). |
Error | String | Failure reason, if applicable. |
Example Body
Section titled βExample Bodyβ{ "TID": "14975698684", "Owner": "27648302057", "VoucherNo": "168-78439-48310", "VoucherType": "168Cash", "Title": "Voucher 168Cash ZAR 20.00 Number : 168-78439-48310", "Amount": "2000", "Locked": "1", "AutoLock": "1", "VSettle": "1", "VAccumulate": "1", "WithdrawFee": "1000", "State": "Success", "Status": "1", "Error": ""}curl -X POST '{api-url}/viewVoucher?ns={community}' \-H 'Authorization: bearer YOUR_TOKEN' \-H 'Content-Type: application/json' \-d '{"VoucherNo":"168-78439-48310","Metadata":"{\"ActorUserIDs\": \"547828938941114\"}"}'using System;using System.Net.Http;using System.Text;using System.Threading.Tasks;
class Program{ static async Task Main(string[] args) { var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "{api-url}/viewVoucher?ns={community}"); request.Headers.Add("Authorization", "bearer YOUR_TOKEN");
var jsonPayload = @"{ ""VoucherNo"": ""168-78439-48310"", ""Metadata"": ""{\""ActorUserIDs\"": \""547828938941114\""}""}"; request.Content = new StringContent(jsonPayload, Encoding.UTF8, "application/json");
var response = await client.SendAsync(request); response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); }}package main
import ( "fmt" "io/ioutil" "net/http" "strings")
func main() { url := "{api-url}/viewVoucher?ns={community}" payload := strings.NewReader(`{"VoucherNo":"168-78439-48310","Metadata":"{\"ActorUserIDs\": \"547828938941114\"}"}`)
req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "bearer YOUR_TOKEN") req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req) defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body) fmt.Println(string(body))}import java.net.URI;import java.net.http.HttpClient;import java.net.http.HttpRequest;import java.net.http.HttpResponse;
public class ApiRequest { public static void main(String[] args) throws Exception { var payload = """ { "VoucherNo": "168-78439-48310", "Metadata": "{\"ActorUserIDs\": \"547828938941114\"}"} """;
var request = HttpRequest.newBuilder() .uri(URI.create("{api-url}/viewVoucher?ns={community}")) .header("Authorization", "bearer YOUR_TOKEN") .header("Content-Type", "application/json") .POST(HttpRequest.BodyPublishers.ofString(payload)) .build();
var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); }}// Requires Node.js v18+(async () => { const url = '{api-url}/viewVoucher?ns={community}'; const payload = { "VoucherNo": "168-78439-48310", "Metadata": { "ActorUserIDs": "547828938941114" }};
try { const response = await fetch(url, { method: 'POST', headers: { 'Authorization': 'bearer YOUR_TOKEN', 'Content-Type': 'application/json' }, body: JSON.stringify(payload) }); const data = await response.json(); console.log(data); } catch (error) { console.error('Error:', error); }})();<?php$curl = curl_init();
curl_setopt_array($curl, array( CURLOPT_URL => '{api-url}/viewVoucher?ns={community}', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => '{ "VoucherNo": "168-78439-48310", "Metadata": "{\"ActorUserIDs\": \"547828938941114\"}"}', CURLOPT_HTTPHEADER => array( 'Authorization: bearer YOUR_TOKEN', 'Content-Type: application/json' ),));
$response = curl_exec($curl);curl_close($curl);echo $response;import requestsimport json
url = "{api-url}/viewVoucher?ns={community}"payload = { "VoucherNo": "168-78439-48310", "Metadata": { "ActorUserIDs": "547828938941114" }}
headers = { "Authorization": "bearer YOUR_TOKEN", "Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)print(response.json())require 'uri'require 'net/http'require 'json'
url = URI("{api-url}/viewVoucher?ns={community}")
http = Net::HTTP.new(url.host, url.port)http.use_ssl = true
request = Net::HTTP::Post.new(url)request["Authorization"] = 'bearer YOUR_TOKEN'request["Content-Type"] = 'application/json'
request.body = JSON.dump({ "VoucherNo": "168-78439-48310", "Metadata": { "ActorUserIDs": "547828938941114" }})
response = http.request(request)puts response.read_body