-
Notifications
You must be signed in to change notification settings - Fork 662
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CardValidCallback and add support in card forms
Summary Add `CardInputWidget#setCardValidCallback()` and `CardMultilineWidget#setCardValidCallback()` Setting a callback instance will allow the integrating app to determine if the current form input is valid and which fields are invalid, if any. For example, when none of the fields are valid, `CardValidCallback#onInputChanged()` will be called with ``` false, setOf( CardValidCallback.Fields.Number, CardValidCallback.Fields.Expiry, CardValidCallback.Fields.Cvc ) ``` When all of the fields are valid, `CardValidCallback#onInputChanged()` will be called with ``` true, emptySet() ``` Testing Add unit tests and manually verified Motivation Fixes #1808
- Loading branch information
1 parent
9902e37
commit 3ed36fe
Showing
8 changed files
with
259 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
stripe/src/main/java/com/stripe/android/view/CardValidCallback.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.stripe.android.view | ||
|
||
interface CardValidCallback { | ||
/** | ||
* @param isValid if the current input is valid | ||
* @param invalidFields if the current input is invalid, this [Set] will be populated with the | ||
* fields that are invalid, represented by [Fields]; if the current input is valid, | ||
* this [Set] will be empty | ||
*/ | ||
fun onInputChanged(isValid: Boolean, invalidFields: Set<Fields>) | ||
|
||
enum class Fields { | ||
Number, | ||
Expiry, | ||
Cvc | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.