/lovable-integrations

Lovable and Adyen integration: Step-by-Step Guide 2025

Unlock seamless payment solutions by integrating Lovable with Adyen. Follow our step-by-step guide for secure, efficient checkout integration.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to integrate Lovable with Adyen?

 

Setting Up Dependencies

 

Since Lovable doesn’t provide a terminal, you must manually add the necessary dependencies by creating a file named package.json in the project root (if it doesn’t exist) with the following content. This registers Adyen’s checkout library and Axios for HTTP calls:


{
  "dependencies": {
    "adyen-checkout": "latest",
    "axios": "latest"
  }
}

Place this file in the root directory of your Lovable project so that when the project initializes, these dependencies are recognized.

 

Creating the Adyen Configuration File

 

Next, create a new TypeScript file named adyenConfig.ts in a new folder called config (or in the root if you prefer). This file will hold the Adyen API keys and merchant information:


export const adyenConfig = {
  apiKey: 'YOURADYENAPI_KEY',
  merchantAccount: 'YOURMERCHANTACCOUNT',
  environment: 'test' // Change to 'live' when ready for production
};

Ensure you replace YOURADYENAPIKEY and YOURMERCHANT_ACCOUNT with your actual Adyen account details.

 

Creating the Adyen Integration Service

 

Now, create a new file called adyenService.ts in a folder named services. This service encapsulates the logic for communicating with the Adyen API. Insert the following TypeScript code into that file:


import axios from 'axios';
import { adyenConfig } from '../config/adyenConfig';

interface PaymentSessionResponse {
  sessionData: string;
  // Add further fields returned by Adyen if needed
}

/**
- Creates a new payment session with Adyen.
- 
- @param amount - The payment amount in minor units (e.g., cents)
- @param currency - The currency code (e.g., EUR, USD)
- @returns A promise that resolves with the payment session data
 */
export async function createPaymentSession(amount: number, currency: string): Promise<PaymentSessionResponse> {
  const requestData = {
    amount: {
      value: amount,
      currency: currency
    },
    merchantAccount: adyenConfig.merchantAccount,
    reference: 'ORDER-' + new Date().getTime(), // Example reference
    returnUrl: 'https://yourdomain.com/checkout/result'
  };

  try {
    const response = await axios.post(
      (adyenConfig.environment === 'live' 
        ? 'https://live-checkout-test.adyen.com/v68/sessions' 
        : 'https://checkout-test.adyen.com/v68/sessions'),
      requestData,
      {
        headers: {
          'Content-Type': 'application/json',
          'X-API-Key': adyenConfig.apiKey
        }
      }
    );
    return response.data;
  } catch (error) {
    throw new Error('Unable to create payment session: ' + error);
  }
}

Place this file under a new folder called services so that you can manage your service integrations separately.

 

Integrating the Service into Your Main Code

 

Locate the main file where your checkout or payment logic exists. In Lovable projects this might be your main TypeScript file for handling business logic. Insert the following code snippet at the beginning of that file to import and use the Adyen service:


import { createPaymentSession } from './services/adyenService';

// This function is an example of how to trigger the Adyen checkout process.
async function initiateCheckout() {
  try {
    // Example: setting an amount of 1000 (e.g., €10.00 if using cents) in EUR
    const sessionResponse = await createPaymentSession(1000, 'EUR');
    console.log('Payment session created successfully:', sessionResponse);
    
    // Insert logic to forward sessionResponse.sessionData to Adyen Checkout UI
    // For example, you may call AdyenCheckout initialization code here.
    
  } catch (error) {
    console.error('Error during checkout:', error);
  }
}

// Bind the initiateCheckout function to your UI event, for instance:
document.getElementById('checkoutButton')?.addEventListener('click', initiateCheckout);

Ensure that this code is inserted where your project handles checkout events. The checkoutButton element should exist in your UI so users can trigger the payment process.

 

Adding Adyen Checkout to Your Front-End

 

If your Lovable project includes a front-end where you need to display the Adyen Checkout, add the following snippet to your HTML file where you include your JavaScript. Insert it inside your HTML’s <head> or right before the closing </body> tag:


<!-- Include Adyen Checkout Library via CDN -->
<script src="https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/5.24.0/adyen.js"></script>
<link rel="stylesheet" href="https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/5.24.0/adyen.css" />

Adjust the library version or environment URL as needed. This snippet ensures that the Adyen Checkout UI resources are available to your project.

 

Final Integration Steps

 

Once the above files and code snippets are added, your integration is complete. Review the following points:

  • Ensure that the package.json file is placed at the root so that dependency management recognizes the added libraries.
  • The adyenConfig.ts file must contain your real Adyen API credentials.
  • The adyenService.ts file encapsulates all API calls to Adyen and can be expanded if further endpoints are needed.
  • Include the Adyen Checkout CDN snippet in your HTML to load the checkout resources in the browser.
  • Integrate the trigger function (initiateCheckout) into your event handlers so that users can initiate the payment process.

With these steps, your Lovable project is now integrated with Adyen using TypeScript.

Still stuck?
Copy this prompt into ChatGPT and get a clear, personalized explanation.

This prompt helps an AI assistant understand your setup and guide you through the fix step by step, without assuming technical knowledge.

AI AI Prompt

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022