Skip to content

Commit

Permalink
Mark code using Card for card object creation as @deprecated (#2681)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshafrir-stripe authored Aug 3, 2020
1 parent 035b688 commit da97e5f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions stripe/src/main/java/com/stripe/android/Stripe.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,7 @@ class Stripe internal constructor(
* By default, will use the Connect account that was used to instantiate the `Stripe` object, if specified.
* @param callback a [ApiResultCallback] to receive the result or error
*/
@Deprecated("Use createCardToken(CardParams)")
@UiThread
@JvmOverloads
fun createCardToken(
Expand Down Expand Up @@ -1290,6 +1291,7 @@ class Stripe internal constructor(
* @throws APIException any other type of problem (for instance, a temporary issue with
* Stripe's servers
*/
@Deprecated("Use createCardTokenSynchronous(CardParams)")
@Throws(AuthenticationException::class, InvalidRequestException::class,
APIConnectionException::class, CardException::class, APIException::class)
@WorkerThread
Expand Down
6 changes: 6 additions & 0 deletions stripe/src/main/java/com/stripe/android/model/Card.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ data class Card internal constructor(
/**
* the [number] of this card
*/
@Deprecated("Use CardParams")
val number: String?,

/**
* the [cvc] for this card
*/
@Deprecated("Use CardParams")
val cvc: String?,

/**
Expand Down Expand Up @@ -225,6 +227,7 @@ data class Card internal constructor(
/**
* @return a [Card.Builder] populated with the fields of this [Card] instance
*/
@Deprecated("Use CardParams")
fun toBuilder(): Builder {
return Builder(number, expMonth, expYear, cvc)
.name(name)
Expand Down Expand Up @@ -360,6 +363,7 @@ data class Card internal constructor(
* @param expYear the expiry year
* @param cvc the card CVC number
*/
@Deprecated("Use CardParams")
class Builder(
internal val number: String? = null,
@param:IntRange(from = 1, to = 12) internal val expMonth: Int? = null,
Expand All @@ -377,8 +381,10 @@ data class Card internal constructor(
private var addressCountry: String? = null
private var brand: CardBrand? = null
private var funding: CardFunding? = null

@Size(4)
private var last4: String? = null

private var fingerprint: String? = null
private var country: String? = null
private var currency: String? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ class SourceParams private constructor(
*
* @see [Card Payments with Sources](https://stripe.com/docs/sources/cards)
*/
@Deprecated("Use createCardParams with CardParams argument.")
@JvmStatic
fun createCardParams(card: Card): SourceParams {
return SourceParams(SourceType.CARD, card.loggingTokens)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class CardInputWidget @JvmOverloads constructor(
*/
override val paymentMethodCard: PaymentMethodCreateParams.Card?
get() {
return card?.let {
return cardParams?.let {
PaymentMethodCreateParams.Card(
number = it.number,
cvc = it.cvc,
Expand Down Expand Up @@ -207,6 +207,7 @@ class CardInputWidget @JvmOverloads constructor(
* A [Card] representing the card details and postal code if all fields are valid;
* otherwise `null`
*/
@Deprecated("Use cardParams", ReplaceWith("cardParams"))
override val card: Card?
get() {
return cardBuilder?.build()
Expand Down Expand Up @@ -275,6 +276,7 @@ class CardInputWidget @JvmOverloads constructor(
* A [Card.Builder] representing the card details and postal code if all fields are valid;
* otherwise `null`
*/
@Deprecated("Use cardParams", ReplaceWith("cardParams"))
override val cardBuilder: Card.Builder?
get() {
val cardNumber = cardNumberEditText.cardNumber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class CardMultilineWidget @JvmOverloads constructor(
*/
override val paymentMethodCard: PaymentMethodCreateParams.Card?
get() {
return card?.let {
return cardParams?.let {
PaymentMethodCreateParams.Card(
number = it.number,
cvc = it.cvc,
Expand Down Expand Up @@ -172,6 +172,7 @@ class CardMultilineWidget @JvmOverloads constructor(
* A [Card] representing the card details and postal code if all fields are valid;
* otherwise `null`
*/
@Deprecated("Use cardParams", ReplaceWith("cardParams"))
override val card: Card?
get() {
return cardBuilder?.build()
Expand Down Expand Up @@ -211,6 +212,7 @@ class CardMultilineWidget @JvmOverloads constructor(
* A [Card.Builder] representing the card details and postal code if all fields are valid;
* otherwise `null`
*/
@Deprecated("Use cardParams", ReplaceWith("cardParams"))
override val cardBuilder: Card.Builder?
get() {
if (!validateAllFields()) {
Expand Down
2 changes: 2 additions & 0 deletions stripe/src/main/java/com/stripe/android/view/CardWidget.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ internal interface CardWidget {
* A [Card] representing the card details and postal code if all fields are valid;
* otherwise `null`
*/
@Deprecated("Use cardParams", ReplaceWith("cardParams"))
val card: Card?

/**
Expand All @@ -23,6 +24,7 @@ internal interface CardWidget {
* A [Card.Builder] representing the card details and postal code if all fields are valid;
* otherwise `null`
*/
@Deprecated("Use cardParams", ReplaceWith("cardParams"))
val cardBuilder: Card.Builder?

/**
Expand Down

0 comments on commit da97e5f

Please sign in to comment.