Integration Guides
Error Codes

Error Codes

This document provides a comprehensive list of error codes that the Waga API may return, along with their meanings and recommended actions.

Error Codes and Descriptions

Error CodeStatus CodeMessageDescriptionRecommended Action
400400Bad RequestThe request could not be processed due to invalid input.Verify the input data and ensure all required fields are provided correctly.
401401UnauthorizedAuthentication failed due to an invalid or missing API key.Provide a valid API key in the request header.
403403ForbiddenAccess to the requested resource is forbidden.Ensure you have the necessary permissions to access the resource.
404404Not FoundThe requested endpoint or resource could not be found.Check the URL and try again.
500500Internal Server ErrorAn error occurred on the server side.Try again later or contact support if the problem persists.

Detailed Descriptions and Callouts

400 Bad Request

{
  "code": 400,
  "message": "Bad request"
}
⚠️

Bad Request: It seems like there was an issue with your request. Please check the input data and ensure all required fields are provided correctly.

401 Unauthorized

{
  "code": 401,
  "message": "Unauthorized"
}

Unauthorized: Your API key is invalid or missing. Please provide a valid API key in the request header.

403 Forbidden

{
  "code": 403,
  "message": "Forbidden"
}
🚫

Forbidden: You do not have permission to access this resource. Please ensure you have the necessary permissions.

404 Not Found

{
  "code": 404,
  "message": "Not found"
}
🔍

Not Found: The requested endpoint or resource could not be found. Please check the URL and try again.

500 Internal Server Error

{
  "code": 500,
  "message": "Internal server error"
}
💥

Internal Server Error: We encountered an unexpected error on our side. Please try again later or contact support if the problem persists.

Example Usage

To handle error responses effectively, you can implement error handling in your code based on the returned error codes. Here's an example in JavaScript:

fetch("https://api.wagapay.net/register", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "apiKey": "YOUR_API_KEY",
  },
  body: JSON.stringify({
    business_name: "Apple Inc.",
    amount: "1200.00",
    currency: "USD",
    order_number: "123456789",
    return_url: "https://apple.com",
    reason: "Macbook Pro M1 13 purchase",
    customer_phone: "0923456789",
    expires_after: 1,
  }),
})
  .then(response => {
    if (!response.ok) {
      return response.json().then(error => {
        throw new Error(error.message);
      });
    }
    return response.json();
  })
  .then(data => {
    console.log("Success:", data);
  })
  .catch(error => {
    console.error("Error:", error.message);
    // Handle specific error codes here
    if (error.message === "Unauthorized") {
      // Take action for unauthorized error
    }
    // Add more conditions as needed
  });

By using this approach, you can ensure that your application responds appropriately to different error conditions, providing a better user experience and easier debugging.