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

Add new CustomerSheet playground #8362

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ internal class CustomerSheetPlaygroundActivity : AppCompatActivity() {
callback = callback,
)

LaunchedEffect(playgroundState, customerSheet) {
LaunchedEffect(customerSheet) {
viewModel.fetchOption(customerSheet)
samer-stripe marked this conversation as resolved.
Show resolved Hide resolved
samer-stripe marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,7 @@ internal class CustomerSheetPlaygroundViewModel(
try {
CustomerAdapter.Result.success(
CustomerEphemeralKey.create(
customerId = response.customerId
?: throw IllegalStateException(
"No 'customerId' was found in backend response!"
),
customerId = response.customerId,
ephemeralKey = response.customerEphemeralKeySecret
?: throw IllegalStateException(
"No 'customerEphemeralKeySecret' was found in backend response!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ data class CustomerEphemeralKeyResponse(
@SerialName("publishableKey")
val publishableKey: String,
@SerialName("customerId")
val customerId: String? = null,
val customerId: String,
@SerialName("customerEphemeralKeySecret")
val customerEphemeralKeySecret: String? = null,
@SerialName("customerSessionClientSecret")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ internal object CountrySettingsDefinition :
override fun configure(value: Country, requestBuilder: CustomerEphemeralKeyRequest.Builder) {
requestBuilder.merchantCountryCode(value.value)
}

override fun valueUpdated(value: Country, playgroundSettings: CustomerSheetPlaygroundSettings) {
// When the changes via the UI, reset the customer.
samer-stripe marked this conversation as resolved.
Show resolved Hide resolved
if (playgroundSettings[CustomerSettingsDefinition].value is CustomerType.Existing) {
playgroundSettings[CustomerSettingsDefinition] = CustomerType.New
}
}
}

enum class Country(override val value: String) : ValueEnum {
Expand Down