Braintree'payment_method_nonce'返回为空

问题描述 投票:0回答:2

我对Braintree还是很陌生。我在沙盒环境中集成了DropIn UI。提交表单后,“ payment_method_nonce”返回空值,这使交易失败。 DropIn UI在特定的div中正确显示,并且为了确保一切正常,我为PaymentMethodNonce添加了一个占位符,该占位符为“ fake-valid-nonce”,这使交易有效。我一直坚持为什么Braintree服务器没有发回Nonce值。

我对token.php进行Ajax调用,以获取使DropIn UI正确呈现的客户端令牌。

下面的Ajax呼叫:

<script>
    $.ajax({
    url: "/braintree/token.php",
    type: "get",
    dataType: "json",
    success: function (data) {
        braintree.setup(data, 'dropin', {container: 'dropin-container'});
    );
</script>

这是生成客户端令牌的token.php:

需要(“ braintree.php”);$ clientToken = $ gateway-> clientToken()-> generate();回声json_encode($ clientToken);

[当我检查HTML时,BrainTree显示一个'server-error-message'div,并且显示“处理您的请求时出错。请重试。”关于此问题的其他帖子也提到了可以设置和提交HTML表单的方式可能会导致此问题。

这是我的表格:

    <div class="container">
    <div class="row flex-nowrap">
        <div class="alpha-container col-12">
            <div class="content-container">
                <form id="infoForm" method="post" action="/congrats.php">

                    <div class="tab">
                        <h2>Pick a Time</h2>
                        <div>
                            <!-- Google Schedule API goes here -->
                        </div>
                        <div>
                            <h4>Distance:</h4>
                            <p></p>
                            <br>
                            <h4>Duration:</h4>
                            <p></p>
                            <h4>Estimate:</h4>
                            <p></p>
                        </div>
                    </div>

                    <div class="tab">
                        <h2>Contact Information</h2>
                        <div class="contact-form">
                            <div class="contact-block">
                                <label for="fullname"></label>
                                <input type="text" name="Data[fullname]" class="contact" placeholder="Full Name">
                            </div>

                            <div class="contact-block">
                                <label for="email"></label>
                                <input type="email" name="Data[email]" class="contact" placeholder="Email Address">
                            </div>

                            <div class="contact-block">
                                <label for="phonenumber"></label>
                                <input type="number" name="Data[phonenumber]" class="contact" placeholder="Phone Number">
                            </div>
                        </div>
                    </div>

                    <div class="tab">
                        <h2>Payment Information</h2>
                        <div class="payment-form">
                            <label for="firstName"></label>
                            <input type="text" placeholder="First Name" name="Data[first_name]">

                            <label for="lastName"></label>
                            <input type="text" placeholder="Last Name" name="Data[last_name]">

                            <div id="dropin-container"></div>
                        </div>
                    </div>

                    <!-- Next/Previous Buttons -->
                    <div style="overflow:auto;">
                        <div style="float:right;">
                            <button type="button" id="prevBtn" onclick="nextPrev(-1)">Previous</button>
                            <button type="button" id="nextBtn" onclick="nextPrev(1)">Next</button>
                        </div>
                    </div>
                    <!--Progress Bar -->
                    <div style="text-align:center;margin-top:40px;">
                        <span class="step"></span>
                        <span class="step"></span>
                        <span class="step"></span>
                    </div>

                </form>
            </div>
        </div>
    </div>
</div>

表单使用Javascript隐藏表单的步骤,然后添加一个Submit按钮,然后它到达了最后一步。 “ congrats.php”是我要处理交易的地方。我在标头中同时包含jQuery和Braintree JS。

javascript php ajax braintree nonce
2个回答
0
投票

我的HTML表单结构似乎不正确。我正在使用w3schools的表单,该表单使用javascript添加了一个提交按钮。我的新表单现在使用type = submit的按钮标记。我不认为Braintree的服务器知道我实际上正在提交付款信息,但并不完全确定。


-1
投票

标记为正确,我给了你答案,这是在浪费我的时间而没有做。

© www.soinside.com 2019 - 2024. All rights reserved.