Skip to content

Commit

Permalink
Make PaymentMethod.Card.Networks fields public (#2579)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshafrir-stripe authored Jun 11, 2020
1 parent da34b8f commit 2f0c66b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,9 @@ data class PaymentMethod internal constructor(

@Parcelize
data class Networks(
private val available: Set<String> = emptySet(),
private val selectionMandatory: Boolean = false,
private val preferred: String? = null
val available: Set<String> = emptySet(),
val selectionMandatory: Boolean = false,
val preferred: String? = null
) : StripeModel
}

Expand Down
1 change: 1 addition & 0 deletions stripe/src/test/java/com/stripe/android/ApiKeyFixtures.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
36 changes: 36 additions & 0 deletions stripe/src/test/java/com/stripe/android/StripeEndToEndTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 2f0c66b

Please sign in to comment.