Skip to content

when pay_later flag is passed, we do not need to generate order_ids#204

Open
vendz wants to merge 1 commit into
devfrom
refactor/stop-orderid-generations
Open

when pay_later flag is passed, we do not need to generate order_ids#204
vendz wants to merge 1 commit into
devfrom
refactor/stop-orderid-generations

Conversation

@vendz
Copy link
Copy Markdown
Member

@vendz vendz commented Sep 23, 2025

No description provided.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @vendz, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a crucial enhancement to the booking process by ensuring that payment order IDs are only generated when an immediate payment is required. This change streamlines the 'pay later' booking flow, preventing the creation of unnecessary payment orders and improving the efficiency of the system. Additionally, several code formatting adjustments have been made to enhance readability and maintainability across key controller and helper files.

Highlights

  • Conditional Order ID Generation: The system will now conditionally generate order IDs only when a payment amount is greater than zero and the pay_later flag is not set to true. This prevents unnecessary order ID creation for 'pay later' bookings.
  • Code Formatting and Readability: Multiple sections of the guestBooking.controller.js and mumukshuBooking.controller.js files have been reformatted to improve code readability, including import statements, function signatures, and function calls with multiple arguments.
  • Razorpay Order Creation: The generateOrderId function in transactions.helper.js no longer explicitly awaits the razorpay.orders.create call, potentially changing its asynchronous behavior.
  • Dependency Update: The uglify-js dependency has been removed from package-lock.json.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly implements the pay_later flag to conditionally skip order ID generation. However, I've identified a critical issue where an await keyword was removed from a promise-based call, which will break order creation. Additionally, a country-specific check was removed from the payment logic in two controller files, which could lead to unintended behavior for international users. There is also a minor issue of an unused import. Please review the detailed comments.

var order;
if (['prod', 'qa'].includes(process.env.NODE_ENV) && amount > 0) {
order = await razorpay.orders.create(options);
order = razorpay.orders.create(options);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The await keyword has been removed from the razorpay.orders.create(options) call. Since this function returns a Promise, removing await will cause the order variable to be assigned the Promise object itself, not the resolved order data. Consequently, any subsequent code attempting to access properties like order.id will fail, breaking the order creation process.

Suggested change
order = razorpay.orders.create(options);
order = await razorpay.orders.create(options);

if (req.user.country == 'India' && amount > 0) {
const payLater = req.body.pay_later === true;

if (amount > 0 && !payLater) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The condition to generate an order ID has been changed, removing the req.user.country == 'India' check. This will now trigger order ID generation for non-Indian users. As Razorpay is the payment provider, this could cause issues if it's not configured for international payments. Was this change intentional? If so, consider adding a comment to clarify why this check is no longer necessary.

if (req.user.country == 'India' && amount > 0) {
const payLater = req.body.pay_later === true;

if (amount > 0 && !payLater) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Similar to the change in guestBooking.controller.js, the check for req.user.country == 'India' has been removed. This will cause order IDs to be generated for non-Indian users, which might lead to payment failures if the Razorpay integration doesn't support international transactions. Please verify if this is the intended behavior.

import database from '../../config/database.js';
import ApiError from '../../utils/ApiError.js';
import moment from 'moment';
import logger from '../../config/logger.js';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This logger import is not used anywhere in the file. It should be removed to maintain code cleanliness.

Base automatically changed from dev to main April 14, 2026 16:40
@vendz vendz changed the base branch from main to dev May 10, 2026 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants