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

184
Visualizações
Javascript - Return value from a callback javascript function and use it in next callback function

payresobj value is found good in the "function(instance, error, result)" scope,

Want to pass the same variable payresobj to "function(stage, expired)" , it is currently returning "undefined" , How can i pass the variable in that "function(stage, expired)" callback function to use it in the case switch scenarios.. Please Advice!

function checkout_card() {
  paysafe.checkout.setup("************************************", {
      amount: amt,
      currency: "USD",
      locale: "en_US",
      customer: {
        firstName: fname,
        lastName: lname,
        email: uemail,
        phone: "",
      },
      payout: false,
      payoutConfig: {
        maximumAmount: 999999
      },
      merchantRefNum: merchrefno,
      canEditAmount: false,
      environment: "TEST",
      singleUseCustomerToken: singletoken,
      displayPaymentMethods: ["card"],
      billingAddress: {
        street: staddress,
        city: bcity,
        zip: bzip,
        country: bcountry,
        state: bstate
      },
      simulator: "EXTERNAL",
      paymentMethodDetails: {
        card: {
          accountId: "********"
        }
      },
    },
    function(instance, error, result) {
      //console.log(error);
      if (error) {
        console.log(error);

      }

      if (result && result.paymentHandleToken) {
        payresobj = result
        return payresobj;

      } else {
        //alert(error.message);

      }
    },
    function(stage, expired) {
      console.log(stage);

      //console.log(instance)
      console.log(payresobj);
      switch (stage) {

        case "PAYMENT_HANDLE_NOT_CREATED": // Handle the scenario

          break;
        case "PAYMENT_HANDLE_CREATED": // Handle the scenario

        case "PAYMENT_HANDLE_REDIRECT": // Handle the scenario
          console.log("PAYMENT_HANDLE_REDIRECT");

          break;

        default: // Handle the scenario
          console.log("DEFAULT");

      }
    });
}
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