0

我正在根据付款表格文档实施PayMill的信用卡付款表格。所以我从Bridge文档页面复制了 JS,从Payment Form文档页面复制了表单。

但是没有创建令牌。当我尝试调试 JS 并添加console.info(error.apierror);paymillResponseHandler(...)函数中时,我得到错误代码:field_invalid_amount.

根据支持页面

此错误消息有三个可能的原因:

  1. 未提供金额值

  2. 数字四舍五入

  3. 错误的分隔符

但是提供了 amuont,我已经尝试过不同的分隔符。“数字四舍五入”是什么意思,尚不清楚。

可能是什么问题以及如何解决此问题?

代码:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta name="generator" content="PSPad editor, www.pspad.com">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
        <title>
        </title>
    </head>
    <body>
        <!-- PayMill HEAD start -->
        <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/css/bootstrap.no-responsive.no-icons.min.css" />
        <script type="text/javascript">
            var PAYMILL_PUBLIC_KEY = '51668632777bf03b57f861c5a7278a38';
        </script>
        <script type="text/javascript" src="https://bridge.paymill.com/"></script>
        <!-- PayMill HEAD stop -->
        <!-- PayMill FORM start -->
        <form id="payment-form" class="span4" action="payment.php" method="POST">
            <p class="payment-errors alert-error span3" style="display:none;">
            </p>
            <div id="payment-form-cc">
                <div class="controls controls-row">
                    <div class="span2">
                        <label class="card-number-label">Kreditkarte
                        </label>
                        <input class="card-number span2" type="text" size="20" value="4111111111111111"/>
                    </div>
                    <div class="span1">
                        <label class="card-cvc-label">CVC
                        </label>
                        <input class="card-cvc span1" type="text" size="4" value="111"/>
                    </div>
                </div>
                <div class="controls controls-row">
                    <div class="span3 card-icon">
                    </div>
                </div>
                <div class="controls controls-row">
                    <div class="span3">
                        <label class="card-holdername-label">Karteninhaber
                        </label>
                        <input class="card-holdername span3" type="text" size="20" value="lala"/>
                    </div>
                </div>
                <div class="controls controls-row">
                    <div class="span3">
                        <label class="card-expiry-label">Gültigkeitsdatum (MM/YYYY)
                        </label>
                        <input class="card-expiry-month span1" type="text" size="2" value="12"/>
                        <span style="float:left;"> /
                        </span>
                        <input class="card-expiry-year span1" type="text" size="4" value="2015"/>
                    </div>
                </div>
            </div>
            <div class="controls controls-row">
                <div class="span2">
                    <label class="amount-label">Betrag
                    </label>
                    <input class="amount span2" type="text" size="5" value="9,99" name="amount"/>
                </div>
                <div class="span1">
                    <label class="currency-label">Währung
                    </label>
                    <input class="currency span1" type="text" size="3" value="EUR" name="currency"/>
                </div>
            </div>
            <div class="controls controls-row">
                <div class="span4">
                    <button class="submit-button btn btn-primary" type="submit" >Pay!</button>
                </div>
            </div>
        </form>
        <!-- PayMill FORM stop -->
        <!-- PayMill FOOT start -->
        <script type="text/javascript">
        function paymillResponseHandler(error, result) {
         if (error) {
            console.info(error.apierror);
           // Displays the error above the form
           $(".payment-errors").text(error.apierror);
         } else {
           console.info('OK');
           var form = $("#payment-form");
           // Output token
           var token = result.token;
           // Insert token into form in order to submit to server
           form.append(
             "<input type='hidden' name='paymillToken' value='"+token+"'/>"
           );
           // Submit form
           form.get(0).submit();
         }
        }
        </script>
        <script type="text/javascript">
        paymill.createToken({
            number:         $('.card-number').val(),       // required
            exp_month:      $('.card-expiry-month').val(), // required
            exp_year:       $('.card-expiry-year').val(),  // required
            cvc:            $('.card-cvc').val(),          // required
            amount_int:     $('.card-amount-int').val(),   // required, e.g. "4900" for 49.00 EUR
            currency:       $('.currency').val(),          // required
            cardholder:     $('.card-holdername').val()    // optional
        },
        paymillResponseHandler);
        </script>
        <!-- PayMill FOOT stop -->
    </body>
</html>
4

1 回答 1

0

在表单中,输入字段amount具有类amountspan2. 并且令牌创建功能正在检查$('.card-amount-int'). 现在我只是简单地将card-amount-int类添加到amount输入字段并且......得到另一个问题...... :) 但是这个问题已经解决了。

于 2014-06-05T15:35:14.450 回答