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

Downgrade kotlin from 1.5.0 to 1.4.32 #3739

Merged
merged 8 commits into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import java.time.Duration

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlinVersion = '1.5.0'
ext.kotlinVersion = '1.4.32'
ext.dokkaVersion = '1.4.30'

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.stripe.android.model.Address
import com.stripe.android.model.PaymentMethod
import com.stripe.android.model.PaymentMethodCreateParams
import com.stripe.example.databinding.SofortActivityBinding
import java.util.Locale

class SofortPaymentMethodActivity : StripeIntentActivity() {
private val viewBinding: SofortActivityBinding by lazy {
Expand All @@ -26,7 +27,7 @@ class SofortPaymentMethodActivity : StripeIntentActivity() {
viewBinding.submit.setOnClickListener {
keyboardController.hide()

val country = viewBinding.country.text.toString().lowercase()
val country = viewBinding.country.text.toString().toLowerCase(Locale.ROOT)
createAndConfirmPaymentIntent(
country,
PaymentMethodCreateParams.create(
Expand Down
777 changes: 123 additions & 654 deletions stripe/api/stripe.api

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ class GooglePayJsonFactory constructor(
transactionInfo: TransactionInfo
): JSONObject {
return JSONObject()
.put("currencyCode", transactionInfo.currencyCode.uppercase())
.put("currencyCode", transactionInfo.currencyCode.toUpperCase(Locale.ROOT))
.put("totalPriceStatus", transactionInfo.totalPriceStatus.code)
.apply {
transactionInfo.countryCode?.let {
put("countryCode", it.uppercase())
put("countryCode", it.toUpperCase(Locale.ROOT))
}

transactionInfo.transactionId?.let {
Expand All @@ -153,7 +153,7 @@ class GooglePayJsonFactory constructor(
PayWithGoogleUtils.getPriceString(
it,
Currency.getInstance(
transactionInfo.currencyCode.uppercase()
transactionInfo.currencyCode.toUpperCase(Locale.ROOT)
)
)
)
Expand Down Expand Up @@ -370,7 +370,7 @@ class GooglePayJsonFactory constructor(
internal val normalizedAllowedCountryCodes: Set<String>
get() {
return allowedCountryCodes.map {
it.uppercase()
it.toUpperCase(Locale.ROOT)
}.toSet()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ import kotlinx.parcelize.Parcelize
@Parcelize
data class PaymentIntentResult internal constructor(
override val intent: PaymentIntent,
@Outcome override val outcomeFromFlow: Int = 0,
@Outcome private val outcomeFromFlow: Int = 0,
val failureMessage: String? = null
) : StripeIntentResult<PaymentIntent>()
) : StripeIntentResult<PaymentIntent>(outcomeFromFlow)
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ internal interface PaymentRelayStarter : AuthActivityStarter<PaymentRelayStarter
is SetupIntent -> {
SetupIntentArgs(stripeIntent, stripeAccountId)
}
else -> {
error("StripeIntent must either be a PaymentIntent or SetupIntent.")
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ import kotlinx.parcelize.Parcelize
@Parcelize
data class SetupIntentResult internal constructor(
override val intent: SetupIntent,
@Outcome override val outcomeFromFlow: Int = 0,
@Outcome private val outcomeFromFlow: Int = 0,
val failureMessage: String? = null
) : StripeIntentResult<SetupIntent>()
) : StripeIntentResult<SetupIntent>(outcomeFromFlow)
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ import com.stripe.android.model.StripeModel
*
* [intent] is a [StripeIntent] retrieved after confirmation/authentication succeeded or failed.
*/
sealed class StripeIntentResult<T : StripeIntent> : StripeModel {
abstract class StripeIntentResult<T : StripeIntent> internal constructor(
@Outcome private val outcomeFromFlow: Int
) : StripeModel {
abstract val intent: T

@Outcome
protected abstract val outcomeFromFlow: Int

@Outcome
@get:Outcome
val outcome: Int
Expand Down
3 changes: 2 additions & 1 deletion stripe/src/main/java/com/stripe/android/model/Address.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.stripe.android.ObjectBuilder
import com.stripe.android.model.parsers.AddressJsonParser
import kotlinx.parcelize.Parcelize
import org.json.JSONObject
import java.util.Locale

/**
* Model for an owner [address](https://stripe.com/docs/api#source_object-owner-address)
Expand Down Expand Up @@ -45,7 +46,7 @@ data class Address internal constructor(
}

fun setCountry(country: String?): Builder = apply {
this.country = country?.uppercase()
this.country = country?.toUpperCase(Locale.ROOT)
}

internal fun setCountryCode(countryCode: CountryCode?): Builder = apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.stripe.android.model
import android.os.Parcelable
import com.stripe.android.ObjectBuilder
import kotlinx.parcelize.Parcelize
import java.util.Locale

@Parcelize
data class AddressJapanParams(
Expand Down Expand Up @@ -77,7 +78,7 @@ data class AddressJapanParams(
* @param country Two-letter country code (ISO 3166-1 alpha-2).
*/
fun setCountry(country: String?): Builder = apply {
this.country = country?.uppercase()
this.country = country?.toUpperCase(Locale.ROOT)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ internal data class CountryCode private constructor(
fun isCA(countryCode: CountryCode?) = countryCode == CA
fun isGB(countryCode: CountryCode?) = countryCode == GB

fun create(value: String) = CountryCode(value.uppercase())
fun create(value: String) = CountryCode(value.toUpperCase(Locale.ROOT))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.stripe.android.Stripe
import kotlinx.parcelize.Parcelize
import org.json.JSONException
import org.json.JSONObject
import java.util.Locale

/**
* Model for PaymentMethod creation parameters.
Expand Down Expand Up @@ -438,7 +439,7 @@ data class PaymentMethodCreateParams internal constructor(
) : StripeParamsModel, Parcelable {
override fun toParamMap(): Map<String, Any> {
return mapOf(
PARAM_COUNTRY to country.uppercase()
PARAM_COUNTRY to country.toUpperCase(Locale.ROOT)
)
}

Expand All @@ -453,7 +454,7 @@ data class PaymentMethodCreateParams internal constructor(
) : StripeParamsModel, Parcelable {
override fun toParamMap(): Map<String, Any> {
return mapOf(
PARAM_BANK to bank.lowercase()
PARAM_BANK to bank.toLowerCase(Locale.ROOT)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import kotlinx.parcelize.Parcelize
/**
* An interface for methods available in [PaymentIntent] and [SetupIntent]
*/
sealed interface StripeIntent : StripeModel {
interface StripeIntent : StripeModel {
/**
* Unique identifier for the object.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ internal class PaymentFlowFailureMessageFactory(
is SetupIntent -> {
createForSetupIntent(intent)
}
else -> null
}
}
outcome == StripeIntentResult.Outcome.TIMEDOUT -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal class CurrencyFormatter {
targetLocale: Locale = Locale.getDefault()
) = format(
amount,
Currency.getInstance(amountCurrencyCode.uppercase()),
Currency.getInstance(amountCurrencyCode.toUpperCase(Locale.ROOT)),
targetLocale
)

Expand Down Expand Up @@ -70,7 +70,7 @@ internal class CurrencyFormatter {
*/
return SERVER_DECIMAL_DIGITS
.filter { entry ->
entry.key.contains(currency.currencyCode.uppercase())
entry.key.contains(currency.currencyCode.toUpperCase(Locale.ROOT))
}.map {
it.value
}.firstOrNull() ?: currency.defaultFractionDigits
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.widget.Filter
import android.widget.TextView
import com.stripe.android.R
import java.lang.ref.WeakReference
import java.util.Locale

/**
* Adapter that populates a list of countries for a spinner.
Expand Down Expand Up @@ -127,8 +128,8 @@ internal class CountryAdapter(
private fun getSuggestedCountries(constraint: CharSequence?): List<Country> {
return unfilteredCountries
.filter {
it.name.lowercase().startsWith(
constraint.toString().lowercase()
it.name.toLowerCase(Locale.ROOT).startsWith(
constraint.toString().toLowerCase(Locale.ROOT)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal object CountryUtils {
return listOfNotNull(getCountryByCode(currentLocale.getCountryCode(), currentLocale))
.plus(
localizedCountries(currentLocale)
.sortedBy { it.name.lowercase() }
.sortedBy { it.name.toLowerCase(Locale.ROOT) }
.filterNot { it.code == currentLocale.getCountryCode() }
)
}
Expand All @@ -60,7 +60,7 @@ internal object CountryUtils {
)
@JvmSynthetic
internal fun doesCountryUsePostalCode(countryCode: String): Boolean {
return !NO_POSTAL_CODE_COUNTRIES.contains(countryCode.uppercase())
return !NO_POSTAL_CODE_COUNTRIES.contains(countryCode.toUpperCase(Locale.ROOT))
}

@JvmSynthetic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import kotlin.test.Ignore
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertIs
import kotlin.test.assertTrue

@RunWith(RobolectricTestRunner::class)
@ExperimentalCoroutinesApi
Expand Down Expand Up @@ -419,12 +419,12 @@ internal class StripeApiRepositoryTest {
)

verify(stripeApiRequestExecutor).execute(apiRequestArgumentCaptor.capture())
val requestParams = apiRequestArgumentCaptor.firstValue.params.orEmpty()
val paymentMethodParams = assertIs<Map<String, *>>(requestParams["payment_method_data"])
assertIs<String>(paymentMethodParams["muid"])
assertIs<String>(paymentMethodParams["guid"])
assertThat(paymentMethodParams["type"])
.isEqualTo("card")
val apiRequest = apiRequestArgumentCaptor.firstValue
val paymentMethodDataParams =
apiRequest.params?.get("payment_method_data") as Map<String, *>
assertTrue(paymentMethodDataParams["muid"] is String)
assertTrue(paymentMethodDataParams["guid"] is String)
assertEquals("card", paymentMethodDataParams["type"])

verifyFingerprintAndAnalyticsRequests(AnalyticsEvent.PaymentIntentConfirm)

Expand Down