Skip to content

Commit

Permalink
Fix bugs & add improvements to CustomerSheet playground.
Browse files Browse the repository at this point in the history
  • Loading branch information
samer-stripe committed Apr 29, 2024
1 parent e949573 commit c49a1e7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
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)
}

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.
if (playgroundSettings[CustomerSettingsDefinition].value is CustomerType.Existing) {
playgroundSettings[CustomerSettingsDefinition] = CustomerType.New
}
}
}

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

0 comments on commit c49a1e7

Please sign in to comment.