Skip to content

Latest commit

 

History

History
128 lines (98 loc) · 2.76 KB

File metadata and controls

128 lines (98 loc) · 2.76 KB

Cybrid Payment Backend

Express.js backend server for Cybrid payment integration.

Features

  • RESTful API for Cybrid payment operations
  • TypeScript for type safety
  • OAuth2 authentication with Cybrid API
  • Customer and account management
  • Transaction processing
  • Secure environment configuration

Prerequisites

  • Node.js >= 18.0.0
  • npm or yarn
  • Cybrid API credentials

Installation

npm install

Configuration

  1. Copy the example environment file:

    cp .env.example .env
  2. Configure your environment variables in .env:

    PORT=5000
    NODE_ENV=development
    CYBRID_CLIENT_ID=your_client_id
    CYBRID_CLIENT_SECRET=your_client_secret
    CYBRID_BANK_GUID=your_bank_guid
    CYBRID_OAUTH_TOKEN_URL=https://auth.sandbox.cybrid.app/oauth/token
    CYBRID_API_BASE_URL=https://api.sandbox.cybrid.app
    CYBRID_SCOPE=openid
    ALLOWED_ORIGINS=http://localhost:5173

Available Scripts

Development

npm run dev

Starts the development server with hot reload using ts-node-dev.

Build

npm run build

Compiles TypeScript to JavaScript in the dist folder.

Production

npm start

Runs the compiled JavaScript from the dist folder.

Lint

npm run lint

Runs ESLint on TypeScript files.

Project Structure

backend/
├── src/
│   ├── config/       # Configuration files
│   ├── cybrid/       # Cybrid SDK integration
│   ├── db/           # Database/storage layer
│   ├── routes/       # API routes
│   └── index.ts      # Application entry point
├── .env.example      # Example environment variables
├── package.json      # Dependencies and scripts
└── tsconfig.json     # TypeScript configuration

API Endpoints

The backend exposes various endpoints for:

  • Customer management
  • Account operations
  • Payment processing
  • Transaction history

See the route definitions in src/routes/ for detailed API documentation.

Dependencies

Production

  • @cybrid/cybrid-api-bank-typescript - Cybrid Bank API SDK
  • @cybrid/cybrid-api-id-typescript - Cybrid Identity API SDK
  • express - Web framework
  • axios - HTTP client
  • dotenv - Environment variable management
  • helmet - Security middleware
  • cors - Cross-origin resource sharing
  • morgan - HTTP request logger

Development

  • typescript - TypeScript compiler
  • ts-node-dev - TypeScript execution with hot reload
  • @types/* - Type definitions

Security

  • Environment variables for sensitive credentials
  • Helmet middleware for secure HTTP headers
  • CORS configuration for allowed origins
  • OAuth2 token management

Error Handling

The application uses express-async-errors for automatic async error handling in routes.

License

ISC