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

Added verve brand #145

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added icons/verve.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions lib/credit_card_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class _CreditCardFormState extends State<CreditCardForm> {
late CreditCardModel creditCardModel;

final MaskedTextController _cardNumberController =
MaskedTextController(mask: '0000 0000 0000 0000');
MaskedTextController(mask: '0000 0000 0000 0000 000');
Copy link
Collaborator

Choose a reason for hiding this comment

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

These changes should be based on the brand, as most of the brands support only 16 digits.

final TextEditingController _expiryDateController =
MaskedTextController(mask: '00/00');
final TextEditingController _cardHolderNameController =
Expand Down Expand Up @@ -281,7 +281,7 @@ class _CreditCardFormState extends State<CreditCardForm> {
validator: widget.cardNumberValidator ??
(String? value) {
// Validate less that 13 digits +3 white spaces
if (value!.isEmpty || value.length < 16) {
if (value!.isEmpty || value.length < 19) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

These changes should be based on the brand, as most of the brands support only 16 digits.

return widget.numberValidationMessage;
}
return null;
Expand Down
15 changes: 15 additions & 0 deletions lib/credit_card_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const Map<CardType, String> CardTypeIconAsset = <CardType, String>{
CardType.discover: 'icons/discover.png',
CardType.elo: 'icons/elo.png',
CardType.hipercard: 'icons/hipercard.png',
CardType.verve: 'icons/verve.png',
};

class CreditCardWidget extends StatefulWidget {
Expand Down Expand Up @@ -648,6 +649,9 @@ class _CreditCardWidgetState extends State<CreditCardWidget>
CardType.hipercard: <List<String>>{
<String>['606282'],
},
CardType.verve: <List<String>>{
<String>['5061'],
}
};

/// This function determines the Credit Card type based on the cardPatterns
Expand Down Expand Up @@ -753,6 +757,16 @@ class _CreditCardWidgetState extends State<CreditCardWidget>
isAmex = true;
break;

case CardType.verve:
icon = Image.asset(
CardTypeIconAsset[ccType]!,
height: 48,
width: 48,
package: 'flutter_credit_card',
);
isAmex = false;
break;

default:
icon = Container(
height: 48,
Expand Down Expand Up @@ -903,4 +917,5 @@ enum CardType {
discover,
elo,
hipercard,
verve
DiekoMA marked this conversation as resolved.
Show resolved Hide resolved
}