简体   繁体   English

Paypal Express Checkout窗口不断加载

[英]Paypal Express Checkout window keeps loading

I'm trying to integrate the PayPal button to execute a simple payment to a new Paypal account I just created. 我正在尝试集成PayPal按钮,以对刚刚创建的新Paypal帐户执行简单付款。 Following the guide I rendered the button, but when I click on it and the new window shows up, nothing happens. 按照指南,我渲染了按钮,但是当我单击它并显示新窗口时,什么也没有发生。 The "loading lock" keeps spinning, but no errors are shown in the new window, nor in my page. “加载锁”一直在旋转,但是在新窗口和我的页面中均未显示任何错误。 No calls to "onError()" function are executed. 不执行对“ onError()”函数的调用。 I don't know what's wrong! 我不知道怎么了! I followed the instruction of the guide! 我按照指南的指示!

Navigating other websites I saw that in the new window, while loading (and the "loading lock" spins) some get/post are executed, nothing is executed in my case. 浏览其他网站时,我看到在新窗口中,在加载(和“加载锁”自旋)时执行了一些get / post,在我的情况下什么也没有执行。

This is my HTML and related .js file (well, part of them) 这是我的HTML和相关的.js文件(很好,一部分)

 //THIS FUNCTION IS CALLED TO DISPLAY A NEW ELEMENT CONTAINING THE BUTTON function payment(todelete) { destroy(todelete); $("#pay").delay(timeFade).fadeIn(timeFade); paypal.Button.render({ env: 'sandbox', client: { sandbox: 'MYKEY', production: 'MYKEY' }, commit: true, payment: function(data, actions) { fetch("/getOldAmount").then(function(res){ return (res.json()); }).then(function(data){ var old_amount = data[0].Donation; var amount_tot = $("#amount").val(); //BUILDING A RANDOM TEST JSON, NOT RELATED TO MY CODE var payment_json = { transactions: [ { amount: { total: '1.00', currency: 'USD' } } ] }; if(amount_tot > old_amount){ //WHEN CLICKING PAYPAL BUTTON I CAN SEE THIS LOG, SO EVERYTHING IS FINE HERE console.log("EXECUTING PAYPAL POST"); return actions.payment.create(payment_json); } else { console.log("Amount too low to execute transaction"); } }); }, onAuthorize: function(data, actions) { return actions.payment.execute().then(function(payment) { console.log("AUTHORIZED"); }); }, onError: function(data, actions){ console.log("ERRORRRRRR"); console.log(data); } }, '#paypal-button'); } 
 <div class="container pagination-centered" style="display: block"> <div class="form-group"> <label class="richest_header" for="amount">ENTER AMOUNT</label> <input type="text" class="form-control amount-field" id="amount" placeholder="Amount..." name="amountField"> </div> <div id="paypal-button"></div> </div> <!-- HEADER --> [...] <script src="https://www.paypalobjects.com/api/checkout.js"> <script type="text/javascript" src="assets/script/myscript.js"></script> [...] 

Do I need to do something more? 我需要做更多的事情吗? Do I need to add code? 我需要添加代码吗? Am I doing something wrong? 难道我做错了什么? Why is paypal documentation so poor? 为什么贝宝文档如此差?

您需要将承诺返还给return fetch("/getOldAmount").then(... payment() - return fetch("/getOldAmount").then(...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM