Payment System is a service that handles client registration, payment processing, and basket management by iyzico integration. It utilizes MongoDB as its database and provides a RESTful API for interactions.
payment-system/
├── cmd/
│ └── server/
│ └── server.go
├── domain/
│ └── entity/
│ ├── basket.go
│ ├── client.go
│ └── payment.go
| └── authorization.go
| └── basket.request.go
| └── payment.response.go
| └── iyzico_payment.response.go
| └── iyzico_payment.request.go
| └── client.response.go
| └── client.request.go
├── pkg/
│ ├── config/
│ │ └── config.go
│ ├── controller/
│ │ ├── basket.go
│ │ ├── client.go
│ │ └── payment.go
│ ├── database/
│ │ └── database.go
│ ├── repository/
│ │ ├── basket.go
│ │ └── client.go
| | └── iyzico_authorization.go
| | └── iyzico.go
| ├── formatter/
| | ├── formatter.go
| ├── interfaces/
│ | ├── basket.go
│ | └── client.go
| | └── payment.go
│ ├── router/
│ │ └── router.go
│ └── usecase/
│ ├── basket.go
│ ├── client.go
│ └── payment.go
└── main.go- Go 1.16+
- Docker
- MongoDB
-
Clone the repository
git clone https://github.com/berkcansavur/payment-system.git cd payment-system -
Run MongoDB using Docker
docker run --name mongodb -d -p 27017:27017 mongo
or
docker compose up -d
-
Load environment variables Create a
.envfile in the root directory with the following content:DB_URI=mongodb://localhost:27017 IYZICO_API_KEY=your_api_key IYZICO_SECRET=your_secret IYZICO_BASE_URL=https://sandbox-api.iyzipay.com
-
Launch Json for Debugging
{ "version": "0.2.0", "configurations": [ { "name": "Debug Main", "type": "go", "request": "launch", "mode": "debug", "envFile": "${workspaceFolder}/.env", "program": "${workspaceFolder}/main.go" } ] } -
Run the application
go run main.go
POST /client/create- Create a new clientDELETE /client/{id}- Delete a clientPOST /client/{id}- Update a clientGET /client/{id}- Get client detailsGET /client/{id}/cards- Get client cardsPOST /client/{id}/cards- Add a card to clientDELETE /client/{id}/cards- Remove a card from clientPOST /client/{id}/checkout- Checkout with current active basket
POST /payment/create- Create a payment
POST /basket/create/{clientId}- Create a new basket for clientPOST /basket/abort/{id}- Delete basket with id
The application uses standard Go logger for logging. Logs are generated at various levels (info, error) to provide insights into the application flow and for debugging purposes.