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

CardField not saving card number, or cvv #499

Closed
carman247 opened this issue Dec 24, 2021 · 2 comments · Fixed by #518
Closed

CardField not saving card number, or cvv #499

carman247 opened this issue Dec 24, 2021 · 2 comments · Fixed by #518
Labels
bug Something isn't working

Comments

@carman247
Copy link

carman247 commented Dec 24, 2021

flutter_stripe: ^2.1.0

CardField isn't updating card number or cvv. Only expiry month and expiry year get updated. The other two remain null

Probably because the only arguments it's receiving are:
{last4: null, expiryMonth: null, expiryYear: null, complete: false, brand: null}

Even with both of these set to true, number and cvc still aren't saved/returned in the card details.

dangerouslyUpdateFullCardDetails: true,
dangerouslyGetFullCardDetails: true,

And.. that's because these two parameters are missing from _MethodChannelCardField in lib/widgets/card_field.dart

dangerouslyGetFullCardDetails: widget.dangerouslyGetFullCardDetails,
dangerouslyUpdateFullCardDetails: widget.dangerouslyUpdateFullCardDetails,
@remonh87
Copy link
Member

remonh87 commented Jan 6, 2022

Thanks for reporting. Created a fix. Btw the CVC will never be updated from the card field on both Android and iOS. See code snippet from iOS Stripe sdk as example.

func paymentCardTextFieldDidChange(_ textField: STPPaymentCardTextField) {
        if onCardChange != nil {
            let brand = STPCardValidator.brand(forNumber: textField.cardParams.number ?? "")
            var cardData: [String: Any?] = [
                "expiryMonth": textField.cardParams.expMonth ?? NSNull(),
                "expiryYear": textField.cardParams.expYear ?? NSNull(),
                "complete": textField.isValid,
                "brand": Mappers.mapCardBrand(brand) ?? NSNull(),
                "last4": textField.cardParams.last4 ?? ""
            ]
            if (cardField.postalCodeEntryEnabled) {
                cardData["postalCode"] = textField.postalCode ?? ""
            }
            if (dangerouslyGetFullCardDetails) {
                cardData["number"] = textField.cardParams.number ?? ""
            }
            onCardChange!(cardData as [AnyHashable : Any])
        }
        if (textField.isValid) {
            self.cardParams = textField.cardParams
            self.cardPostalCode = textField.postalCode
        } else {
            self.cardParams = nil
            self.cardPostalCode = nil
        }
    }

@carman247
Copy link
Author

Great thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants