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

Deprecate Card.create() #2677

Merged
merged 1 commit into from
Aug 3, 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
7 changes: 7 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 @@ -556,6 +556,13 @@ data class Card internal constructor(
* @param expYear the expiry year
* @param cvc the CVC code
*/
@Deprecated(
"Use CardParams",
ReplaceWith(
"Builder(number, expMonth, expYear, cvc).build()",
"com.stripe.android.model.Card.Builder"
)
)
@JvmStatic
fun create(
number: String? = null,
Expand Down
11 changes: 5 additions & 6 deletions stripe/src/test/java/com/stripe/android/ApiRequestTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.stripe.android

import android.net.Uri
import com.google.common.truth.Truth.assertThat
import com.stripe.android.model.CardFixtures
import com.stripe.android.model.CardParamsFixtures
import java.io.ByteArrayOutputStream
import kotlin.test.Test
import kotlin.test.assertEquals
Expand All @@ -16,12 +16,11 @@ internal class ApiRequestTest {

@Test
fun url_withCardData_createsProperQueryString() {
val cardMap = CardFixtures.MINIMUM_CARD.toParamMap()
.plus(FINGERPRINT_DATA.params)
val url = FACTORY.createGet(
StripeApiRepository.sourcesUrl,
OPTIONS,
cardMap
url = StripeApiRepository.sourcesUrl,
options = OPTIONS,
params = CardParamsFixtures.MINIMUM.toParamMap()
.plus(FINGERPRINT_DATA.params)
).url

assertThat(Uri.parse(url))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.stripe.android

import com.google.common.truth.Truth.assertThat
import com.stripe.android.model.CardFixtures
import com.stripe.android.model.CardParamsFixtures
import com.stripe.android.model.ConfirmPaymentIntentParams
import com.stripe.android.model.ConfirmStripeIntentParams.Companion.PARAM_PAYMENT_METHOD_DATA
import com.stripe.android.model.PaymentMethodCreateParamsFixtures
Expand All @@ -20,7 +20,7 @@ class FingerprintParamsUtilsTest {
val updatedParams = fingerprintParamsUtils.addFingerprintData(
params = mapOf(
ConfirmPaymentIntentParams.PARAM_SOURCE_DATA to
SourceParams.createCardParams(CardFixtures.CARD).toParamMap()
SourceParams.createCardParams(CardParamsFixtures.DEFAULT).toParamMap()
),
fingerprintData = FINGERPRINT_DATA
)
Expand All @@ -33,19 +33,20 @@ class FingerprintParamsUtilsTest {
"address" to mapOf(
"city" to "San Francisco",
"country" to "US",
"line1" to "1234 Main Street",
"line2" to "906",
"postal_code" to "94111",
"line1" to "123 Market St",
"line2" to "#345",
"postal_code" to "94107",
"state" to "CA"
),
"name" to "Jenny Rosen"
),
"card" to mapOf(
"number" to CardNumberFixtures.VISA_NO_SPACES,
"exp_month" to 8,
"exp_year" to 2019,
"exp_month" to 12,
"exp_year" to 2025,
"cvc" to "123"
),
"metadata" to mapOf("fruit" to "orange"),
"muid" to FINGERPRINT_DATA.muid,
"guid" to FINGERPRINT_DATA.guid,
"sid" to FINGERPRINT_DATA.sid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import com.nhaarman.mockitokotlin2.whenever
import com.stripe.android.exception.APIConnectionException
import com.stripe.android.exception.InvalidRequestException
import com.stripe.android.model.BankAccountTokenParamsFixtures
import com.stripe.android.model.Card
import com.stripe.android.model.CardFixtures
import com.stripe.android.model.CardParams
import com.stripe.android.model.CardParamsFixtures
import com.stripe.android.model.ConfirmPaymentIntentParams
import com.stripe.android.model.ListPaymentMethodsParams
import com.stripe.android.model.PaymentIntentFixtures
Expand Down Expand Up @@ -187,7 +187,7 @@ class StripeApiRepositoryTest {
@Test
fun createSource_shouldLogSourceCreation_andReturnSource() {
val source = stripeApiRepository.createSource(
SourceParams.createCardParams(CARD),
SourceParams.createCardParams(CARD_PARAMS),
DEFAULT_OPTIONS
)

Expand All @@ -205,7 +205,7 @@ class StripeApiRepositoryTest {
whenever(stripeApiRequestExecutor.execute(any<ApiRequest>()))
.thenReturn(stripeResponse)
create().createSource(
SourceParams.createCardParams(CardFixtures.CARD_WITH_ATTRIBUTION),
SourceParams.createCardParams(CardParamsFixtures.WITH_ATTRIBUTION),
DEFAULT_OPTIONS
)

Expand Down Expand Up @@ -242,7 +242,7 @@ class StripeApiRepositoryTest {
@Test
fun createSource_withConnectAccount_keepsHeaderInAccount() {
val connectAccountId = "acct_1Acj2PBUgO3KuWzz"
val source = stripeApiRepository.createSource(SourceParams.createCardParams(CARD),
val source = stripeApiRepository.createSource(SourceParams.createCardParams(CARD_PARAMS),
ApiRequest.Options(ApiKeyFixtures.CONNECTED_ACCOUNT_PUBLISHABLE_KEY, connectAccountId))

// Check that we get a source back; we don't care about its fields for this test.
Expand Down Expand Up @@ -345,7 +345,7 @@ class StripeApiRepositoryTest {
ApiKeyFixtures.CONNECTED_ACCOUNT_PUBLISHABLE_KEY,
connectAccountId
),
SourceParams.createCardParams(CARD).toParamMap()
SourceParams.createCardParams(CARD_PARAMS).toParamMap()
)
)
assertNotNull(response)
Expand Down Expand Up @@ -434,7 +434,7 @@ class StripeApiRepositoryTest {
fingerprintDataRepository = fingerprintDataRepository
)
val source = stripeApiRepository.createSource(
SourceParams.createCardParams(CARD),
SourceParams.createCardParams(CARD_PARAMS),
DEFAULT_OPTIONS
)
assertNotNull(source)
Expand Down Expand Up @@ -734,7 +734,7 @@ class StripeApiRepositoryTest {

assertFailsWith<APIConnectionException> {
create().createSource(
SourceParams.createCardParams(CARD),
SourceParams.createCardParams(CARD_PARAMS),
DEFAULT_OPTIONS
)
}
Expand Down Expand Up @@ -812,7 +812,7 @@ class StripeApiRepositoryTest {
)
whenever(stripeApiRequestExecutor.execute(any<ApiRequest>())).thenReturn(stripeResponse)
create().createToken(
CardFixtures.CARD_WITH_ATTRIBUTION,
CardParamsFixtures.WITH_ATTRIBUTION,
DEFAULT_OPTIONS
)

Expand Down Expand Up @@ -935,8 +935,8 @@ class StripeApiRepositoryTest {

private companion object {
private const val STRIPE_ACCOUNT_RESPONSE_HEADER = "Stripe-Account"
private val CARD =
Card.create("4242424242424242", 1, 2050, "123")
private val CARD_PARAMS =
CardParams("4242424242424242", 1, 2050, "123")

private val DEFAULT_OPTIONS = ApiRequest.Options(ApiKeyFixtures.DEFAULT_PUBLISHABLE_KEY)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.stripe.android.model.AddressFixtures
import com.stripe.android.model.Card
import com.stripe.android.model.CardBrand
import com.stripe.android.model.CardFunding
import com.stripe.android.model.CardParamsFixture
import com.stripe.android.model.CardParamsFixtures
import com.stripe.android.model.PaymentIntent
import com.stripe.android.model.PaymentMethod
import com.stripe.android.model.PaymentMethodCreateParams
Expand Down Expand Up @@ -133,7 +133,7 @@ class StripeEndToEndTest {
@Test
fun `create Source using CardParams should return object with expected data`() {
val source = defaultStripe.createSourceSynchronous(
SourceParams.createCardParams(CardParamsFixture.DEFAULT)
SourceParams.createCardParams(CardParamsFixtures.DEFAULT)
)
assertThat(source?.sourceTypeModel)
.isEqualTo(
Expand All @@ -155,7 +155,7 @@ class StripeEndToEndTest {
@Test
fun `create card token using CardParams should return object with expected data`() {
val token = defaultStripe.createCardTokenSynchronous(
CardParamsFixture.DEFAULT
CardParamsFixtures.DEFAULT
)
val card = token?.card

Expand Down
Loading