Flutterwave / React-Native

React Native library for Flutterwave for Business (F4B) v2 and v3 APIs.
https://developer.flutterwave.com/
MIT License
6 stars 13 forks source link

onRedirect called twice #39

Closed georgeben closed 2 years ago

georgeben commented 2 years ago

I don't understand why on onRedirect is being called twice. Here's a snippet of my code.

async function handleRedirect(params) {
    console.log("Params!", params);
    if (loading) return
    setLoading(true);
    setShowPaymentDialog(false);
    if (params.status == "cancelled") {
      return;
    }
    try {
      console.log("Verifying transaction", params.tx_ref);
      const transactionResponse = await verifyTransaction(params.tx_ref);
      const transaction = transactionResponse.data.transaction;

      setTransaction(transaction);
    } catch (error) {
      console.log("Error", error);
    } finally {
      setLoading(false);
    }
  }
<FlutterwaveCheckout
          onAbort={handleAbort}
          onRedirect={handleRedirect}
          link={paymentLink || undefined}
          visible={showPaymentDialog}
        />

Please what am I doing wrong?

thecodecafe commented 2 years ago

Duplicate of https://github.com/Flutterwave/flutterwave-react-native/issues/40