Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make PaymentMethod.Card.Networks fields public #2579

Merged
merged 1 commit into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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