ezet / stripe-sdk

A simple and flexible Stripe library for Flutter with complete support for SCA and PSD2.
https://pub.dev/packages/stripe_sdk
Other
137 stars 137 forks source link

Fix card expiry date validation for months below 11 #105

Closed musthafa1996 closed 3 years ago

musthafa1996 commented 3 years ago

StripeCard.validateExpDate() fails when expMonth is below 11. This is due to a bug in the following code:

bool validateDate() { return _ccValidator.validateExpDate('$expMonth/$expYear').isValid; }

For example, if expMonth is 01 and expYear is 12, and since expMonth is an int, the resulting String passed to _ccValidator.validateExpDate would be "1/12" instead of "01/12", which fails while matching with RegExp(r'((0[1-9])|(1[0-2]))(/)+(\d{2,4})'),