Fakepay API Documentation

The Fakepay API is a REST API based roughly on an API from a common payment provider.

General Information

The following information applies to all Fakepay API requests and responses.

Base URL

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.

Requests and Responses

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.

Workflow

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).

Username and Password

Your Fakepay username and password at https://cs3660.xyz/fakepay is the same as your issued Cpanel username and password for your Webhost.

Authentication Request and Response

Initial Authentication

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.

Authentication URL

All authentication requests are to be sent to the following URL

Authentication Format

CURL Example Request

Expected Response

Python HTTPX Example

Subsequent Requests

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:

Order Request and Response

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.

Order URL

All order requests are to be sent to the following URL

Order requests must be accompanied by an appropriate authorization header (see above).

Order Request Format

Order Response Format

A subsequent GET request may be sent to verify order status. Orders expire after 3 hours. Order expiration information is managed server-side.

Capture Request and Response

Capture URL

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.

Capture Request Format

Capture Request Validation

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.

Bank Validation

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).

Capture Response Format (Success)

In the following example, payment was successful:

Capture Response Format (Reject Due to Invalid Amount)

In the following example, payment was rejected due to an invalid amount:

Capture Response Format (Reject Due to Invalid Card Number)

In the following example, payment was rejected due because the card number did not pass checksum:

Capture Response Format (Reject Due to Bank Decline)

In the following example, payment was declined by the cardholder's bank: