Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

134
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda