The Fakepay API is a REST API based roughly on an API from a common payment provider.
The following information applies to all Fakepay API requests and responses.
All request URLs in the Fakepay API are relative to the URL https://cs3660.xyz/fakepay. There is no separate sandbox URL because the entire Fakepay API is a sandbox.
All requests to the Fakepay API require authentication. The API recognizes basic authentication (username and password) and bearer token authentication. All responses are given in JSON with a Content-Type header of application/json. All requests except the authentication request require application/json content in the body.
There is only one recognized workflow for the Fakepay API, which is as follows:
The Fakepay API is designed to handle each request asynchronously. Authorization tokens last 9 hours (32,400 seconds). Order ids last 3 hours (10,800 seconds).
Your Fakepay username and password at https://cs3660.xyz/fakepay is the same as your issued Cpanel username and password for your Webhost.
Initial authentication uses a basic token, "username:password", base64 encoded. The body of an initial authentication requests must be "grant_type=client_credentials". Although the request is not sent in JSON, the response is sent in JSON.
All authentication requests are to be sent to the following URL
CURL Example Request
Expected Response
Python HTTPX Example
All requests subsequent to initial authentication require bearer token authorization. The bearer token must match the "acces_token" returned from the server. The authorization header must be given in the following form:
Python HTTPX Example:
All payment submissions must begin with an order. A unique order id is generated. Once this order id is received, it must be used to capture payment with card information.
All order requests are to be sent to the following URL
Order requests must be accompanied by an appropriate authorization header (see above).
A subsequent GET request may be sent to verify order status. Orders expire after 3 hours. Order expiration information is managed server-side.
All capture requests are to be sent to a URL in the following form:
For example:
Capture requests must be accompanied by an appropriate authorization header (see above). The order id must be the one from the "id" field given by the Fakepay API server.
Fakepay requires a 16-digit card number, an expiration date in the form YYYY-MM, a CVV security code appropriate to the card type, and an amount that matches the order amount. Fakepay will validate the card number using the standard checksum algorithm. VISA, MASTERCARD, DISCOVER, and AMERICAN EXPRESS (AMEX) cards are recognized. If any of the required data is missing or the card number fails checksum or is missing required data, the Fakepay API will give a reject response.
If the card passes checksum, the Fakepay API will pretend it communicated with the payor's bank. It will choose randomly whether to give a success or decline response. The choice will be based on random number generation, aiming for a 4:1 ratio (4 success to 1 decline).
In the following example, payment was successful:
In the following example, payment was rejected due to an invalid amount:
In the following example, payment was rejected due because the card number did not pass checksum:
In the following example, payment was declined by the cardholder's bank: