Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong credit card type comparation #34775

Conversation

ndlinh-celtic
Copy link

@ndlinh-celtic ndlinh-celtic commented Dec 8, 2021

Description

Fix wrong credit card type comparation

if (cardInfo.title == allowedTypes[i].type) is incorrect comparation. cardInfo.title will be 'Visa', 'Master',.... but allowedTypes[i].type is VI, MC,...

Resolved issues:

  1. resolves [Issue] Fix wrong credit card type comparation #35662: Fix wrong credit card type comparation

`if (cardInfo.title == allowedTypes[i].type)` is incorrect comparation. cardInfo.title will be 'Visa', 'Master',.... but allowedTypes[i].type is VI, MC,...
@m2-assistant
Copy link

m2-assistant bot commented Dec 8, 2021

Hi @ndlinh-celtic. Thank you for your contribution
Here are some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here

ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.

For more details, review the Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@ndlinh
Copy link

ndlinh commented Dec 9, 2021

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@bgorski
Copy link
Contributor

bgorski commented Dec 9, 2021

@ndlinh-celtic can you provide information on how to trigger the incorrect behavior?

@bgorski bgorski self-requested a review December 9, 2021 10:37
@ndlinh-celtic
Copy link
Author

ndlinh-celtic commented Dec 9, 2021

@bgorski

Magento default doesn't have credit card payment form, so it's difficult to re-produce this problem with default magento instance.

I'm developing a payment gateway that have credit card form. In this form, I use a rule validate-card-number provided by
Magento_Payment/js/model/credit-card-validation/validator.js to validate credit card number. This rule use a function (alias: creditCardNumberValidator) in Magento_Payment/js/model/credit-card-validation/credit-card-number-validator.js and credit card type information declare in Magento_Payment/js/model/credit-card-validation/credit-card-number-validator/credit-card-type.js. The credit card type information has format like this:

var types = [
    {
        title: 'Visa',
        type: 'VI',
        pattern: '^4\\d*$',
        gaps: [4, 8, 12],
        lengths: [16],
        code: {
            name: 'CVV',
            size: 3
        }
    },
    {
        title: 'MasterCard',
        type: 'MC',
        pattern: '^(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$',
        gaps: [4, 8, 12],
        lengths: [16],
        code: {
            name: 'CVC',
            size: 3
        }
    },
    ...
]

The statement cardInfo = creditCardNumberValidator(number).card; in validate-card-number validate function return credit card type information store in cardInfo then use cardInfo.title to compare with allowedTypes[i].type. allowedTypes is an array contains information as screenshot bellow:

Selection_071

So, use title to compare with type is incorrect. The validation never pass.
After apply the changes in this PR, all validation rules on my credit card form working without any problem.

@sidolov sidolov added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Dec 9, 2021
@andrewbess andrewbess self-assigned this Dec 9, 2021
@m2-community-project m2-community-project bot moved this from Pending Review to Review in Progress in High Priority Pull Requests Dashboard Dec 9, 2021
@engcom-Alfa
Copy link
Contributor

@magento give me test instance

@magento-deployment-service
Copy link

Hi @engcom-Alfa. Thank you for your request. I'm working on Magento instance for you.

@engcom-Alfa
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @engcom-Alfa. Thank you for your request. I'm working on Magento instance for you.

@magento-deployment-service
Copy link

Hi @engcom-Alfa, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

@magento-deployment-service
Copy link

@ndlinh-celtic
Copy link
Author

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @ndlinh-celtic. Thank you for your request. I'm working on Magento instance for you.

@magento-deployment-service
Copy link

@bgorski
Copy link
Contributor

bgorski commented Jun 18, 2022

@magento run Functional Tests CE, Functional Tests EE, Functional Tests B2B

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@bgorski bgorski self-assigned this Jun 18, 2022
@engcom-Lima
Copy link
Contributor

Hi @ndlinh-celtic

Thanks for your contribution and collaboration.

I have gone to through yours comment "Magento default doesn't have credit card payment form, so it's difficult to re-produce this problem with default magento instance."
I have enabled PayPal in my local 2.4-develop, in frontend I got credit card payment form.
Kindly assist me, How can I can reproduce this issue?
Below is the screenshot for your reference:
image

@engcom-Lima
Copy link
Contributor

@magento run Functional Tests CE, Functional Tests EE, Functional Tests B2B

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Alfa
Copy link
Contributor

@magento run Functional Tests CE, Functional Tests EE, Functional Tests B2B

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Alfa
Copy link
Contributor

@magento run Functional Tests CE, Functional Tests EE, Functional Tests B2B

@engcom-Alfa engcom-Alfa added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Jul 4, 2022
@m2-community-project m2-community-project bot moved this from Testing in Progress to Ready for Testing in High Priority Pull Requests Dashboard Jul 4, 2022
@engcom-Alfa
Copy link
Contributor

@magento run Functional Tests CE, Functional Tests EE, Functional Tests B2B

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Alfa
Copy link
Contributor

Hi @ndlinh-celtic
With the default Paypal payment methods credit card form, we are not able to see any JS errors as such in the console.

  1. If it is specific by adding a new payment gateway with a new CC form including card validation, Ca you please confirm?
  2. Can you please let us know step-by-step procedure you have followed to come up with a new payment gateway for better understanding?
  3. Also, even after multiple tries, there are 3 auto-test jobs are getting failed, Can you help us with your fixes on this?

Thanks in advance!

@engcom-Alfa
Copy link
Contributor

Hi @ndlinh-celtic
I tried to reach you thru Slack channel, but could not find you there!
You are invited to join the Magento Community Slack Channel, please feel free to join the workspace.

@ndlinh-celtic
Copy link
Author

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @ndlinh-celtic. Thank you for your request. I'm working on Magento instance for you.

@magento-deployment-service
Copy link

Copy link
Contributor

@engcom-Alfa engcom-Alfa left a comment

Choose a reason for hiding this comment

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

Hi @ndlinh ,
Looks like you are working on this as per my above-comment. Kindly revert us on it.
Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Frontend Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests Award: bug fix Component: Payment Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Release Line: 2.4 Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Issue] Fix wrong credit card type comparation
8 participants