This Spring Boot application provides REST APIs for integrating with Klarna Payments API for online store payment processing.
- Create payment sessions
- Update payment sessions
- Get session details
- Create orders
- Cancel authorizations
- Generate customer tokens for future purchases
- Java 17
- Spring Boot 3.2.3
- Spring WebFlux for reactive API calls
- Lombok for reducing boilerplate code
- SpringDoc OpenAPI for API documentation
- Java 17 or higher
- Maven 3.6 or higher
Configure the application by updating the application.properties file:
# Klarna API configuration
klarna.api.url=https://api.klarna.com
klarna.api.username=your_api_username
klarna.api.password=your_api_password
klarna.api.merchant.id=your_merchant_idmvn clean installmvn spring-boot:runThe application will start on port 8080 with context path /api.
Once the application is running, you can access the API documentation at:
- Swagger UI: http://localhost:8080/api/swagger-ui.html
- OpenAPI JSON: http://localhost:8080/api/api-docs
POST /api/klarna/sessions- Create a new payment sessionGET /api/klarna/sessions/{sessionId}- Get details about a sessionPOST /api/klarna/sessions/{sessionId}- Update a session
POST /api/klarna/authorizations/{authorizationToken}/order- Create an orderDELETE /api/klarna/authorizations/{authorizationToken}- Cancel an authorizationPOST /api/klarna/authorizations/{authorizationToken}/customer-token- Generate a customer token
For more information about the Klarna Payments API, refer to the official documentation.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.