How can I show alert after flutter wave payment succeeds?

Hi everyone, I implemented a flutterwave payment for a client, after the customer's payment completes and the charge is successful I would like a way to alert the the user that their payment went through.


I tried implementing this by calling the alert function inside the callback parameter like this:


                                callback: function(response) {
                                    var txref = response.data.txRef; // collect txRef returned and pass to a                   server page to complete status check.
                                    console.log("This is the response returned after a charge", response);
                                    if (
                                       response.data.chargeResponseCode == "00" ||
                                       response.data.chargeResponseCode == "0"
                                    ) {
                                     alert('Success!');
                                       // redirect to a success page
                                    } else {
                                       // redirect to a failure page.
                                    }

                                    x.close(); // use this to close the modal immediately after payment.
                                 }

But it's not working and I don't know why, Forgive my noobness but I never truly learned javascript 😅 please help me out here guys.

Comments

Sign In or Register to comment.