Skip to content

ashifakram/spring-payment-gateway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Payment Gateway

A minimal Spring Boot API that creates Stripe Checkout sessions for one-time payments.

Tech Stack

  • Java 17
  • Spring Boot 4.0.0
  • Stripe Java SDK 26.8.0
  • Maven

Features

  • REST endpoint to create a Stripe Checkout session
  • Simple amount-based payment flow
  • CORS enabled for all origins

Project Structure

  • src/main/java/com/example/springpayment/SpringPaymentGatewayApplication.java
  • src/main/java/com/example/springpayment/controller/PaymentController.java
  • src/main/resources/application.properties

Configuration

Option A: Use environment variable (recommended)

  1. In src/main/resources/application.properties:
    spring.application.name=spring-payment-gateway
    stripe.secret.key=${STRIPE_SECRET_KEY}
  2. In .env (ignored by git):
    STRIPE_SECRET_KEY=sk_test_...
    

Option B: Direct in properties (not recommended)

stripe.secret.key=sk_test_...

Running the App

./mvnw spring-boot:run

The app will start on http://localhost:8080.

API

Create Checkout Session

POST /api/payment/create-checkout-session

Request Body

{
  "amount": 5000
}

amount is in the smallest currency unit (e.g., paise for INR).

Response

{
  "url": "https://checkout.stripe.com/..."
}

Notes

  • Currency is set to INR in the controller.
  • Success and cancel URLs are currently hardcoded to:
    • http://localhost:3000/success
    • http://localhost:3000/cancel

Testing

./mvnw test

About

Spring Boot Stripe Checkout API for INR one‑time payments.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages