Validate Subscription

Validate Subscription

Endpoint: /api/validate-subscription/{cr}


Introduction

The Validate Subscription endpoint enables partners to verify the subscription status of a customer based on their Commercial Registration (CR) number. This API helps ensure that your customers are actively subscribed before allowing access to premium services.

HTTP Method and URL

  • Method: GET
  • URL: /api/validate-subscription/{cr}
  • Headers:
    • X-API-KEY: your_api_key

Path Parameters

  • {cr} (string, required): The customer's commercial registration (CR) number. The CR number must be an alphanumeric string.

Example Request

To validate the subscription status of a customer with a CR number. your request will look like this:

Request:

GET /api/validate-subscription/1234567890 HTTP/1.1
Host: api.paylink.sa

Example Response

The API will return a JSON object with the subscription status:

Successful Response:

{
    "cr": "1234567890",
    "status": "subscribed"
}

Or

{
    "cr": "1234567890",
    "status": "unsubscribed"
}

Response Fields

  • cr: The Commercial Registration number provided in the request.
  • status: Indicates the subscription status of the customer. Possible values are:
    • "subscribed": The customer is currently subscribed.
    • "unsubscribed": The customer is not subscribed.

Error Responses

In case of errors, the API will return appropriate HTTP status codes and error messages.

  • Status Code: 400 Bad Request

    Response:

    {
        "error": "Invalid CR number format."
    }
    
  • Status Code: 404 Not Found

    Response:

    {
        "error": "Subscription not found for CR number."
    }