From d85b68a705f97e0bf68dc755e0057c0bc29fe07d Mon Sep 17 00:00:00 2001 From: Michael Shafrir Date: Thu, 11 Jun 2020 10:19:37 -0400 Subject: [PATCH] Make PaymentMethod.Card.Networks fields public --- .../com/stripe/android/model/PaymentMethod.kt | 6 ++-- .../java/com/stripe/android/ApiKeyFixtures.kt | 1 + .../com/stripe/android/StripeEndToEndTest.kt | 36 +++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/stripe/src/main/java/com/stripe/android/model/PaymentMethod.kt b/stripe/src/main/java/com/stripe/android/model/PaymentMethod.kt index 1ade1f4d5b7..a4dd864d727 100644 --- a/stripe/src/main/java/com/stripe/android/model/PaymentMethod.kt +++ b/stripe/src/main/java/com/stripe/android/model/PaymentMethod.kt @@ -537,9 +537,9 @@ data class PaymentMethod internal constructor( @Parcelize data class Networks( - private val available: Set = emptySet(), - private val selectionMandatory: Boolean = false, - private val preferred: String? = null + val available: Set = emptySet(), + val selectionMandatory: Boolean = false, + val preferred: String? = null ) : StripeModel } diff --git a/stripe/src/test/java/com/stripe/android/ApiKeyFixtures.kt b/stripe/src/test/java/com/stripe/android/ApiKeyFixtures.kt index 1943a42dd59..989f6d52ead 100644 --- a/stripe/src/test/java/com/stripe/android/ApiKeyFixtures.kt +++ b/stripe/src/test/java/com/stripe/android/ApiKeyFixtures.kt @@ -17,4 +17,5 @@ internal object ApiKeyFixtures { const val EPS_PUBLISHABLE_KEY = "pk_test_vOo1umqsYxSrP5UXfOeL3ecm" const val OXXO_PUBLISHABLE_KEY = "pk_test_bjqpeDIsfh4Bnwok0rtnrS7200PY7PLRfb" const val ALIPAY_PUBLISHABLE_KEY = "pk_test_vOo1umqsYxSrP5UXfOeL3ecm" + const val CB_PUBLISHABLE_KEY = "pk_test_51Gsr5VLtxFHECmaoeyWTxRKLZZiks5QKbg5H0IeGd8yt7OzQhA7807thLrHayMOeDRmJv3ara1VYy6AvBXAnUGcB00QAZheC0Z" } diff --git a/stripe/src/test/java/com/stripe/android/StripeEndToEndTest.kt b/stripe/src/test/java/com/stripe/android/StripeEndToEndTest.kt index e90a2dbd217..befee375bfa 100644 --- a/stripe/src/test/java/com/stripe/android/StripeEndToEndTest.kt +++ b/stripe/src/test/java/com/stripe/android/StripeEndToEndTest.kt @@ -11,6 +11,7 @@ import com.stripe.android.model.AccountParams import com.stripe.android.model.AddressFixtures import com.stripe.android.model.PaymentIntent import com.stripe.android.model.PaymentMethod +import com.stripe.android.model.PaymentMethodCreateParams import com.stripe.android.model.PaymentMethodCreateParamsFixtures import com.stripe.android.model.SetupIntent import com.stripe.android.model.Token @@ -88,6 +89,41 @@ class StripeEndToEndTest { ) } + @Test + fun `createPaymentMethod with CB cards should create expected Networks object`() { + val stripe = Stripe(context, ApiKeyFixtures.CB_PUBLISHABLE_KEY) + val createPaymentMethod = { number: String -> + stripe.createPaymentMethodSynchronous( + paymentMethodCreateParams = PaymentMethodCreateParams.create( + card = PaymentMethodCreateParams.Card( + number = number, + expiryMonth = 1, + expiryYear = 2025, + cvc = "123" + ) + ) + ) + } + + assertThat(createPaymentMethod("4000002500001001")?.card?.networks) + .isEqualTo( + PaymentMethod.Card.Networks( + available = setOf("visa"), + selectionMandatory = false, + preferred = null + ) + ) + + assertThat(createPaymentMethod("5555552500001001")?.card?.networks) + .isEqualTo( + PaymentMethod.Card.Networks( + available = setOf("mastercard"), + selectionMandatory = false, + preferred = null + ) + ) + } + private fun createStripeWithTestScope( publishableKey: String = ApiKeyFixtures.DEFAULT_PUBLISHABLE_KEY ): Stripe {