Skip to content

Commit

Permalink
Improve migration guide
Browse files Browse the repository at this point in the history
COAND-944
  • Loading branch information
OscarSpruit committed Nov 18, 2024
1 parent 9152ea3 commit afc18b0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
4 changes: 3 additions & 1 deletion docs/payment-methods/GOOGLE_PAY.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,6 @@ The `com.google.pay.button:compose-pay-button` dependency can now also be remove

### 3. Google Pay availability check

The `GooglePayComponent` now does the availability check on initialization and will return a `GooglePayUnavailableException` in `onError`. You no longer need to manually call `GooglePayComponent.PROVIDER.isAvailable(…)`.
You no longer need to call `GooglePayComponent.PROVIDER.isAvailable(…)`.

The`GooglePayComponent` now checks if Google Pay is available when you initialize it. If Google Pay is not available, you get a `GooglePayUnavailableException` in `onError`.
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,26 @@ internal class GooglePayViewModel @Inject constructor(
),
)

val paymentMethod = paymentMethodResponse
?.paymentMethods
?.firstOrNull { GooglePayComponent.PROVIDER.isPaymentMethodSupported(it) }

if (paymentMethod == null) {
@Suppress("RestrictedApi")
_viewState.emit(GooglePayViewState.Error(UICoreR.string.error_dialog_title))
return@withContext
}
val paymentMethod = paymentMethodResponse
?.paymentMethods
?.firstOrNull { GooglePayComponent.PROVIDER.isPaymentMethodSupported(it) }

if (paymentMethod == null) {
@Suppress("RestrictedApi")
_viewState.emit(GooglePayViewState.Error(UICoreR.string.error_dialog_title))
return@withContext
}

_googleComponentDataFlow.emit(
GooglePayComponentData(
paymentMethod,
checkoutConfiguration,
this@GooglePayViewModel,
),
)
_googleComponentDataFlow.emit(
GooglePayComponentData(
paymentMethod,
checkoutConfiguration,
this@GooglePayViewModel,
),
)

checkGooglePayAvailability(paymentMethod, checkoutConfiguration)
}
checkGooglePayAvailability(paymentMethod, checkoutConfiguration)
}

private fun checkGooglePayAvailability(
paymentMethod: PaymentMethod,
Expand Down

0 comments on commit afc18b0

Please sign in to comment.