贝宝按钮集成

时间:2018-09-16 10:30:38

标签: button paypal

我尝试搜索类似的主题,但找不到一个主题,或者我不太清楚。我是编码的初学者,目前正面临一个问题,我已经尝试解决了数周。问题的简要概述,下面您可以找到我的代码:

我想将PayPal按钮集成到我的网站(下面的查看代码),但是问题是我无法使其自动更改金额值。关键是我的付款页面上有几个选项,我想根据客户的选择更改按钮的值。在下面,我要发布一个包含PayPal按钮的测试代码。官方页面将不同,但功能相似。

我希望您能帮助我。请初学者说明。

> Transform room-runtime.aar (androidx.room:room-runtime:2.0.0-rc01) with AarTransform
> Transform lifecycle-extensions.aar (androidx.lifecycle:lifecycle-extensions:2.0.0-rc01) with AarTransform
> Transform work-runtime.aar (android.arch.work:work-runtime:1.0.0-alpha08) with AarTransform

此金额应通过以下不同按钮自动更改:<div class="buttons" align="center"> <button onclick="showTableOne()" id="monthly"> Monthly Subscription </button> <button onclick="showTableTwo()" id="sixmonths"> 6-Months Subscription </button> <button onclick="showTableThree()" id="yearly"> Yearly Subscription </button> </div> <div id="livesignals"> <div id="checker"> <span> <input type="checkbox" onclick="displayValue()" id="livesignalsadded"> <span>Would you like to add Live Signals to your Newsletter subscription <strong> for just 9,99 per month </strong></span> </input> </span> </div> </div> <div id="tableone"> <table id="monthlyoption" style="width:100%;" align="center"> <tbody> <tr class="subtotal"> <td id="subtotaltext" style="width: 50%"> Subscription Cost </td> <td id="subtotalprice">31.99</td> </tr> <tr class="taxes"> <td id="vat" style="width:50%">VAT (20%)</td> <td id="vatsum"> 7.99 </td> </tr> <tr class="final"> <td id="totaltext" style="width: 50%"> TOTAL </td> <td id="totalprice">39.99</td> </tr> </tbody> </table> </div> <style> #monthlyoption { text-align: center; margin-top: 50px; display: block; } .buttons { margin-top: 50px; } #tabletwo { display: none; } #tablethree { display: none; } #livesignals { margin-top: 50px; text-align: center; } </style> <script type="text/javascript"> var value1 = 31.99; var value2 = 7.99; var value3= 39.99; function showTableTwo() { document.getElementById('subtotalprice').innerHTML= value1 + 100; document.getElementById('vatsum').innerHTML= value2 + 10.01; /* makes it in period have to fix that */ document.getElementById('totalprice').innerHTML= value3 + 110; document.getElementById('livesignalsadded').checked = false; } function showTableThree() { document.getElementById('subtotalprice').innerHTML = value1 + 300; document.getElementById('vatsum').innerHTML = value2 + 30.01; /* makes it in period have to fix that */ document.getElementById('totalprice').innerHTML = value3 + 330; document.getElementById('livesignalsadded').checked = false; } function showTableOne() { document.getElementById('subtotalprice').innerHTML = value1; document.getElementById('vatsum').innerHTML = value2; document.getElementById('totalprice').innerHTML = value3; document.getElementById('livesignalsadded').checked = false; } </script> <div id="paypaloptions"> <div id="monthlynewsletter" style="display:none;"> <script src="https://www.paypalobjects.com/api/checkout.js"></script> <div id="paypal-button-container"></div> <script> // Render the PayPal button paypal.Button.render({ // Set your environment env: 'sandbox', // sandbox | production // Specify the style of the button style: { label: 'paypal', size: 'medium', // small | medium | large | responsive shape: 'rect', // pill | rect color: 'blue', // gold | blue | silver | black tagline: false }, // PayPal Client IDs - replace with your own // Create a PayPal app: https://developer.paypal.com/developer/applications/create client: { sandbox: 'AZDxjDScFpQtjWTOUtWKbyN_bDt4OgqaF4eYXlewfBP4-8aqX3PiV8e1GWU6liB2CUXlkA59kJXE7M6R', production: '<insert production client id>' }, payment: function(data, actions) { return actions.payment.create({ payment: { transactions: [ { amount: { total: '0.01', currency: 'USD' } } ] } }); }, onAuthorize: function(data, actions) { return actions.payment.execute().then(function() { window.alert('Payment Complete!'); }); } }, '#paypal-button-container'); </script> </div> </div>

0 个答案:

没有答案