You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
private fun initiateCharge() {
val checkoutResultListener = object : CheckoutResultListener {
override fun onSuccess(transaction: Transaction) {
// Executed when transaction is successful
print("Paystack transaction $transaction")
}
override fun onError(exception: Throwable) {
// Executed when an error occurs
print("Paystack error $exception")
}
override fun onCancelled() {
// Executed when the user cancels the payment process
print("Paystack onCancelled()")
}
}
val email = "hellouser@gmail.com"
val amount = 1000
val currency = "NGN"
PaystackCheckout.Builder(requireActivity() as AppCompatActivity, email, amount, currency)
.build()
.charge(checkoutResultListener)
}
Error logs
2022-01-23 23:15:09.928 20620-20620/com.sample.mobile.sampleAndroid E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sample.mobile.sampleAndroid, PID: 20620
java.lang.IllegalStateException: LifecycleOwner com.sample.mobile.sampleAndroid.features.auth.activity.AuthActivity@e34c27c is attempting to register while current state is RESUMED. LifecycleOwners must call register before they are STARTED.
at androidx.activity.result.ActivityResultRegistry.register(ActivityResultRegistry.java:123)
at androidx.activity.ComponentActivity.registerForActivityResult(ComponentActivity.java:673)
at com.paystack.checkout.PaystackCheckout.charge(PaystackCheckout.kt:57)
at com.sample.mobile.sampleAndroid.features.auth.fragment.NewLoginFragment.initiateCharge(NewLoginFragment.kt:198)
at com.sample.mobile.sampleAndroid.features.auth.fragment.NewLoginFragment.access$initiateCharge(NewLoginFragment.kt:31)
at com.sample.mobile.sampleAndroid.features.auth.fragment.NewLoginFragment$onViewCreated$4$invokeSuspend$$inlined$collect$1.emit(Collect.kt:135)
at kotlinx.coroutines.flow.FlowKt__ChannelsKt.emitAllImpl$FlowKt__ChannelsKt(Channels.kt:62)
at kotlinx.coroutines.flow.FlowKt__ChannelsKt.access$emitAllImpl$FlowKt__ChannelsKt(Channels.kt:1)
at kotlinx.coroutines.flow.FlowKt__ChannelsKt$emitAllImpl$1.invokeSuspend(Unknown Source:14)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:235)
at kotlinx.coroutines.DispatchedTaskKt.resumeUnconfined(DispatchedTask.kt:191)
at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:162)
at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:406)
at kotlinx.coroutines.CancellableContinuationImpl.completeResume(CancellableContinuationImpl.kt:522)
at kotlinx.coroutines.channels.AbstractChannel$ReceiveElement.completeResumeReceive(AbstractChannel.kt:932)
at kotlinx.coroutines.channels.ArrayChannel.offerInternal(ArrayChannel.kt:76)
at kotlinx.coroutines.channels.AbstractSendChannel.trySend-JP2dKIU(AbstractChannel.kt:155)
at kotlinx.coroutines.channels.SendChannel$DefaultImpls.offer(Channel.kt:166)
at kotlinx.coroutines.channels.AbstractSendChannel.offer(AbstractChannel.kt:143)
at kotlinx.coroutines.channels.ChannelCoroutine.offer(Unknown Source:2)
at reactivecircus.flowbinding.common.SafeOfferKt.safeOffer(SafeOffer.kt:11)
at reactivecircus.flowbinding.android.view.ViewClickedFlowKt$clicks$1$listener$1.onClick(ViewClickedFlow.kt:34)
at android.view.View.performClick(View.java:7441)
at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119)
at android.view.View.performClickInternal(View.java:7418)
at android.view.View.access$3700(View.java:835)
at android.view.View$PerformClick.run(View.java:28676)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7809)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
The text was updated successfully, but these errors were encountered:
Please let me know if any of you went ahead to use this library in your projects (even temporarily).
We're currently rethinking what the payment experience on Android devices should be and would appreciate your feedback when we put something out in the near future.
I'm using this library in a fragment and I get a crash when I try to initiate a charge.
I called initiateCharge() in onViewCreated().
Issue seems similar to https://stackoverflow.com/questions/64476827/how-to-resolve-the-error-lifecycleowners-must-call-register-before-they-are-sta
Code sample:
The text was updated successfully, but these errors were encountered: