PHP Classes

PHP Banking System API: API to implement banking transactions

Recommend this page to a friend!
  Info   View files Example   View files View files (23)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2023-11-06 (2 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 75 This week: 2All time: 10,117 This week: 45Up
Version License PHP version Categories
bank_api-php 1.0.0MIT/X Consortium ...8User Management, Web services, Finances, P...
Description 

Author

This package provides an API to implement banking transactions.

It provides an API to process requests to perform financial operations with bank user accounts stored in a server-side database.

Currently, it can perform operations with user accounts and financial operations like:

- List users

- Get specific user details

- Login on behalf of a user

- Withdraw an amount from a given user account

- Create a new user account

- Update user account details

- Delete user account

- Get user transactions

- Create a new transaction

Innovation Award
PHP Programming Innovation award nominee
November 2023
Number 9
Many sites now have a sort of accounting that keeps track of the balance of the users in terms of money values, like in a banking system.

This package implements an API that can perform banking operations with accounts of users that can have a money balance.

It can be helpful to implement a banking system in sites that manage the money balances of their users.

Manuel Lemos
Picture of Mateo
  Performance   Level  
Name: Mateo <contact>
Classes: 18 packages by
Country: Peru Peru
Innovation award
Innovation award
Nominee: 7x

Winner: 1x

Example

<?php

use BankApi\Db\Sql;
use
BankApi\Routes;
use
Mateodioev\HttpRouter\Router;
use
BankApi\Models\Error as ErrorResponse;
use
Mateodioev\HttpRouter\exceptions\{HttpNotFoundException, RequestException};

require
__DIR__ . '/vendor/autoload.php';

Sql::prepare(__DIR__);
$router = new Router;

Routes::register($router);

try {
   
$router->run();
} catch (
HttpNotFoundException $e) {
   
$router->send(ErrorResponse::json($e->getMessage() ?? 'Not found', $e->getCode() ?: 404));
} catch (
RequestException $e) {
   
$router->send(ErrorResponse::json($e->getMessage() ?? 'Server error', $e->getCode() ?: 500));
} catch (
Exception $e) {
   
$router->send(ErrorResponse::json('Unknown error', 500));
   
// $router->send(ErrorResponse::json($e->getMessage(), 500));
}


Details

Bank api

Ejemplo de una api rest simple para un banco

Endpoints

| Metodo | Endpoint | Descripcion |--------|----------|-----------| | GET | /api/docs | Documentacion en swagger | | GET | / | Alias de /api/docs | | GET | /api/users/ | Obtener todos los usuarios | | POST | /api/users/ | Crear un nuevo usuario | | GET | /api/users/{id} | Obtener un usuario por su id | | PUT | /api/users/{id} | Actualizar un usuario | | DELETE | /api/users/{id} | Eliminar un usuario | | POST | /api/users/login/ | Obtiene la informacion del usuario si los datos son correctos | POST | /api/users/{id}/withdraw | Retira una cantidad de un usuario | GET | /api/users/{id}/transactions | Obtener todas las transaciones de un usuario | GET | /api/transactions/{id} | Obtener un transacion por su ID | | POST | /api/transactions/ | Crear una nueva transacion

Instalacion

Docker

  1. Clona esta repositorio 
    git clone https://github.com/Mateodioev/bank_api-php.git
    cd bank_api-php
    
  2. Levanta el servicio con docker
    docker compose up -d
    
  3. Ve a la documentacion
    http://localhost:8080/api/docs
    
    > Puedes cambiar el puerto en el archivo .env

Manual

  1. Clona esta repositorio 
    git clone https://github.com/Mateodioev/bank_api-php.git
    cd bank_api-php
    
  2. Instalar la base de datos

    Crea un nuevo usuario de mysql y una db

    mysql -u root -p
    
    CREATE USER 'tu_usuario'@'localhost' IDENTIFIED BY 'contraseņa'; CREATE DATABASE bank_example; GRANT ALL PRIVILEGES ON bank_example . * TO 'tu_usuario'@'localhost'; FLUSH PRIVILEGES;

    Crea las tablas segun las tablas del archivo `db.sql`

  3. Crea los archivos de configuracion `.env` y `.htaccess`

    cp example.htaccess .htaccess
    cp example.env .env
    

    Luego edita el archivo .env segun tus datos


  Files folder image Files  
File Role Description
Files folder imagepublic (2 files)
Files folder imagesrc (2 files, 3 directories)
Accessible without login Plain text file .editorconfig Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file db.sql Data Auxiliary data
Accessible without login Plain text file docker-compose.yml Data Auxiliary data
Accessible without login Plain text file Dockerfile Data Auxiliary data
Accessible without login Plain text file example.env Data Auxiliary data
Accessible without login Plain text file example.htaccess Data Auxiliary data
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file readme.md Doc. Documentation
Accessible without login Plain text file thunder-collection_bankApi.json Data Auxiliary data

  Files folder image Files  /  public  
File Role Description
  Accessible without login Plain text file openapi.yaml Data Auxiliary data
  Accessible without login HTML file swagger.html Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imageControllers (3 files)
Files folder imageDb (2 files)
Files folder imageModels (4 files)
  Accessible without login Plain text file helpers.php Aux. Auxiliary script
  Plain text file Routes.php Class Class source

  Files folder image Files  /  src  /  Controllers  
File Role Description
  Plain text file baseController.php Class Class source
  Plain text file TransactionController.php Class Class source
  Plain text file UserController.php Class Class source

  Files folder image Files  /  src  /  Db  
File Role Description
  Plain text file Sql.php Class Class source
  Plain text file SqlException.php Class Class source

  Files folder image Files  /  src  /  Models  
File Role Description
  Plain text file Error.php Class Class source
  Plain text file Success.php Class Class source
  Plain text file Transaction.php Class Class source
  Plain text file User.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:75
This week:2
All time:10,117
This week:45Up