本文介绍了方形付款表单无法执行requestCardNonce()以在Firefox 48.0.2中获得随机数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还向Square支持小组提交了一个请求,希望很快能收到答复.

I've also submitted a request to Square support and hope to hear back soon.

复制步骤

  • Load the Square payment form (copy-pasta from https://docs.connect.squareup.com/articles/adding-payment-form/#samplewebpage and add your Application ID and uncomment the lines to submit a request to the server) in Firefox 48.0.2 (latest release as of today). Here's a test URL: https://wideningwontwork.org/test.html
  • Leave all fields blank.
  • Click "Submit Query" button.

期望

  • 所有字段均应以红色突出显示,以指示必填字段.

观察

  • Firefox无法触发事件requestCardNonce(),因为它未定义. Firefox控制台中的错误消息:

  • Firefox cannot fire the event requestCardNonce() because it is not defined. Error message in Firefox console:

ReferenceError: event is not defined
requestCardNonce()    payment:121
onclick()    payment:1

  • 使用nonce ="(空字符串或NULL)将表单提交到服务器.

  • Form is submitted to the server with nonce = "" (empty string or NULL).

    推荐答案

    很遗憾,我们已经在我们正在处理的文档中发布了一个错误. Firefox要求将事件作为参数传递给函数,而chrome和safari则不需要.如果将示例中复制的requestCardNonce的定义编辑为以下内容,则它应该对您有用:

    Unfortunately, we've published a bug in the documentation We're working on it. Firefox requires an event to be passed as an argument to the function, whereas chrome and safari don't. If you edit the definition of requestCardNonce that you copied from the example to instead be the following, it should work for you:

    function requestCardNonce(event) {
      event.preventDefault();
      paymentForm.requestCardNonce();
    }
    

    注意事件参数.那是您必须添加的部分.对困惑感到抱歉.我们将修复文档.

    Notice the event argument. That's the part you have to add. Sorry for the confusion. We'll fix the docs.

    已编辑,其中包含截至2016-08-31 17:04:43的当前屏幕截图.这是脚本中需要在函数定义中添加事件自变量,然后需要在提交按钮上向函数调用提供事件自变量的位置.

    edited to include a current screenshot as of 2016-08-31 17:04:43. This is the location in the script where you need to add an event argument to the function definition, and then where you need to provide the event argument to the function call on the submit button.

    在两个地方都使用firefox添加了事件,我在您的测试表单中得到了以下内容:

    Having added event in both places, using firefox, I've gotten the following with your test form:

    这篇关于方形付款表单无法执行requestCardNonce()以在Firefox 48.0.2中获得随机数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

  • 07-24 23:29