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

Move BillingDetailsCollectionConfiguration into PaymentSheet #6551

Merged
merged 11 commits into from
Apr 17, 2023
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## XX.XX.XX - 2023-XX-XX

## 20.23.1 - 2023-04-17

### PaymentSheet
* [FIXED][6551](https://github.com/stripe/stripe-android/pull/6551) Fixed a build issue where `BillingDetailsCollectionConfiguration` couldn't be found in the classpath. If you worked around this issue by importing `payments-ui-core` directly, undo this change and update the import of `BillingDetailsCollectionConfiguration` to `com.stripe.android.paymentsheet.PaymentSheet.BillingDetailsCollectionConfiguration`.

## 20.23.0 - 2023-04-17

### PaymentSheet
Expand Down
55 changes: 7 additions & 48 deletions payments-ui-core/api/payments-ui-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -22,62 +22,21 @@ public final class com/stripe/android/ui/core/Amount$Creator : android/os/Parcel
public synthetic fun newArray (I)[Ljava/lang/Object;
}

public final class com/stripe/android/ui/core/BillingDetailsCollectionConfiguration : android/os/Parcelable {
public static final field $stable I
public static final field CREATOR Landroid/os/Parcelable$Creator;
public final class com/stripe/android/ui/core/BuildConfig {
public static final field BUILD_TYPE Ljava/lang/String;
public static final field DEBUG Z
public static final field LIBRARY_PACKAGE_NAME Ljava/lang/String;
public fun <init> ()V
public fun <init> (Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$AddressCollectionMode;Z)V
public synthetic fun <init> (Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$AddressCollectionMode;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;
public final fun component2 ()Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;
public final fun component3 ()Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;
public final fun component4 ()Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$AddressCollectionMode;
public final fun component5 ()Z
public final fun copy (Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$AddressCollectionMode;Z)Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration;
public static synthetic fun copy$default (Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration;Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$AddressCollectionMode;ZILjava/lang/Object;)Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration;
public fun describeContents ()I
public fun equals (Ljava/lang/Object;)Z
public final fun getAddress ()Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$AddressCollectionMode;
public final fun getAttachDefaultsToPaymentMethod ()Z
public final fun getEmail ()Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;
public final fun getName ()Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;
public final fun getPhone ()Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
public fun writeToParcel (Landroid/os/Parcel;I)V
}

public final class com/stripe/android/ui/core/BillingDetailsCollectionConfiguration$AddressCollectionMode : java/lang/Enum {
public static final field Automatic Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$AddressCollectionMode;
public static final field Full Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$AddressCollectionMode;
public static final field Never Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$AddressCollectionMode;
public static fun valueOf (Ljava/lang/String;)Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$AddressCollectionMode;
public static fun values ()[Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$AddressCollectionMode;
}

public final class com/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode : java/lang/Enum {
public static final field Always Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;
public static final field Automatic Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;
public static final field Never Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;
public static fun valueOf (Ljava/lang/String;)Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;
public static fun values ()[Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration$CollectionMode;
}

public final class com/stripe/android/ui/core/BillingDetailsCollectionConfiguration$Creator : android/os/Parcelable$Creator {
public final class com/stripe/android/ui/core/CardBillingDetailsCollectionConfiguration$Creator : android/os/Parcelable$Creator {
public fun <init> ()V
public final fun createFromParcel (Landroid/os/Parcel;)Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration;
public final fun createFromParcel (Landroid/os/Parcel;)Lcom/stripe/android/ui/core/CardBillingDetailsCollectionConfiguration;
public synthetic fun createFromParcel (Landroid/os/Parcel;)Ljava/lang/Object;
public final fun newArray (I)[Lcom/stripe/android/ui/core/BillingDetailsCollectionConfiguration;
public final fun newArray (I)[Lcom/stripe/android/ui/core/CardBillingDetailsCollectionConfiguration;
public synthetic fun newArray (I)[Ljava/lang/Object;
}

public final class com/stripe/android/ui/core/BuildConfig {
public static final field BUILD_TYPE Ljava/lang/String;
public static final field DEBUG Z
public static final field LIBRARY_PACKAGE_NAME Ljava/lang/String;
public fun <init> ()V
}

public final class com/stripe/android/ui/core/FieldValuesToParamsMapConverter$Companion {
public final fun transformToPaymentMethodCreateParams (Ljava/util/Map;Ljava/lang/String;Z)Lcom/stripe/android/model/PaymentMethodCreateParams;
}
Expand Down
4 changes: 2 additions & 2 deletions payments-ui-core/detekt-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<ID>ConstructorParameterNaming:CardNumberElement.kt$CardNumberElement$val _identifier: IdentifierSpec</ID>
<ID>ConstructorParameterNaming:CvcElement.kt$CvcElement$val _identifier: IdentifierSpec</ID>
<ID>CyclomaticComplexMethod:FormItemSpec.kt$FormItemSpecSerializer$override fun selectDeserializer(element: JsonElement): DeserializationStrategy&lt;out FormItemSpec></ID>
<ID>CyclomaticComplexMethod:LpmRepository.kt$LpmRepository$private fun convertToSupportedPaymentMethod( stripeIntent: StripeIntent, sharedDataSpec: SharedDataSpec, billingDetailsCollectionConfiguration: BillingDetailsCollectionConfiguration = BillingDetailsCollectionConfiguration() )</ID>
<ID>CyclomaticComplexMethod:LpmRepository.kt$LpmRepository$private fun convertToSupportedPaymentMethod( stripeIntent: StripeIntent, sharedDataSpec: SharedDataSpec, cardBillingDetailsCollectionConfiguration: CardBillingDetailsCollectionConfiguration, )</ID>
<ID>CyclomaticComplexMethod:TransformGoogleToStripeAddress.kt$@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun Place.transformGoogleToStripeAddress( context: Context ): com.stripe.android.model.Address</ID>
<ID>CyclomaticComplexMethod:TransformSpecToElements.kt$TransformSpecToElements$fun transform(list: List&lt;FormItemSpec>): List&lt;FormElement></ID>
<ID>EmptyFunctionBlock:CardNumberViewOnlyController.kt$CardNumberViewOnlyController${}</ID>
<ID>ForbiddenComment:Menu.kt$// TODO: Make sure this gets the rounded corner values</ID>
<ID>LongMethod:LpmRepository.kt$LpmRepository$private fun convertToSupportedPaymentMethod( stripeIntent: StripeIntent, sharedDataSpec: SharedDataSpec, billingDetailsCollectionConfiguration: BillingDetailsCollectionConfiguration = BillingDetailsCollectionConfiguration() )</ID>
<ID>LongMethod:LpmRepository.kt$LpmRepository$private fun convertToSupportedPaymentMethod( stripeIntent: StripeIntent, sharedDataSpec: SharedDataSpec, cardBillingDetailsCollectionConfiguration: CardBillingDetailsCollectionConfiguration, )</ID>
<ID>LongMethod:Menu.kt$@Suppress("ModifierParameter") @Composable internal fun DropdownMenuContent( expandedStates: MutableTransitionState&lt;Boolean>, transformOriginState: MutableState&lt;TransformOrigin>, initialFirstVisibleItemIndex: Int, modifier: Modifier = Modifier, content: LazyListScope.() -> Unit )</ID>
<ID>LongMethod:TransformGoogleToStripeAddress.kt$@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) fun Place.transformGoogleToStripeAddress( context: Context ): com.stripe.android.model.Address</ID>
<ID>LongMethod:TransformGoogleToStripeAddressTest.kt$TransformGoogleToStripeAddressTest$@Test fun `test JP address`()</ID>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.stripe.android.ui.core

import android.os.Parcelable
import androidx.annotation.RestrictTo
import kotlinx.parcelize.Parcelize

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@Parcelize
data class CardBillingDetailsCollectionConfiguration(
val collectName: Boolean = false,
val collectEmail: Boolean = false,
val collectPhone: Boolean = false,
val address: AddressCollectionMode = AddressCollectionMode.Automatic,
) : Parcelable {

val collectAddress: Boolean
get() = address != AddressCollectionMode.Never

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
enum class AddressCollectionMode {
Automatic,
Never,
Full,
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.stripe.android.ui.core.elements

import androidx.annotation.RestrictTo
import com.stripe.android.ui.core.BillingDetailsCollectionConfiguration
import com.stripe.android.ui.core.CardBillingDetailsCollectionConfiguration
import com.stripe.android.uicore.address.AddressRepository
import com.stripe.android.uicore.address.FieldType
import com.stripe.android.uicore.elements.AddressElement
Expand Down Expand Up @@ -30,8 +30,8 @@ class CardBillingAddressElement(
),
sameAsShippingElement: SameAsShippingElement?,
shippingValuesMap: Map<IdentifierSpec, String?>?,
private val collectionMode: BillingDetailsCollectionConfiguration.AddressCollectionMode =
BillingDetailsCollectionConfiguration.AddressCollectionMode.Automatic,
private val collectionMode: CardBillingDetailsCollectionConfiguration.AddressCollectionMode =
CardBillingDetailsCollectionConfiguration.AddressCollectionMode.Automatic,
) : AddressElement(
identifier,
addressRepository,
Expand All @@ -47,15 +47,15 @@ class CardBillingAddressElement(
val hiddenIdentifiers: Flow<Set<IdentifierSpec>> =
countryDropdownFieldController.rawFieldValue.map { countryCode ->
when (collectionMode) {
BillingDetailsCollectionConfiguration.AddressCollectionMode.Never -> {
CardBillingDetailsCollectionConfiguration.AddressCollectionMode.Never -> {
FieldType.values()
.map { it.identifierSpec }
.toSet()
}
BillingDetailsCollectionConfiguration.AddressCollectionMode.Full -> {
CardBillingDetailsCollectionConfiguration.AddressCollectionMode.Full -> {
emptySet()
}
BillingDetailsCollectionConfiguration.AddressCollectionMode.Automatic -> {
CardBillingDetailsCollectionConfiguration.AddressCollectionMode.Automatic -> {
when (countryCode) {
"US", "GB", "CA" -> {
FieldType.values()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.stripe.android.ui.core.elements

import androidx.annotation.RestrictTo
import com.stripe.android.ui.core.BillingDetailsCollectionConfiguration
import com.stripe.android.ui.core.CardBillingDetailsCollectionConfiguration
import com.stripe.android.ui.core.R
import com.stripe.android.uicore.address.AddressRepository
import com.stripe.android.uicore.elements.IdentifierSpec
Expand All @@ -20,15 +20,15 @@ data class CardBillingSpec(
@SerialName("allowed_country_codes")
val allowedCountryCodes: Set<String> = supportedBillingCountries,
@SerialName("collection_mode")
val collectionMode: BillingDetailsCollectionConfiguration.AddressCollectionMode =
BillingDetailsCollectionConfiguration.AddressCollectionMode.Automatic,
val collectionMode: CardBillingDetailsCollectionConfiguration.AddressCollectionMode =
CardBillingDetailsCollectionConfiguration.AddressCollectionMode.Automatic,
) : FormItemSpec() {
fun transform(
initialValues: Map<IdentifierSpec, String?>,
addressRepository: AddressRepository,
shippingValues: Map<IdentifierSpec, String?>?,
): SectionElement? {
if (collectionMode == BillingDetailsCollectionConfiguration.AddressCollectionMode.Never) {
if (collectionMode == CardBillingDetailsCollectionConfiguration.AddressCollectionMode.Never) {
tillh-stripe marked this conversation as resolved.
Show resolved Hide resolved
return null
}

Expand Down
Loading