hyperswitch icon indicating copy to clipboard operation
hyperswitch copied to clipboard

[PLUGIN] - WooCommerce - Refactor Code for Clarity and Readability

Open sakksham7 opened this issue 1 year ago • 5 comments

The WooCommerce-Payments-Plugin connect with multiple payment processors with a single API to improve payment conversions, reduce costs and ops. It supports multiple currencies, offers fraud protection, and provides an easy-to-use dashboard for managing transactions and tracking sales.

Getting started

  1. Get familiar with Php and Javascript.
  2. Check the README.md for project structure and setup instructions.
  3. To setup locally, follow the steps provided here

Description:

You are provided with a code snippet that performs a specific function. Your task is to refactor the code to improve its readability, performance, and maintainability. Consider applying best practices such as input validation, descriptive variable naming, reducing complexity, and handling edge cases. The goal is to make the code more efficient, cleaner, and easier to understand while maintaining its core functionality.

Code Snippet -

This provided code snippet is a part of WooCommerce-Plugin.

async function hyperswitchPaymentHandleSubmit(isOneClickPaymentMethod, result) {
  if (result || isOneClickPaymentMethod) {
    let err;
    if (!isOneClickPaymentMethod && result) {
      const { error } = await hyper.confirmPayment({
        confirmParams: {
          return_url: hyperswitchReturnUrl,
        },
        redirect: "if_required",
      });
      err = error;
    } else {
      const { error } = await hyper.confirmOneClickPayment(
        {
          confirmParams: {
            return_url: hyperswitchReturnUrl,
          },
          redirect: "if_required",
        },
        result
      );
      err = error;
    }
    if (err) {
      if (err.type) {
        if (err.type == "validation_error") {
          jQuery([document.documentElement, document.body]).animate(
            {
              scrollTop: jQuery(
                ".payment_box.payment_method_hyperswitch_checkout"
              ).offset().top,
            },
            500
          );
        } else {
          location.href = hyperswitchReturnUrl;
        }
      } else {
        location.href = hyperswitchReturnUrl;
      }
      jQuery(".payment_method_hyperswitch_checkout").unblock();
    } else {
      location.href = hyperswitchReturnUrl;
    }
  }
}

Contribution Guidelines:

  • Fork the repository and create a new branch for your work.
  • Ensure the WebSDK follows best practices for API integration and field rendering.
  • Write clean, well-documented code with clear commit messages.
  • Add unit tests to ensure the dynamic field rendering works as expected.
  • Make sure to follow our coding standards and contribution guidelines.

Helpful Resources:

  • Link to WooCommerce-Plugin documentation: WooCommerce

Submission Process:

  • Ask the maintainers for assignment of the issue, you can request for assignment by commenting on the issue itself.
  • Once assigned, submit a pull request (PR).
  • Maintainers will review and provide feedback, if any.
  • Maintainers can unassign issues due to inactivity, read more here.

Refer here for Terms and conditions for the contest.

If you have any questions or need help getting started, feel free to ask in the comments!

sakksham7 avatar Sep 30 '24 05:09 sakksham7

Hi @sakksham7 @gorakhnathy7 I would like to work on this issue. Can you assign it to me?

nabeel001 avatar Oct 01 '24 04:10 nabeel001

Hello @sakksham7 @gorakhnathy7 , can you assign this issue to me , i would like to work on it

karan68 avatar Oct 01 '24 06:10 karan68

Hey @karan68 This is already assigned to another contributor, Kindly pick an issue from here.

gorakhnathy7 avatar Oct 01 '24 06:10 gorakhnathy7

@sakksham7 @gorakhnathy7 Kindly review my Pull request.

nabeel001 avatar Oct 01 '24 12:10 nabeel001

Hey @nabeel001 this is under review, thanks for your patience.

gorakhnathy7 avatar Oct 02 '24 09:10 gorakhnathy7

@gorakhnathy7 @sakksham7 By when can I expect it to be reviewed, also meanwhile can I pick up some other issue..?

nabeel001 avatar Oct 04 '24 09:10 nabeel001

Hey @nabeel001 It will take some time, we will keep you posted with the updates!

gorakhnathy7 avatar Oct 12 '24 10:10 gorakhnathy7

I would like to work on this. Can you assign it to me?

ravi-hash avatar Oct 20 '24 15:10 ravi-hash

Hi @gorakhnathy7 Any updates about my PR review for this issue..?

nabeel001 avatar Oct 21 '24 12:10 nabeel001

Hey @nabeel001 Thanks for your patience, we are reviewing PRs one by one, will keep you posted.

gorakhnathy7 avatar Oct 22 '24 08:10 gorakhnathy7

Hey @nabeel001 Thanks for participating! Kindly fill this form once all of your PRs are merged.

gorakhnathy7 avatar Oct 31 '24 08:10 gorakhnathy7