Skip to content

rknow/payment-processor

Repository files navigation

Simple payment processor

Clone and Install

git clone https://github.com/rknow/payment-processor.git

cd payment-processor

composer install

Configure .env

Choose your payment gateway

PAYMENT_GATEWAY=PayPal # PayPal | Stripe | Mock

For MockPayment only

MOCK_SHOULD_SUCCEED=true

Run the CLI Demo

php run.php

Example output:

=== Payment Processor (Env + PHP-DI) ===

[LOG] PayPal processing payment of $150 [LOG] PayPal refunding $75

=== Done ===

Switching gateways instantly by editing .env

PAYMENT_GATEWAY=Stripe

🧪 Testing vendor/bin/phpunit --testdox

Dockerized

docker build -t payment-processor .

docker run --rm payment-processor vendor/bin/phpunit --testdox

Docker Usage

Build & Run

docker compose up --build

Override environment variables

docker run -e PAYMENT_GATEWAY=Stripe payment-processor

Or use your .env file:

docker run --env-file .env payment-processor

⚡ Continuous Integration (GitHub Actions)

The included workflow .github/workflows/ci.yml will:

1. Build the Docker image

2. Run PHPUnit tests inside the container

3. Execute on each push or pull_request to the main branch

You can view your test status under GitHub → Actions.

🛠️ Technologies Used

Category Tool
Language PHP 8.3
Dependency Injection PHP-DI
Environment Config vlucas/phpdotenv
Unit Testing PHPUnit
Containerization Docker & Docker Compose
CI/CD GitHub Actions

🎨 Concepts Demonstrated

Concept Example
Interface PaymentInterface defines the contract
Trait LoggerTrait for reusable logging
Dependency Injection PaymentProcessor depends on PaymentInterface
Testing MockPayment simulates success/failure
Configuration .env controls which gateway is used
Automation CI pipeline builds and tests via Docker

Future Enhancements

  • Add REST API using Slim or Laravel
  • Database-backed transaction logs
  • Code coverage reports in CI
  • Docker Hub publishing

License

MIT License © 2025 — Free to use, learn, and modify.

Show Your Support

If you find this useful, please star ⭐ the repo or fork it to learn modern PHP project structure and CI integration.

About

Simple dockerized payment processor with a CI/CD pipeline

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors