You can check the status of a request with your provided reference using this API.
Description
- Method: This is a GET request, indicating that data is being sent to the server.
- URL: The URL for this request is https://uat-businessapi.spenn.com/api/Partner/transaction/request/{externalReference}/status
- HTTPS Version: The request is made using HTTPS.
Headers
- Content-Type: The Content-Type header is set to application/json, indicating that the request body contains JSON data.
- Authorization: The Authorization header is used with a bearer token for authentication. The actual token value should replace the placeholder Bearer eyJhbG...NrEQ41w.
NB:
[ExternalReference] This is a unique id you generated when making payment requests.
Sample Request:
import requests
base_url = "https://uat-businessapi.spenn.com/api/Partner/transaction/request/{externalReference}/status"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer eyJhbG...NrEQ41w"
}
request_id = "1e6cc63a-2d0d-4885-9c51-f9a35f113811"
# Format the URL with the dynamic requestId
url = base_url.format(requestId=request_id)
payload = {
"requestMoneyGuid": request_id
}
# Make the GET request
response = requests.get(url, headers=headers, json=payload)
# Check the response status
if response.status_code == 200:
# Successful response
print("Request was successful. Response JSON:")
print(response.json())
else:
# Handle the error
print(f"Error: {response.status_code}\n{response.text}")
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class ApiRequestExample {
public static void main(String[] args) {
try {
String baseUrl = "https://uat-businessapi.spenn.com/api/Partner/transaction/request/{externalReference}/status";
String authorizationHeader = "Bearer eyJhbG...NrEQ41w";
String requestMoneyGuid = "1e6cc63a-2d0d-4885-9c51-f9a35f113811";
// Format the URL with the dynamic requestId
String url = baseUrl.replace("{requestId}", requestMoneyGuid);
URL apiUrl = new URL(url);
HttpURLConnection connection = (HttpURLConnection) apiUrl.openConnection();
// Set the request method to GET
connection.setRequestMethod("GET");
// Set request headers
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Authorization", authorizationHeader);
// Read the response
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
StringBuilder response = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
response.append(line);
}
reader.close();
// Print the response
System.out.println("Request was successful. Response JSON: " + response.toString());
// Close the connection
connection.disconnect();
} catch (Exception e) {
// Handle exceptions
e.printStackTrace();
}
}
}
const baseUrl = "https://uat-businessapi.spenn.com/api/Partner/transaction/request/{externalReference}/status";
const authorizationHeader = "Bearer eyJhbG...NrEQ41w";
const requestMoneyGuid = "1e6cc63a-2d0d-4885-9c51-f9a35f113811";
// Format the URL with the dynamic requestId
const url = baseUrl.replace("{requestId}", requestMoneyGuid);
const headers = {
"Content-Type": "application/json",
"Authorization": authorizationHeader
};
const payload = {
requestMoneyGuid: requestMoneyGuid
};
// Make the GET request
fetch(url, {
method: 'GET',
headers: headers,
body: JSON.stringify(payload)
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.json();
})
.then(data => {
console.log("Request was successful. Response JSON:", data);
})
.catch(error => {
console.error('Error:', error);
});
Sample response of approved request and transaction OK:
{
"$id": "1",
"requestGuid": "1e6cc63a-2d0d-4885-9c51-f9a35f113811",
"requestStatus": "Cancelled",
"timestampCreated": "2020-10-12T19:32:55.47",
"phoneNumber": "+250783008884",
"message": "Please send some money",
"amount": 10.00,
“externalReference”: “sasd23xfhaxfasdfa2342”,
"transactionStatus": "TransactionVerified"
}