为什么我不能改变PayPal演示脚本中的“价格”变量

时间:2018-01-04 20:33:19

标签: javascript paypal paypal-sandbox

我试图用一个来自servlet的双变量替换静态变量'4'。我的PayPal javascript代码如下所示:

<form name="frm" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">

    <div id="content">
        <h2>Thank you for choosing us!  </h2>

        <div class="article">
            Your ticket price is: <%=fareResult%> USD
        </div>
        <div>                        

            <tr>
                <td>
                    <script src="https://www.paypalobjects.com/api/checkout.js"></script>

                    <div id="paypal-button-container"></div>

                    <script>
                        paypal.Button.render({

                            env: 'sandbox', // sandbox | production

                            // PayPal Client IDs - replace with your own
                            // Create a PayPal app: https://developer.paypal.com/developer/applications/create
                            client: {
                                sandbox: 'mysandboxID',
                                production: 'myID'
                            },

                            // Show the buyer a 'Pay Now' button in the checkout flow
                            commit: true,
                            // payment() is called when the button is clicked
                            payment: function (data, actions) {

                                // Make a call to the REST api to create the payment


                                return actions.payment.create({
                                    payment: {
                                        transactions: [
                                            {
                                                amount: {total: '4', currency: 'USD'}
                                            }
                                        ]
                                    }
                                });
                            },
                            // onAuthorize() is called when the buyer approves the payment
                            onAuthorize: function (data, actions) {

                                // Make a call to the REST api to execute the payment
                                return actions.payment.execute().then(function () {
                                    window.alert('Payment Complete!');
                                });
                            }

                        }, '#paypal-button-container');
                    </script>

在付款时,我写了'4'而不是<%double price = Double.parseDouble(variablefromservlet);%>。它不再起作用了。有人可以帮忙吗?

0 个答案:

没有答案