Mangopay / cardregistration-js-kit

Mangopay V2 JS resources for card registration front-end workflow
MIT License
38 stars 34 forks source link

Validation isn't passed for 3ds testing cards #29

Closed EvgeniyDubovoy closed 7 years ago

EvgeniyDubovoy commented 7 years ago

I get 105204(CVV_FORMAT_ERROR) error, when I try to add one of 3ds testing cards (3569990000000132, 3569990000000157, 3012340000000000, 3012349999999999)

The error occures in this function:

_validate: function(cvv, cardType) {

           if(cardType === "MAESTRO") {
               return true;
           }
           cvv = cvv ? cvv.trim() : "";
           cardType = cardType ? cardType.trim() : "";

           // CVV is 3 to 4 digits for AMEX cards and 3 digits for all other cards
           if (mangoPay._validation._helpers._validateNumericOnly(cvv) === true) {
                if (cardType === "AMEX" && (cvv.length === 3 || cvv.length === 4)) {
                    return true;
                }
                if (cardType === "CB_VISA_MASTERCARD" && cvv.length === 3) {
                    return true;
                }
           }

           // Invalid format
           return {
               "ResultCode": "105204",
               "ResultMessage": "CVV_FORMAT_ERROR"
           };

        }
hobailey commented 7 years ago

What CVV are you using? i just registered 3569990000000132 / 1017 / 123 in sandbox with no problem :-/

EvgeniyDubovoy commented 7 years ago

It seems that we don't correctly determine the card type. Tell me please, how I can determine the card type by card number?

hobailey commented 7 years ago

Ah, so you're automatically detecting the CardType from the first 6 numbers of the card? Unfortunatley the BIN info for the cards in sandbox do not match the real CardType that they carry.

EvgeniyDubovoy commented 7 years ago

Ok, thanks. Tell me please, what constans we need to use for card types. As far as I understand, constant CB_VISA_MASTERCARD is used for Visa and Mastercard. Am I right? What constants for other card types?

hobailey commented 7 years ago

If you hover over "CardType" in the docs, you'll see the diferent possible options.

EvgeniyDubovoy commented 7 years ago

Thank you for help.