Giter Club home page Giter Club logo

Comments (7)

mstuart avatar mstuart commented on May 28, 2024 1

Hi @cfreyre, we're looking into this. Thanks!

from paypal-js.

gabrielo91 avatar gabrielo91 commented on May 28, 2024 1

@cfreyre we were able to reproduce the bug and we are working on it now, we'll let u know when we have some news. Thanks!

from paypal-js.

gabrielo91 avatar gabrielo91 commented on May 28, 2024 1

Hi @cfreyre, the fix has been released, please try it out and let us know, thanks!

from paypal-js.

cfreyre avatar cfreyre commented on May 28, 2024 1

@gabrielo91 Thank You . It is Working Fine. ¡Muchas Gracias! ; )

from paypal-js.

gabrielo91 avatar gabrielo91 commented on May 28, 2024

Hi @cfreyre, we were trying to reproduce the error and it seems it is working fine, we used the below code snippet. We see the exact same behavior in desktop and mobile, first, the on click alert is launched, and then the creating order one. Could you please provide some extra information about it or let us know if with such a code snippet do you have the same issue?

Thanks!

<!DOCTYPE html>
<html>
  <head>
    <title>Checkout Standard Integration</title>
    <meta charset="UTF-8" />
  </head>
  <body>
    <div id="paypal-button-container"></div>
    <script src="https://www.paypal.com/sdk/js?client-id=AWx1gpCaWDcvW0Tfxwf6gqMuvRkxVyhYPKJIEB6KVO3AdxxZJVnNaFxbQkemez5VwrqpkcMbRN8ZGJ-j"></script>
    <script>
      paypal.Buttons({
      createOrder: function (data, actions) {
          alert('creating order')
          return actions.order.create({
              purchase_units: [{
                  amount: {
                      value: '50.00'
                  }
              }]
          });
      }
  }).render('#paypal-button-container').setAttribute('onClick', alert('on click'));
    </script>
  </body>
</html>

from paypal-js.

cfreyre avatar cfreyre commented on May 28, 2024

Hi, thanks @gabrielo91. Working more on the error, I think it is actually not in the onClick button per se, I think it may be in the "action.resolve" function. My code calls a file in "onClick Method" and the method "actions.resolve ();" doesn't work well. I don't know if this behavior has to do with what was reported here: https://github.com/paypal/paypal-checkout-components/issues/1657

It is worth mentioning that it was working perfect a month ago.

This is my Code:

              paypal.Buttons({
              createOrder: function(data, actions) {
                  return actions.order.create({
                      intent:"CAPTURE",
                      shippingAddressEditable: false,
                      purchase_units: [{
                          amount: {
                            value: "500",
                            breakdown: {
                              item_total: {
                                currency_code: "MXN",
                                value: "50"
                              },
                              shipping: {
                                currency_code: "MXN",
                                value: "10"
                              }
                            }
                          },
                          invoice_id:inputVal,
                          description: "Pedido 500 realizado en example.com",
                          custom_id: inputVal,
                          shipping: {
                            method: "UPS",
                            address: {
                              name: {
                                full_name: "George Benson"
                              },
                              ...
                              ...
                            }
                          }
                      }],
                  });
              },
            onApprove: function(data, actions) {
                  return actions.order.capture().then(function(details) {
                      var url = "onApprove_file.php";
                      var data = details;
                      fetch(url, {
                        method: "POST",
                        body: JSON.stringify(data),
                        headers:{
                          "Content-Type": "application/json"
                        }
                      })
                      .then(response => window.location.replace("another_file.php"));
              });
            },
            onClick: function(data, actions) {
              return fetch("checkout_prefix.php", {
                method: "post"
              }).then(function(res) {
                return res.json();
              }).then(function(data) {
                if (data.validationError) {
                  return actions.reject();
                } else {
                  document.getElementById("paypal-button-container").classList.add("hidden");
                  document.getElementById("paypal-message").classList.add("hidden");
                  document.getElementById("paypal-wait").classList.remove("hidden");
                  return actions.resolve();
                }
              });
            }
          }).render("#paypal-button-container");
       });

from paypal-js.

gabrielo91 avatar gabrielo91 commented on May 28, 2024

Hi @cfreyre, we released the fix. Please re-open this if it’s still an issue for you.

from paypal-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.