// payment.js

const Razorpay = require('razorpay');

// Create a Razorpay instance with your key ID and secret
const razorpay = new Razorpay({
  key_id: 'rzp_test_AetJF8P2SPF1Xy',
  key_secret: 'bAHpGZCluzEsXmkK95EcxPID'
});

// Function to create a Razorpay order
async function createOrder(amount) {
  try {
    const order = await razorpay.orders.create({
      amount: amount * 100, // Amount in paisa
       currency: 'INR',
      payment_capture: 1 // Automatically capture the payment when created
    });

    // Return the order ID
    return order.id;
  } catch (error) {
    throw new Error('Error creating Razorpay order');
  }
}

module.exports = { createOrder };
