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

feat: add Elo as a supported credit card provider #326

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

raisiqueira
Copy link

This is an additional merge request for the #292 adding Elo as a credit card provider.

closes #325

@fabian-hiller
Copy link
Owner

Thank you very much! Where did you get the regex from? Is there a good source that I can use to check what's a valid Elo credit card?

@fabian-hiller fabian-hiller self-assigned this Dec 27, 2023
@fabian-hiller fabian-hiller added the enhancement New feature or request label Dec 27, 2023
@raisiqueira
Copy link
Author

Hi @fabian-hiller, The source is from this project: https://github.com/raisiqueira/react-payment-inputs/blob/master/src/utils/cardTypes.js. I've used this library when I was working on a Brazilian fintech. To check if Elo credit card number is valid, you can use this website (Portuguese only) to generate a valid credit card number.

@ariskemper
Copy link
Contributor

ariskemper commented Dec 28, 2023

Thanks @raisiqueira for PR, we will review it. @fabian-hiller here are tests cards also for Elo https://docs.adyen.com/development-resources/testing/test-card-numbers/
and
https://developer.ebanx.com/docs/resources/testCreditCards/

we could also extend it for other cards like Bancontact, Cartes Bancaires, Dankort, Hipercard in separate PRs.

@fabian-hiller usually is good that, we would know what type of card it is, visa, mastercard, since in the forms there is implemented usually change of logotip based on the provider. Enhancement would be that output returns a provider name, if card is valid?

@fabian-hiller
Copy link
Owner

Thank you for this PR. @ariskemper feel free to create another PR for other providers. How would you output the provider name? Not sure if this should be part of Valibot. But we could export the specific provider regex we use so that the same regex can be used to determine the provider with custom code.

@ariskemper
Copy link
Contributor

ariskemper commented Dec 28, 2023

@raisiqueira would be enough maybe shorter and less complex Regex, because Elo credit card numbers usually starts with the following prefixes and are 16 digits in length:

4011
4312
4389
4514
4573
4576
5041
5066
5067
5090
6277
6362
6363
6500
6504
6505
6507
6509
6516
6550

we need to account for these prefixes and ensure that the total length of the card number is 16 digits?
Would be regex like this
/^(4011|4312|4389|4514|4573|4576|5041|5066|5067|5090|6277|6362|6363|6500|6504|6505|6507|6509|6516|6550)\d{12}$/ sufficient?

@raisiqueira
Copy link
Author

Hey @ariskemper I believe that this regex that you shared is enough. I'll update the merge request.

@ariskemper
Copy link
Contributor

@raisiqueira if you could add more tests to cover different valid and invalid card numbers would be great.

@raisiqueira
Copy link
Author

@ariskemper Done. Check if the new assertions are enough.

@ariskemper
Copy link
Contributor

@raisiqueira for now should be fine, we could add extra tests in next releases for missing prefixes. @fabian-hiller what do you think?

@fabian-hiller
Copy link
Owner

Looks good on the first view. I will focus on other parts of the project for this and maybe the next week. After that I will review and merge everything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Elo as a supported credit card provider
3 participants