hyperswitch icon indicating copy to clipboard operation
hyperswitch copied to clipboard

[PLUGIN] - WooCommerce - Add Input Validation for Hex Color String

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 processes a hex color string. Your task is to ensure that the input is a valid hex color string before proceeding with the function. Implement validation that checks whether the string is in the correct hex format (e.g., #FFF or #FFFFFF) and handle any invalid inputs appropriately. The goal is to prevent errors caused by incorrect input while maintaining the existing functionality of the code.

Code Snippet -

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

function checkWcHexIsLight(color) {
  const hex = color.replace("#", "");
  const c_r = parseInt(hex.substr(0, 2), 16);
  const c_g = parseInt(hex.substr(2, 2), 16);
  const c_b = parseInt(hex.substr(4, 2), 16);
  const brightness = (c_r * 299 + c_g * 587 + c_b * 114) / 1000;
  return brightness > 155;
}

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.
  • For this issue, please submit a PR on @juspay/hyperswitch-woocommerce-plugin repo, and link it to the issue.

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 26 '24 11:09 sakksham7

Hi, is anyone working on this issue? If not, I would like to take it up.

TheMarvelFan avatar Sep 26 '24 16:09 TheMarvelFan

@TheMarvelFan - Assigning this to you

neerajkumar-n avatar Oct 01 '24 06:10 neerajkumar-n

Hi @neerajkumar-n

I have created a PR for this issue. Please review the changes and let me know if any modifications are required.

Thanks!

TheMarvelFan avatar Oct 02 '24 10:10 TheMarvelFan

Hey @TheMarvelFan it will be reviewed soon. Thanks, for your patience

sakksham7 avatar Oct 04 '24 06:10 sakksham7

Hello! I saw this task was assigned and being discussed about 9 months ago, yet there have been no updates since then. I'd like to help out and would appreciate knowing if it's still available for someone to pick up.

If the previous assignee is no longer working on it, I'd be willing to give it a try. Let me know!

piyushgalgotia avatar May 29 '25 18:05 piyushgalgotia