A flexible payment gateway integration system that supports multiple payment providers with a clean, extensible architecture.
- Docker
- Docker Compose
- Clone this repository
- Make sure the
docker/phpdirectory exists - Copy the
.env.examplefile to.envand update the values as needed - Run
docker-compose up -dto start the containers - Access the PHP container:
docker exec -it payment_php bash - Install dependencies:
composer install - Access the API at http://localhost:8080/api/payment/process
payment-gateway/
├── config/
│ └── certificates/ # SSL certificates for API authentication
│ ├── example_client_tls.cer
│ └── example_client_tls.key
├── src/
│ ├── DTO/ # Data Transfer Objects
│ │ ├── PaymentRequest.php
│ │ └── PaymentResponse.php
│ ├── Exception/ # Custom exception classes
│ │ └── BankingGatewayException.php
│ ├── Gateway/ # Payment gateway implementation
│ │ ├── BankingGatewayLauncher.php
│ │ ├── PaymentConnector.php
│ │ ├── PaymentMethodIDs.php
│ │ └── PaymentMethods/ # Specific payment method implementations
│ │ └── ING/ # ING Open Banking implementation
│ │ ├── IngOpenBankingPaymentConnector.php
│ │ ├── IngPaymentRequestBuilder.php
│ │ ├── IngPaymentSender.php
│ │ └── IngPaymentResponseProcessor.php
│ └── Service/ # Service classes
│ └── Logger/ # Logging services
│ └── PaymentLoggerService.php
├── tests/ # Test suite (mirrors src structure)
│ └── Gateway/
│ └── PaymentMethods/
│ └── ING/
│ ├── IngOpenBankingPaymentConnectorTest.php
│ ├── IngPaymentRequestBuilderTest.php
│ ├── IngPaymentSenderTest.php
│ └── IngPaymentResponseProcessorTest.php
└── var/ # Runtime files
└── log/ # Log files
└── payments/
└── ing/ # ING payment logs
The payment gateway system follows a modular, layered architecture:
-
Launcher Layer:
BankingGatewayLauncherserves as the entry point, handling payment requests and selecting the appropriate connector. -
Connector Layer: Connectors like
IngOpenBankingPaymentConnectorimplement thePaymentConnectorinterface and orchestrate the payment flow for specific payment providers. -
Processing Layer: Each connector delegates to specialized components:
IngPaymentRequestBuilder: Builds payment requests according to API specificationsIngPaymentSender: Handles API communication with the payment providerIngPaymentResponseProcessor: Processes API responses into standardizedPaymentResponseobjects
-
Support Services:
PaymentLoggerService: Provides specialized logging for payment transactions
To add a new payment method:
- Create a new folder under
src/Gateway/PaymentMethods/for your provider - Create implementation classes following the Single Responsibility Principle:
- A main connector class implementing
PaymentConnector - Helper classes for request building, API communication, and response processing
- A main connector class implementing
- Add the payment method ID to
PaymentMethodIDs.php - Update
BankingGatewayLauncher.phpto handle the new payment method
You can test the API endpoints using command-line tools like curl:
curl -X GET http://localhost:8080/api/payment/process# Execute tests from outside the container
docker exec payment_php bin/phpunit
# Or access the container first
docker exec -it payment_php bash
bin/phpunit- GET
/api/payment/process- Process a payment
Designed for multi-method banking integration; at the moment, only the ING method is implemented.
- Symfony 6.4 framework
- RESTful API architecture
- Docker containerization