This website uses cookies to ensure you get the best experience on our website.

Skip to content
LOGO
  • Company

    About IGNEK

    Learn about our story and our mission.

    Careers

    We're hiring!

    We always looking for talented peoples. Join our team!

    Blogs

    The latest industry news, updates and info.

    Case Studies

    Take a closer look at the projects we've delivered

    Webinar

    Watch our latest organized webinar

    Get in touch with our HR team

    • hr@ignek.com
    • +91 93284 95160
    • Ahmedabad, Gujarat, India – 382470
  • Services

    Enterprise Portal Development

    Custom Enterprise Portal Development for flawless Solutions

    Dedicated Development Team

    Expand Teams, Optimize Development with Our Expertise

    Back-end Development

    Empowering your digital presence with robust backend development expertise

    Front-end Development

    Crafting engaging user experiences through expert frontend development

    Digital Transformation

    Embrace digital transformation by modernizing process

    SaaS Development

    Transform your business with SaaS Innovative Solutions

    Technologies

    Liferay Services

    Development & Customization

    Theme

    Upgradation

    Migration

    Proof of Concept

    Performance Tunning

    Architecture

    Support & Maintenance

    E-commerce

    Expert Advice

    React Services

    Enterprise Development

    Custom Application

    Single Page Application

    Architecture

    API Integration

    Migration

    Consulting

    Maintenance & Support

    Spring Boot Services

    Web Service

    MVC Web Development

    API Integration

    Security

    Migration

    Microservices

    Support & Maintenance

    AEM Services

    Consulting Service

    Site Development

    Migration & Upgradation

    Integration

    Maintenance & Support

    Custom Solutions

    Content Management

    Team Augementation

  • Solution

    Ready for digital excellence

    In our rapidly evolving world, businesses are always on the lookout for fresh ways to improve their operations and connect with their audiences.

    Contact US

    Solutions

    SaaS : Software As A Service

    Transforming industries through cutting edge SaaS solutions.

    Customer Portal : Boost Business Productivity

    Streamline operations and enhance productivity with our Customer Portal solution.

    Liferay Based Intranet Portal

    Internal portal for company communication, collaboration and resources

    Integration

    Matomo Integration with Liferay

    Integrate Matomo to enable user interactions seamlessly.

    Microsoft Teams integration with Liferay

    Integrate to enable seamless collaboration, messaging within your portal.

    Jira Integration With Liferay

    Optimizes business operations by integrating with Jira.

  • Hire Us

    Liferay

    Get expert Liferay developers for seamless portal solutions.

    React JS

    Get expert ReactJS developers for dynamic web solutions.

    Web Developer

    Get custom web solutions from IGNEK's expert developers.

    Spring Boot

    Get top-notch Spring Boot developers for your project success!

    Healthcare

    Get top Healthcare Developers for cutting-edge medical software.

    MERN Stack

    Get expert MERN developers from IGNEK for custom, innovative project solutions.

    Why Hire Developers From IGNEK ?

    • Certified Developer
    • Transparent Communication
    • Flexible Hiring Modals
    • Fully Signed NDA
    • Cost Effective
    • Easy Exit Policy

    Get in touch with our Sales team

    • sales@ignek.com
    • +91 6351576580
    • info@ignek.com
    • Ahmedabad, Gujarat, India – 382470
SCHEDULE CALL
  • COMPANY
    • About
    • Case Studies
    • Blogs
    • Career
    • Webinar
  • SERVICES
    • Enterprise Portal Development
    • Dedicated Development Team
    • Back-end Development
    • Front-end Development
    • Digital Transformation
    • SaaS Development
  • SOLUTION
    • Customer Portal:  Boost Business Productivity
    • SaaS : Software as a Service
    • Liferay Based Employee Intranet Portal
  • TECHNOLOGY
    • Liferay Services
      • Liferay Development and Customization
      • Liferay Theme Development Service
      • Liferay DXP 7.4 Upgrade
      • Liferay Migration
      • Liferay Proof Of Concept
      • Liferay Performance Tuning
      • Liferay Architecture Design Service
      • Liferay Support And Maintenance Service
      • Liferay Ecommerce Development
      • Liferay Expert Advice
    • ReactJS Services
      • ReactJS Enterprise Application Development
      • ReactJS Custom Application Development
      • ReactJS Single Page Application Development (SPA)
      • ReactJS Applications Architecture
      • ReactJS API Integration
      • ReactJS Migration
      • ReactJS Consulting
      • ReactJS Maintenance and Support
    • Spring Boot Services
      • Spring Boot Web Development Service
      • Spring MVC Web Development
      • Spring Boot API Integration Service
      • Spring Boot Security
      • Spring Boot Migration Service
      • Spring Boot Microservices
      • Spring Boot Support & Maintenance Service
    • AEM Development Services
      • AEM Consulting Services
      • AEM Site Development
      • AEM Migration & Upgradation
      • AEM Integration Services
      • AEM Maintenance & Support
      • AEM Content Management
      • Custom AEM Solutions
      • AEM Team Augmentation
  • INTEGRATION
  • HIRE US
    • Hire Liferay Developer
    • Hire ReactJS Developer
    • Hire Spring Boot Developer
    • Hire Healthcare Developer
    • Hire Web Developer
    • Hire MERN Stack Developer
  • CONTACT US
  • Company

    About IGNEK

    Careers

    We're hiring!

    Blogs

    Case Studies

    Webinar

    Get in touch with our HR team

    • hr@ignek.com
    • +91 93284 95160
    • Ahmedabad, Gujarat, India – 382470
  • Services

    Enterprise Portal Development

    Dedicated Development Team

    Back-end Development

    Front-end Development

    Digital Transformation

    SaaS Development

    Technologies

    Liferay Liferay Services
    • Development & Customization
    • Theme
    • Upgradation
    • Migration
    • Proof of Concept
    • Performance Tuning
    • Architecture
    • Support & Maintenance
    • E-commerce
    • Expert Advice
    React React Services
    • Enterprise Development
    • Custom Application
    • Single Page Application
    • Architecture
    • API Integration
    • Migration
    • Consulting
    • Maintenance & Support
    Spring Boot Spring Boot Services
    • Web Service
    • MVC Web Development
    • API Integration
    • Security
    • Migration
    • Microservices
    • Support & Maintenance
    AEM AEM Services
    • Consulting Service
    • Site Development
    • Migration & Upgradation
    • Integration
    • Maintenance & Support
    • Custom Solutions
    • Content Management
    • Team Augmentation
  • Solution

    Ready for digital excellence

    In our rapidly evolving world, businesses are always on the lookout for fresh ways to improve their operations and connect with their audiences.

    Contact US

    Solutions

    SaaS : Software As A Service

    Customer Portal : Boost Business Productivity

    Liferay Based Intranet Portal

    Integration

    Matomo Integration with Liferay

    Microsoft Teams integration with Liferay

    Jira Integration With Liferay

  • Hire Us

    Liferay

    React JS

    Web Developer

    Spring Boot

    Healthcare

    MERN Stack

    Why Hire Developers From IGNEK ?

    • Certified Developer
    • Transparent Communication
    • Flexible Hiring Modals
    • Fully Signed NDA
    • Cost Effective
    • Easy Exit Policy

    Get in touch with our Sales team

    • sales@ignek.com
    • +91 6351576580
    • IGNEK
    • Ahmedabad, Gujarat, India – 382470
  • SCHEDULE CALL

Payment Gateway Integration with Spring Boot

  • Spring Boot
  • December 23, 2024

Share On :

Introduction

In this blog I write about payment as a gateway into springboot applications. Now digital payment is mostly used as a world wide and integrated payment gateway into your application to make your application efficient and fastest payment. We all know that many services provide online payment  fastest and safest.

In this blog, I used razorpay for integration. There are many services like paytm, paypal for payment gateway integration and make your payment safe and fast.

What is payment gateway

A payment gateway is a technology platform that provides services to businesses that accept, manage and handle payment from the customer to business. Payment gateway processes the managed payment flow. It is a link between business and customer. There are many payment gateway API providers that provide your application secure data transfer solutions.

Prerequisites
  • Java 17
  • Maven 
  • Spring Boot Development Environment (here IntelliJ IDEA)
  • Payment gateway platform account (Here razorpay account)
Set up Payment gateway platform (razorpay)
  • Sign up on razorpay Account.
  • Complete account set up 
  • Generate API keys like publish key and secret key.
  • Secure your API keys.
Steps to Integrate a Payment Gateway with Spring Boot Application

Step 1 : Add razorpay dependency into your application.

				
					 <dependency>
			<groupId>com.razorpay</groupId>
			<artifactId>razorpay-java</artifactId>
			<version>1.4.3</version>
		</dependency>

				
			

Step 2 : Configure Application Properties

Add the razorpay credentials into the  application.properties:

				
					payment.gateway.secretKey=sk_test_1234567890
payment.gateway.publishableKey=pk_test_1234567890

				
			

Step 3 : Write service for creating order

In this service we integrated razorpay Rest API. It initializes the razorpay client using your credentials. And razor pay clients provide functionality to create orders.

				
					import com.razorpay.RazorpayClient;
import org.json.JSONObject;
@Service
public class RazorpayService {
    private RazorpayClient razorpayClient;

   @Value("${payment.gateway.secretKey}")
    private String secretKey;

    @Value("${payment.gateway.publishableKey}")
    private String publishableKey;


    public RazorpayService() {
        try {
            razorpayClient = new RazorpayClient(secretKey, publishableKey);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * This method creates a Razorpay order and returns the order details.
     * 
     * @param amount the order amount in INR (multiplied by 100 to convert into paise)
     * @return JSON string containing the order details, including order ID
     */
    public String createOrder(int amount) {
        JSONObject options = new JSONObject(); // Prepare order options
        options.put("amount", amount * 100);   // Convert amount to paise (Razorpay accepts only paise)
        options.put("currency", "INR");       // Specify currency (INR)
        options.put("receipt", "order_rcptid_11"); // Custom receipt identifier for tracking orders
        options.put("payment_capture", 1);    // Automatically capture payments

        try {
            // Call Razorpay's Orders API to create an order
            return razorpayClient.orders.create(options).toString();
        } catch (Exception e) {
            e.printStackTrace(); // Handle exceptions
            return null;
        }
    }
}

				
			

Razerpay client : By using constructor we enable the communication between our application to the razorpay server using our credentials.

Create order method is take data like amount and currency and called razorpay API and return order detail json as sting with unique order id.

Step 4 : define controller 

Define the endpoint in the controller that will invoke the created by the front end to order functionality.

				
					 * API endpoint to create an order in Razorpay.
 *
 * @param amount the order amount in INR (to be converted to paise by the service)
* @return ResponseEntity containing the created order details or an error message */
  
@PostMapping("/create-order")
    public ResponseEntity<?> createOrder(@RequestParam int amount) {
        try {
            String orderResponse = razorpayService.createOrder(amount);
            if (orderResponse != null) {
                return ResponseEntity.ok(orderResponse);
            } else {
                return ResponseEntity.badRequest().body("Failed to create Razorpay order.");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseEntity.status(500).body("An error occurred while creating the order.");
        }
    }

				
			

Step 5 : Verify Payment

Create a service to verify payment. To ensure payment is secure razorpay provides verify services.

				
					public boolean verifyPayment(String orderId, String paymentId, String razorpaySignature) {
  String payload = orderId + '|' + paymentId;
  try {
    return Utils.verifySignature(payload, razorpaySignature, razorpayConfig.getSecret());
  } catch (Exception e) {
    e.printStackTrace();
    return false;
  }
}

				
			

Step 5 : Test the API with  tools like postmen

Here I test the endpoint using postmen.

response

In the response you will get order detail json as sting with uniq by order is.

By this order ID handles payment on the client side.

You can also see the log of the order in the razorpay dashboard.

razorpay_dashboard
Conclusion

Razepay integration with springboot application it’s a straightforward process. It is mostly used in India for its simple and secure process.You can easily set up payment processes, create and verify order and payment into your application. In this blog you get the step by step process of integration of razor pay.

Explore Our Services

Discover how we can help your business thrive, whether you’re running a small startup, an SME, or a large enterprise. We’re here to understand your unique needs and goals, offering the expertise and resources to support your journey to success.

Stay informed about our Spring Boot services and updates by subscribing to our newsletter—just fill in the details below to subscribe.

Loading
Loading...

Related Blogs

October 17, 2023
Enhance program organization and structure through Spring Boot Custom Annotations.
Custom Annotations in Spring Boot
June 6, 2024
CRUD Restful APIs with Spring Boot
CRUD Restful APIs with Spring Boot
June 7, 2024
Spring Boot With Swagger Integration
Spring Boot With Swagger Integration
Loading...

Featured Projects Portfolios

June 19, 2024
Music License Management Portal _ Onboarding & Data Integrity
Music License Management Portal : Onboarding & Data Integrity
November 25, 2024
Restaurant Promotion Platform Maximizing Offer Uptake and Revenue
Restaurant Promotion Platform : Maximizing Offer Uptake and Revenue
November 29, 2024
Public Enterprise Website for Laundry Services
Public Enterprise Website for Laundry Services

Digital Solutions for Your Business with IGNEK

4.9

5.0

5.0

5.0

LOGO

Making the world a better place through constructing elegant hierarchies

COMPANY

  • About
  • Career
  • Case Study
  • Blogs

SERVICES

  • Enterprise Portal Development
  • Dedicated Development Team
  • Back-end Development
  • Front-end Development
  • Digital Transformation
  • SaaS Development

HIRE US

  • Liferay
  • Spring Boot
  • ReactJS
  • Healthcare
  • MERN Stack
  • AEM

CONTACT

  • info@ignek.com
  • info@ignek.com
SALES
  • sales@ignek.com
  • (+91) 635 157 6580
CAREER
  • hr@ignek.com
  • (+91) 932 849 5160
  • E 910-912, Ganesh Glory 11, Jagatpur Road, SG Highway, Ahmedabad, Gujarat - 382470

© 2018-2025 IGNEK, Inc. All rights reserved

Linkedin Facebook X-twitter Instagram