GithubHelp home page GithubHelp logo

braintree / android-card-form Goto Github PK

View Code? Open in Web Editor NEW
366.0 87.0 130.0 1.99 MB

A ready-made card form layout that can be included in your Android app, making it easy to accept credit and debit cards.

License: MIT License

Java 98.09% Shell 0.43% Ruby 1.47%
android payments credit-card debit-card ui view

android-card-form's Introduction

Card Form

Build Status

Card Form is a ready made card form layout that can be included in your app making it easy to accept credit and debit cards.

Adding It To Your Project

Add the dependency in your build.gradle:

dependencies {
    implementation 'com.braintreepayments:card-form:5.4.0'
}

Usage

Card Form is a LinearLayout that you can add to your layout:

<com.braintreepayments.cardform.view.CardForm
    android:id="@+id/card_form"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

To initialize the view and change which fields are required for the user to enter, use the required field methods and CardForm#setup(AppCompatActivity activity).

CardForm cardForm = (CardForm) findViewById(R.id.card_form);
cardForm.cardRequired(true)
        .expirationRequired(true)
        .cvvRequired(true)
        .cardholderName(CardForm.FIELD_REQUIRED)
        .postalCodeRequired(true)
        .mobileNumberRequired(true)
        .mobileNumberExplanation("SMS is required on this number")
        .actionLabel("Purchase")
        .setup(activity);

To access the values in the form, there are getters for each field:

cardForm.getCardNumber();
cardForm.getExpirationMonth();
cardForm.getExpirationYear();
cardForm.getCvv();
cardForm.getCardholderName();
cardForm.getPostalCode();
cardForm.getCountryCode();
cardForm.getMobileNumber();

To check if CardForm is valid call CardForm#isValid(). To validate each required field and show the user which fields are incorrect, call CardForm#validate().

To set custom error messages on a field call CardForm#setCardNumberError(String) on the given field.

Additionally CardForm has 4 available listeners:

  • CardForm#setOnCardFormValidListener called when the form changes state from valid to invalid or invalid to valid.
  • CardForm#setOnCardFormSubmitListener called when the form should be submitted.
  • CardForm#setOnFormFieldFocusedListener called when a field in the form is focused.
  • CardForm#setOnCardTypeChangedListener called when the CardType in the form changes.

Example

Styling

The card form uses the Android Design Support Library for styling and floating labels. All card form inputs use the colorAccent theme attribute, when present, to set their focused color. For more information on the colorAccent attribute, see Using the Material Theme. Additional styling, such as the error color (textErrorColor) can be set in your theme and will be picked up by the card form.

The included sample app has examples with a light theme and dark theme.

Note: Any Activity using the card form must use a style that is a Theme.AppCompat theme or descendant (defines android.support.v7.appcompat.R.attr.colorPrimary). This is a requirement of the Android Design Support Library. If this is a problem in your usage of the card form, please file an issue and we will look further into workarounds for this.

License

Card Form is open source and available under the MIT license. See the LICENSE file for more info.

android-card-form's People

Contributors

braintreeps avatar consp1racy avatar crookedneighbor avatar demerino avatar hollabaq86 avatar jackellenberger avatar lkorth avatar mattwylder avatar mlykotom avatar quinnjn avatar sarahkoop avatar scannillo avatar sestevens avatar sshropshire avatar tperraut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-card-form's Issues

Keyboard overlay field

There is an issue when you click on expiration date field and the opened picker overlay on this field. With rest of the fields all works perfect.
Could you please fix this ?

I want to set CVV input type as password

General information

  • SDK/Library version: 3.0.5
  • Android Version and Device: Genymotion 5.0.0

Issue description

I am trying to set CVV input type as password but its not working for me.

"Google Services" charge for 0.00 on creditcard without any processing

General information

  • SDK/Library version:
  • Android Version and Device:

Issue description

on card submit, or possibly during autofill (creditcard data) on Android 9, with embedded card form. Seems I am being charge $0.00 on my credit card when I haven't attempted to send payment data to any post processing scripts. What is going on?

Hiding Field Icons Leads to Empty Whitespace

General information

  • SDK/Library version: 3.0.5
  • Android Version and Device: Doesn't Matter

Issue description

Relates to #22 (and it's associated fix 858d45b)
If you set the card / postal code / phone number icons to 0 (to disable them) they are set to INVISIBLE instead of GONE and the associated text field maintains its explicit left padding, resulting in a ton of wasted space to the left of the form.

Example

We have a custom layout with a name field above the brain tree form. This looked great in 2.x, but with the update to 3.x and the icons that were forced on us, our UI would look like this:

screen shot 2017-04-06 at 3 46 45 pm

For our app don't want the icons, or the empty whitespace that appears left of the expiration date, but then disabling them leads to this:

screen shot 2017-04-06 at 3 34 36 pm

It'd be nice to disable all icons such that all that extra space is reclaimed.
Something like: CardForm.setIconsEnabled(false); that sets all icons to gone and removes the excessive left padding from the associated fields.

Workaround

For now, I'm going to extend CardForm and manually find and alter the views in question, but it'd be nice if this view were smarter about handling disabling these icons.

Display the keyboard purchase button when postal code and phone number are disabled

Hi there and thanks for your library, it is great!

I use it this way

creditCardForm.cardRequired(true)
                .expirationRequired(true)
                .cvvRequired(true)
                .postalCodeRequired(false)
                .mobileNumberRequired(false)
                .actionLabel("DONE")
                .setup(AccountCreationActivity.this);

But the keyboard DONE button doesn't display when I am on the cvv edittext. Is there any way to do it ?

Regards.

Text color default white

General information

  • SDK/Library version: 3.4.1
  • Android Version and Device:

Issue description

When using the card form widget the text colour in the edit-text field is white and unchangeable. I have tried to change the styles attributes a number of different ways to no avail. I am using app theme in my manifest file

`

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowFullscreen">true</item>

    <item name="colorPrimary">@color/darkNavyBlue</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorLight</item>
    <item name="android:textColor">@android:color/black</item>
    <item name="android:textColorPrimary">@android:color/black</item>
    <item name="android:editTextColor">@android:color/black</item>
    <item name="android:colorBackground">@color/backgroundColor</item>
    <item name="android:textColorSecondary">@android:color/darker_gray</item>
    <item name="android:actionOverflowButtonStyle">@style/MyActionButtonOverflow</item>
    <item name="android:textColorHint">@android:color/black</item>
</style>

<!-- Style to replace actionbar overflow icon. set item 'android:actionOverflowButtonStyle' in AppTheme -->
<style name="MyActionButtonOverflow" parent="android:style/Widget.Holo.Light.ActionButton.Overflow">
    <item name="android:src">@drawable/ic_menu</item>
    <item name="android:background">?android:attr/actionBarItemBackground</item>
    <item name="android:contentDescription">@string/directory_title</item>
</style>

<style name="AppTheme.NoActionBar" parent="@style/AppTheme">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="android:textColor">#000000</item>
</style>

`

Crash at CardType.validate() for Android 8.0.0

General information

  • SDK/Library version: card-form:3.5.0
  • Android Version and Device: Galaxy S7 Edge with Android 8.0.0 and SM-J337P with Android 8.0.0

Issue description

Crash reported by Crashylitcs but haven't both able to reproduce locally.

Stacktrace

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.regex.Matcher java.util.regex.Pattern.matcher(java.lang.CharSequence)' on a null object reference
       at com.braintreepayments.cardform.utils.CardType.validate(CardType.java:223)
       at com.silvercar.mobi.ui.view.CardEditText.isValid(CardEditText.java:120)
       at com.silvercar.mobi.ui.view.CardForm.isCardNumberValid(CardForm.java:161)
       at com.silvercar.mobi.ui.account.CreditCardActivity.isCreditCardValid(CreditCardActivity.java:268)
       at com.silvercar.mobi.ui.account.CreditCardActivity.finishSubmission(CreditCardActivity.java:256)
       at com.silvercar.mobi.ui.account.CreditCardActivity.onFinishClicked(CreditCardActivity.java:238)
       at com.silvercar.mobi.ui.account.CreditCardActivity_ViewBinding$8.doClick(CreditCardActivity_ViewBinding.java:135)
       at butterknife.internal.DebouncingOnClickListener.onClick(DebouncingOnClickListener.java:22)
       at android.view.View.performClick(View.java:6897)
       at android.widget.TextView.performClick(TextView.java:12693)
       at android.view.View$PerformClick.run(View.java:26100)
       at android.os.Handler.handleCallback(Handler.java:789)
       at android.os.Handler.dispatchMessage(Handler.java:98)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6944)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

Layout order

General information

  • SDK/Library version: 4.2.0

Issue description

There is a way to change fields order? I want to add Name at last position
card_form_OutlinedBox

Proguard support.

No mention of proguard issues so far, but enabling proguard would fail for me.

Added the following to my proguard rules and all seemed fine.

Might be useful to add to the readme. Note that I do not have card.io imported into the project, so this rule might not work for those with card.io support.

-dontwarn io.card.payment.**

Card.io scan only card number but not Expiration date.

General information

I integrated the card form together with card.io api but when I trigger card.io and scan a credit card it
recognized only card number but not the expiration period. Any ideas?

minSdkVersion 16
targetSdkVersion 28
Card.IO library version: api 'io.card:android-sdk:5.5.1'

Device: Samsung Galaxy S8 with Android 8.0

Font size for year selector.

Any way you could modify the font size on the expiration keyboard so that the yearly dates don't overflow into two lines?

rendering and Logcat errors

Hi, i receive errors in both my implementation (Card form in a fragment) and in the Demo app. Should i add something more, or just ignore them (the form works and i can initiate Sandbox transactions) ? The errors are in the Design XML View and with error messages:

  1. My implementation: no Activity Theme defined , only Application AppTheme , Nexus 4 emulator , API 22 , compiled in API 25

Exception Details : same as below

  1. Demo app Theme.Holo.Light:

The following classes could not be instantiated:
- com.braintreepayments.cardform.view.MobileNumberEditText
- com.braintreepayments.cardform.view.CardForm
- android.support.design.widget.TextInputLayout

Exception Details java.lang.RuntimeException: Stub!   
at android.telephony.PhoneNumberFormattingTextWatcher.(PhoneNumberFormattingTextWatcher.java:21)   
at com.braintreepayments.cardform.view.MobileNumberEditText.init(MobileNumberEditText.java:37)   
at com.braintreepayments.cardform.view.MobileNumberEditText.(MobileNumberEditText.java:25)   
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)   
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)   
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)   
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)   
at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)   
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)   
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:861)   
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)   
at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)   
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)   
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:861)   
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)   
at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)   
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)   
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)   
at android.view.View.inflate(View.java:20841)   
at com.braintreepayments.cardform.view.CardForm.init   ... (CardForm.java:98)   
at com.braintreepayments.cardform.view.CardForm.(CardForm.java:80)   
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)   
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)   
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)   
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)   
at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)   
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)   
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:861)   
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)   
at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)   
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)   
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:861)   
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)   
at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)   
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)   
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)   
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
Copy stack to clipboard Failed to find style 'editTextStyle' in current theme (48 similar errors not shown)

  1. After closing the Demo app, i get a notification "LightThemeActivity has leaked"

  2. When the Message "Card number is invalid" pops up :
    E/AppCompatResources: Failed to inflate ColorStateList, leaving it to the framework
    java.lang.RuntimeException: Failed to resolve attribute at index 0
    at android.content.res.TypedArray.getColor(TypedArray.java:401)
    at android.support.v7.content.res.AppCompatColorStateListInflater.inflate(AppCompatColorStateListInflater.java:114)
    ... and so on

Card Type

Is there any method to get the card type. I mean like mCardForm.getCardType.

Crash - java.lang.NullPointerException: at com.braintreepayments.cardform.CardScanningFragment.onActivityResult (CardScanningFragment.java:61)

General information

  • SDK/Library version: 3.3.0
  • Android Version and Device: Samsung Galaxy S7 Edge (hero2qltespr), 4096MB RAM, Android 7.0

Issue description

Hello,

I saw this crash happening in my app. It has happen very few times so I don't think it's a big deal, but just thought I would let you know.

Caused by: java.lang.NullPointerException: 
  at com.braintreepayments.cardform.CardScanningFragment.onActivityResult (CardScanningFragment.java:61)
  at android.app.Activity.dispatchActivityResult (Activity.java:7250)
  at android.app.ActivityThread.deliverResults (ActivityThread.java:4521)
  at android.app.ActivityThread.performResumeActivity (ActivityThread.java:3806)
  at android.app.ActivityThread.handleResumeActivity (ActivityThread.java:3872)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3014)
  at android.app.ActivityThread.-wrap14 (ActivityThread.java)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1650)
  at android.os.Handler.dispatchMessage (Handler.java:102)
  at android.os.Looper.loop (Looper.java:154)
  at android.app.ActivityThread.main (ActivityThread.java:6688)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1468)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1358)

Android build error while using AAPT2

General information

  • SDK/Library version: drop-in:3.0.8
  • Android build tools version: 26.0.0
  • Android Gradle plugin version: 3.0.0-alpha3

Issue description

When I'm trying to build an APK, that contains "drop-ui" library, I am receiving next issue
Error: values.xml:3821 (integer) -1 is less than minimum integer 0
Opening this file gives me next results:

<style name="bt_expiration_date_dialog_grid_view"> /*other parameters*/ <item name="android:numColumns">auto_fit</item> </style>

Here is interesting the next line <item name="android:numColumns">auto_fit</item>.
Android docs say, that "auto_fit" parameter has value "-1", but seems AAPT2 can't merge integers that contains values less than 0

IME Actions are not properly reset

When calling CardForm#setRequiredFields repeatedly with different required fields, IME actions on expiration date do not get updated correctly.

Cant take screenshots

Issue description

I put getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);in onCreate of my Activity that holds the cardForm. Still cannot take screenshots. Am I missing something?

[CardForm] Init default value

Is there a way to init value for cardform, for example user click to see card detail with init value
xxxx-xxxx-xxxx-4242 for card number, 02/19 for expire date and xxx for CVV field

Thanks

Could not get resource aar file. Can be server sertificate issue or something else, dont know?

Please take a look at the log here. This issue is coming to me when i am trying to add dependency of your library in my demo app. How to solve it? I am using android studio 3.1.3

Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
Could not determine artifacts for com.braintreepayments:card-form:3.3.0
Could not get resource 'https://jcenter.bintray.com/com/braintreepayments/card-form/3.3.0/card-form-3.3.0.aar'.
Could not HEAD 'https://jcenter.bintray.com/com/braintreepayments/card-form/3.3.0/card-form-3.3.0.aar'.
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
unable to find valid certification path to requested target

Screen Recording the Cardform

General information

  • SDK/Library version: <'com.braintreepayments:card-form:4.2.0'>
  • Android Version and Device: <Samsung Galaxy A30s with Android 9.0 >

Issue description

Trying to allow screen recording of card-form, but cant screen shot or screen record "due to security poilcy"(The toast message comes up), is there a way to bypass this please, I've checked android permissions and haven't seen a way. So i know its in built in the API and cardform src code

Function returns null string

mCardForm = (CardForm) findViewById(R.id.card_form);
mCardForm.setRequiredFields(this, true, true, true, true, getString(R.string.purchase));
mCardForm.setOnCardFormSubmitListener(this);

CardNumber = mCardForm.getCardNumber();
ExpirationMonth = mCardForm.getExpirationMonth();
ExpirationYear = mCardForm.getExpirationYear();
Cvv = mCardForm.getCvv();
 PostelCode = mCardForm.getPostalCode();

Above functions return null strings.

Hide credit card icon?

Hello, is there a way to hide the credit card icon? I've been searching in the source code but the attribute is private and there's no getter or anything. Having the option of hiding it would be nice 😄

Thanks for the lib!

this is the icon:
screen shot 2016-12-29 at 4 39 26 pm

Suggestions on potential new fields

Hi first thanks for the hard work! This library is really slick!
But then for my own projects, I often found myself needs more fields than what this one offers. Those are:

  • Email address;
  • Physical address bundle, could be address line 1, address line 2, city, state, country etc.

It would be really nice if you can add those!
Thanks again.

App Crashes on opening cardForm(NPE)

General information

  • SDK/Library version: 3.5.0
  • Android Version and Device: Samsung Galaxy S6 with Android 7, Xiaomi HM 2LTE-IN with Android 7.0

Issue description

Fatal Exception: java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference at com.braintreepayments.cardform.view.SupportedCardTypesView.setSelected(SupportedCardTypesView.java:61) at myapplicationFragment$onViewCreated$$inlined$apply$lambda$1.onCardTypeChanged(CardInputFragment.kt:63) at com.braintreepayments.cardform.view.CardForm.onCardTypeChanged(CardForm.java:734) at com.braintreepayments.cardform.view.CardEditText.updateCardType(CardEditText.java:179) at com.braintreepayments.cardform.view.CardEditText.afterTextChanged(CardEditText.java:121) at android.widget.TextView.sendAfterTextChanged(TextView.java:7705) at android.widget.TextView$ChangeWatcher.afterTextChanged(TextView.java:9514) at android.text.SpannableStringBuilder.sendAfterTextChanged(SpannableStringBuilder.java:972) at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:516) at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:454) at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:33) at android.text.method.NumberKeyListener.onKeyDown(NumberKeyListener.java:121) at android.widget.TextView.doKeyDown(TextView.java:5813) at android.widget.TextView.onKeyDown(TextView.java:5626) at android.view.KeyEvent.dispatch(KeyEvent.java:2626) at android.view.View.dispatchKeyEvent(View.java:8416) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1496) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1496) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1496) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1496) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1496) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1496) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1496) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1496) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1496) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1496) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1496) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1496) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1496) at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:2364) at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1709) at androidx.core.view.KeyEventDispatcher.dialogSuperDispatchKeyEventPre28(KeyEventDispatcher.java:166) at androidx.core.view.KeyEventDispatcher.dispatchKeyEvent(KeyEventDispatcher.java:89) at androidx.appcompat.app.AppCompatDialog.dispatchKeyEvent(AppCompatDialog.java:206) at androidx.appcompat.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:59) at androidx.appcompat.app.AppCompatDelegateImpl$AppCompatWindowCallback.dispatchKeyEvent(AppCompatDelegateImpl.java:2533) at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2279) at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4072) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4034) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3591) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3644) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3610) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3727) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3618) at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3784) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3591) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3644) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3610) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3618) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3591) at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5869) at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5843) at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5804) at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3387) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5290) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:911) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706)

Validate callback

Could you please add callback for validation fields
So it will check the state before saving

Unable to pre-fill card on file information

  • SDK/Library version: 4.1.0
  • Android Version and Device: Pixel 2 OS 9.0

We store credit card information on our server and I would like to use that stored information to pre-fill the credit card form. Why are there no setter methods to accomplish this? Or is there another way that I can fill the form with all the stored credit card information?

XML error!

Hi, may I know what's the problem causing this error at the XML file?
I been trying to solve for 5 days but could not solve it...

capture

java.lang.RuntimeException: Stub!
	at android.telephony.PhoneNumberFormattingTextWatcher.<init>(PhoneNumberFormattingTextWatcher.java:21)
	at com.braintreepayments.cardform.view.MobileNumberEditText.init(MobileNumberEditText.java:37)
	at com.braintreepayments.cardform.view.MobileNumberEditText.<init>(MobileNumberEditText.java:25)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:465)
	at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:172)
	at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)
	at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:186)
	at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:334)
	at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:345)
	at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:245)
	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
	at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)
	at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
	at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:861)
	at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
	at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:861)
	at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
	at android.view.BridgeInflater.inflate(BridgeInflater.java:299)
	at android.view.View.inflate(View.java:20841)
	at com.braintreepayments.cardform.view.CardForm.init(CardForm.java:99)
	at com.braintreepayments.cardform.view.CardForm.<init>(CardForm.java:81)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:465)
	at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:172)
	at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)
	at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:186)
	at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:334)
	at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:345)
	at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:245)
	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
	at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)
	at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
	at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:324)
	at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
	at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:389)
	at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:548)
	at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:533)
	at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:966)
	at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:533)
	at com.android.tools.idea.rendering.RenderTask.lambda$inflate$70(RenderTask.java:659)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

Couldn't resolve resource @id/visible

error: failed linking references.

My configuration:

compileSdkVersion 28
minSdkVersion 17
targetSdkVersion 28
support Library Version 28.0.0-alpha3
braintreepayments-card-form version 3.3.0

Issue description

I am getting AAPT error,
error: style attribute 'attr/textColorError (aka in.example.app:attr/textColorError)' not found. Message{kind=ERROR, text=error: style attribute 'attr/textColorError (aka in.example.app:attr/textColorError)' not found., sources=[/home/ps/.gradle/caches/transforms-1/files-1.1/card-form-3.3.0.aar/0adfda46d436762f0ca3ad472ea91416/res/values/values.xml:55:5-57:13], original message=, tool name=Optional.of(AAPT)}
when I try to add the card library in my project.

Crash on Android version 4.1

App crashes when user enters card number and selects expiration date field.

I assume that the date picker is not supported in 4.1? It works on newer versions.

Is this a known issue? Let me know if I should post a stacktrace.

name in form

Hi,

Is there a plan to add full name in form ?

thx

Errors in texts for russian locale

Please correct grammatical errors in the texts for the Russian language in res/values-ru/strings.xml:

<string name="bt_card_number_invalid">Номер карты недействит</string>
<string name="bt_cvv_invalid">Данные в поле %s недействит</string>
<string name="bt_expiration_invalid">Срок действия недейств</string>
<string name="bt_mobile_number_required">Номер мобильного обязат</string>

Correctly:

<string name="bt_card_number_invalid">Номер карты недействителен</string>
<string name="bt_cvv_invalid">Данные в поле %s недействительны</string>
<string name="bt_expiration_invalid">Срок действия недействителен</string>
<string name="bt_mobile_number_required">Номер мобильного обязателен</string>

Purchase Button not visible

Purchase button is not visible on the bottom of the Card form, below is the snipped I have used, it shows only Card Form

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_credit_card_form);

    cardForm = (CardForm) findViewById(R.id.bt_card_form);
    cardForm.setRequiredFields(CreditCardFormActivity.this, true, true, true, true, "Purchase");
    cardForm.setOnCardFormSubmitListener(this);

ExpirationDateDialog allows only 10 years in advance (vs. 20 in DateValidator)

We have some users who are unable to select their credit card's expiration date through ExpirationDateDialog - in case the expiration date is >10 years in the future. Meanwhile, the corresponding client-side validator technically allows for 20 years (see com.braintreepayments.cardform.utils.DateValidator.MAXIMUM_VALID_YEAR_DIFFERENCE)

Possible fix:

  • remove hard-coded magic number 10 in com.braintreepayments.cardform.view.ExpirationDateDialog.java:L91
  • replace with reference to MAXIMUM_VALID_YEAR_DIFFERENCE in DateValidator, change its visibility to public

Displaying errors in custom EditTexts doesn't work

When trying to set an error to one of the custom EditTexts (like CardEditText, CvvEditText...), assuming that they are wrapped around a TextInputLayout nothing is displayed in the UI. Looking at the code I found that the problem is in the ErrorEditText class. The method to get the parent TextInputLayout has a bug:

public TextInputLayout getTextInputLayoutParent() {
        if (getParent() != null && getParent().getParent() instanceof TextInputLayout) {
            return (TextInputLayout) getParent().getParent();
        }
        return null;
    }

it's trying to get the parent of the parent, when it should be directly the parent:

public TextInputLayout getTextInputLayoutParent() {
        if (getParent() != null && getParent() instanceof TextInputLayout) {
            return (TextInputLayout) getParent();
        }
        return null;
    }

it's an easy fix, if I have time I'll create a PR.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.