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

resolve initGooglePay with error if it's not available #546

Merged
merged 1 commit into from
Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,16 @@ class GooglePayFragment : Fragment() {
private var isGooglePayLauncherReady: Boolean = false

private fun onGooglePayMethodLauncherReady(isReady: Boolean) {
if(isReady) {
isGooglePayMethodLauncherReady = true
if (isGooglePayLauncherReady) {
onGooglePayReady(true)
}
isGooglePayMethodLauncherReady = true
if (isGooglePayLauncherReady) {
onGooglePayReady(isReady)
}
}

private fun onGooglePayLauncherReady(isReady: Boolean) {
if(isReady) {
isGooglePayLauncherReady = true
if (isGooglePayMethodLauncherReady) {
onGooglePayReady(true)
}
isGooglePayLauncherReady = true
if (isGooglePayMethodLauncherReady) {
onGooglePayReady(isReady)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,13 @@ class StripeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJ
googlePayFragment = (currentActivity as AppCompatActivity).supportFragmentManager.findFragmentByTag("google_pay_launch_fragment") as GooglePayFragment
}
if (intent.action == ON_INIT_GOOGLE_PAY) {
initGooglePayPromise?.resolve(WritableNativeMap())
val isReady = intent.extras?.getBoolean("isReady") ?: false

if (isReady) {
initGooglePayPromise?.resolve(WritableNativeMap())
} else {
initGooglePayPromise?.resolve(createError(GooglePayErrorType.Failed.toString(), "Google Pay is not available on this device"))
}
}
if (intent.action == ON_GOOGLE_PAYMENT_METHOD_RESULT) {
intent.extras?.getString("error")?.let {
Expand Down