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

255
Visualizações
How to close the payment interface if the payment failed in Stripe Google pay?

Need to close the payment interface if the payment fails. Now it showing error instead of close.enter image description here

paymentRequest.on('paymentmethod', function(ev) {
    console.log('ev response',ev)
    
    that.accountService.makePaymentIntent(totAmt).then((data)=>{
      console.log("Promise resolved with: " + JSON.stringify(data));
      let clientSecret = data.data.client_secret;
      // Confirm the PaymentIntent without handling potential next actions (yet).
      stripe.confirmCardPayment(
        clientSecret,
        {payment_method: ev.paymentMethod.id},
        {handleActions: false}
      ).then(function(confirmResult) {
        console.log('confirmResult',confirmResult);

        if (confirmResult.error) {
          // Report to the browser that the payment failed, prompting it to
          // re-show the payment interface, or show an error message and close
          // the payment interface.
          ev.complete('fail');
        } else {
          // Report to the browser that the confirmation was successful, prompting
          // it to close the browser payment method collection interface.
          ev.complete('success');
          // Check if the PaymentIntent requires any actions and if so let Stripe.js
          // handle the flow. If using an API version older than "2019-02-11"
          // instead check for: `paymentIntent.status === "requires_source_action"`.
          if (confirmResult.paymentIntent.status === "requires_action") {
            // Let Stripe.js handle the rest of the payment flow.
            stripe.confirmCardPayment(clientSecret).then(function(result) {
              console.log('confirmCardPayment result',result);                  
              if (result.error) {
                // The payment failed -- ask your customer for a new payment method.
              } else {                    
                that.orderComplete(confirmResult, ev);
              }
            });
          } else {                                
            // The payment has succeeded.
            that.orderComplete(confirmResult, ev);                
          }
        }
      });
    }).catch((error)=>{
      ev.complete('success');
      console.log("Promise rejected with " + JSON.stringify(error));
      that.orderFailed(error);
    });
  });    
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

It's not possible to do this — the behaviour of the PaymentRequest sheet for Google/Apple Pay is controlled by the browser. On Chrome when you let the browser know that the payment failed(by calling ev.complete('fail')), then it shows a message and does not close the sheet. That's not something you have any way to influence I'm afraid.

about 4 years ago · Juan Pablo Isaza Relatório

0

you can use ev.complete('success') instead of ev.complete('fail')

about 4 years ago · Juan Pablo Isaza Relatório
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