This repository implements a Python client for the OpenFSC protocol.
It includes a runnable example that can be quickly started with Docker to test and try out the client behavior end-to-end.
The example implementation ships with a simulated POS adapter that acts as a virtual drop-in for a gas station, including simulated user traffic such as transactions and price changes.
The project uses Docker Compose and installs its Python dependencies in the openfsc-client-python container.
If you prefer Podman, you can use podman in place of docker for the commands below.
-
Copy
.env.exampleto.env:cp .env.example .env
-
Edit
.envand set your credentials:OPENFSC_SITE_ACCESS_KEY- Your site access key (UUID)OPENFSC_SITE_SECRET- Your site secretOPENFSC_URL(optional) - Server URL (defaults to sandbox)POS_ADAPTER_CLASS(optional) - Adapter plugin class (module_name.ClassName)
-
Start the container:
docker compose up -d --build
-
View logs:
docker compose logs -f openfsc-client-python
-
Stop the container:
docker compose down
If credentials are not set in .env, the client stays connected in unauthenticated mode and only responds to HEARTBEAT requests.
The repository includes Kubernetes manifests in k8s/.
-
Build the image locally:
docker build -t openfsc-client-python:local . -
If your cluster runs in a separate container runtime (for example
kind), load the image into the cluster:kind load docker-image openfsc-client-python:local
-
Create/update the Kubernetes secret from your root
.envfile:kubectl create secret generic openfsc-client-secret \ --from-env-file=.env \ --dry-run=client -o yaml | kubectl apply -f -This pulls variables from
.envintoopenfsc-client-secret. -
Deploy:
kubectl apply -k k8s
-
Check pod status:
kubectl get pods -l app=openfsc-client
-
Tail logs:
kubectl logs -f deployment/openfsc-client
-
Remove the demo:
kubectl delete -k k8s
-
(Optional) Remove the secret:
kubectl delete secret openfsc-client-secret
Run unit tests locally:
python3 -m unittest discover -s tests -vThe example setup includes a simulator (openfsc-client/example_pos_simulator.py) used by ExamplePosAdapter.
- Prices for gasoline and Diesel fuels are updated in the background at random intervals (roughly every 15–45 seconds).
- Price changes move up or down by a few cents.
- Products currently involved in an active fueling/payment flow are not changed.
- Traffic simulation runs for pumps
11,12, and13. - New ready-to-pay transactions are generated at random intervals (roughly every 10–60 seconds) on eligible pumps.
- If not picked for mobile payment, the transactions are auto-closed as “paid in-store”.
The client is designed to accept any implementation of PosAdapter.
- Built-in reference implementation:
ExamplePosAdapterinopenfsc-client/example_pos_adapter.py - Runtime plugin selection: set
POS_ADAPTER_CLASStomodule_name.ClassName
You can provide your own adapter by implementing the PosAdapter interface in openfsc-client/pos_adapter.py and wiring it into openfsc-client/main.py.
Example:
export POS_ADAPTER_CLASS=example_pos_adapter.ExamplePosAdapterCustom adapter example:
export POS_ADAPTER_CLASS=my_company.adapters.StorePosAdapterOr in .env:
POS_ADAPTER_CLASS=my_company.adapters.StorePosAdapter