You can cancel a request if you no longer want the customer to do the payment. If a payment has already been made this endpoint will return an error.
Description
- Method: This is a POST 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/cancel
- 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.
Request Body
The request body is in JSON format and contains the following fields:
- requestMoneyGuid: This field contains a unique identifier that represents a specific request to which the QR code is associated.
import requests
import json
# Define the API endpoint URL
url = "https://uat-businessapi.spenn.com/api/Partner/transaction/request/cancel"
# Define the headers, including the Authorization header with your actual token
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer eyJhbG...NrEQ41w" # Replace with your actual token
}
# Define the request body as a Python dictionary
request_data = {
"requestMoneyGuid": "1e6cc63a-2d0d-4885-9c51-f9a35f113811"
}
# Convert the request data to JSON format
request_data_json = json.dumps(request_data)
# Make the POST request
response = requests.post(url, headers=headers, data=request_data_json)
# Check the response
if response.status_code == 200:
print("Request was successful. Response:")
print(response.json())
else:
print(f"Request failed with status code {response.status_code}.")
print("Response content:")
print(response.text)
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
public class APICallExample {
public static void main(String[] args) {
// Define the API endpoint URL
String url = "https://uat-businessapi.spenn.com/api/Partner/transaction/request/cancel";
// Define the request headers
String authorizationHeader = "Bearer eyJhbG...NrEQ41w"; // Replace with your actual token
String contentType = "application/json";
// Define the request body as a JSON string
String requestJson = "{\"requestMoneyGuid\": \"1e6cc63a-2d0d-4885-9c51-f9a35f113811\"}";
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
// Create the HTTP POST request
HttpPost request = new HttpPost(url);
// Set the request headers
request.addHeader("Content-Type", contentType);
request.addHeader("Authorization", authorizationHeader);
// Set the request body
request.setEntity(new StringEntity(requestJson));
// Execute the request
HttpResponse response = httpClient.execute(request);
// Check the response
if (response.getStatusLine().getStatusCode() == 200) {
System.out.println("Request was successful. Response:");
// Process and print the response here if needed
} else {
System.out.println("Request failed with status code " + response.getStatusLine().getStatusCode() + ".");
System.out.println("Response content:");
// Print the response content here if needed
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
// Define the API endpoint URL
const url = "https://uat-businessapi.spenn.com/api/Partner/transaction/request/cancel";
// Define the request headers
const headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer eyJhbG...NrEQ41w', // Replace with your actual token
};
// Define the request body as a JavaScript object
const requestData = {
requestMoneyGuid: "1e6cc63a-2d0d-4885-9c51-f9a35f113811",
};
// Make the POST request
fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(requestData),
})
.then(response => {
if (response.status === 200) {
return response.json();
} else {
console.error(`Request failed with
Sample Response
{
"$id": "1",
"requestId": "1e6cc63a-2d0d-4885-9c51-f9a35f113811",
“externalReference”: “sasd23xfhaxfasdfa2342”,
"status": "Cancelled"
}