Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
I'm trying to complete redirect with javascript after flutterwaveinline integration

So I've been trying to complete a redirect in my javascript code but i need to pass the uniqid that's generated with the next page but it's not working i need to know how to pass the parameters to the script.php

  document.addEventListener("DOMContentLoaded", (event) => {
    // Add an event listener for when the user clicks the submit button to pay
    document.getElementById("submit").addEventListener("click", (e) => {
        
        // POST ALL PARAMETERS TO A PHP SCRIPT IN ANOTHER FILE. THAT SCRIPT WILL RECEIVE THE PARAMETERS AND INSERT INTO THE DB.

        // GENERATE YOUR REF WITH JAVASCRIPT.

        var generated_ref = functionToGenerateRef();

        $.post('script.php', {
            name: name,
            email: email,
            generated_ref: generated_ref,
        }, function (res) {

        })

        e.preventDefault();
        const PBFKey = ""; // paste in the public key from your dashboard here
        const txRef = ''+Math.floor((Math.random() * 1000000000) + 1); //Generate a random id for the transaction reference
        const email = document.getElementById('email').value;
        const phone = document.getElementById('phone').value;
        const amount = document.getElementById('amount').value;
        
       console.log('loaded')

        // getpaidSetup is Rave's inline script function. it holds the payment data to pass to Rave.
    getpaidSetup({
        PBFPubKey: PBFKey,
        customer_email: email,
        amount: amount,
        customer_phone: phone,
        currency: "NGN",  // Select the currency. leaving it empty defaults to NGN
        txref: txRef, // Pass your UNIQUE TRANSACTION REFERENCE HERE.
    
        onclose: function() {},
        callback: function(response) {
            flw_ref = response.tx.flwRef;// collect flwRef returned and pass to a server page to complete status check.
            console.log("This is the response returned after a charge", response);
            console.log(response.tx.chargeResponseCode);
            console.log(response.data.status);
            if(response.tx.chargeResponseCode == '00' || response.tx.chargeResponse == '0') {
                location.href="http://localhost/ntdc/validator/?ref=" + generated_ref;
            } else {
            // redirect to a failure page.
            }
        }
      });
    });
});
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!