-
Notifications
You must be signed in to change notification settings - Fork 628
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
Add shipping details to payment sheet #5419
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,16 +72,19 @@ internal class PaymentMethodViewModel @Inject constructor( | |
val formController = MutableStateFlow<FormController?>(null) | ||
|
||
fun init(loadFromArgs: Boolean) { | ||
val cardMap = args.prefilledCardParams?.toParamMap() | ||
?.takeIf { loadFromArgs } | ||
?.let { convertToFormValuesMap(it) } | ||
?: emptyMap() | ||
val initialValuesMap = args.initialValueMap | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
?: emptyMap() | ||
val combinedMap = cardMap + initialValuesMap | ||
formController.value = | ||
formControllerProvider.get() | ||
.formSpec(LayoutSpec(paymentMethod.formSpec)) | ||
.viewOnlyFields(emptySet()) | ||
.viewModelScope(viewModelScope) | ||
.initialValues( | ||
args.prefilledCardParams?.toParamMap()?.takeIf { loadFromArgs }?.let { | ||
convertToFormValuesMap(it) | ||
} ?: emptyMap() | ||
) | ||
.initialValues(combinedMap) | ||
.stripeIntent(args.stripeIntent) | ||
.merchantName(args.merchantName) | ||
.build().formController | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ class LinkActivityContractTest { | |
"customer@email.com", | ||
"1234567890", | ||
null, | ||
null, | ||
injectionParams | ||
) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.stripe.android.ui.core.address | ||
|
||
import android.os.Parcelable | ||
import com.stripe.android.model.Address | ||
import kotlinx.parcelize.Parcelize | ||
|
||
@Parcelize | ||
data class ShippingAddress( | ||
tillh-stripe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
val name: String?, | ||
val phone: String?, | ||
val address: Address?, | ||
val sameAsShippingEnabled: Boolean? | ||
) : Parcelable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make the names more descriptive? It's not clear what's in the map. Something like INITIAL_SHIPPING_ADDRESS_VALUES_MAP, initialShippingAddressValuesMap is clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or if you're thinking of making this generic (not only for shipping address), maybe
initialFormValuesMap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can make it less genericI like
initialFormValuesMap