【问题标题】:customize paypal button using css or html?使用 css 或 html 自定义 paypal 按钮?
【发布时间】:2017-04-23 20:40:26
【问题描述】:

为什么我不能像这样包裹我的按钮?当我用它做额外的事情时,该按钮没有出现。

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

如何定位? This doc 的信息非常有限。

【问题讨论】:

  • 这个问题太笼统了。放松并告诉我们您在哪里以及您的问题到底是什么,需要更多代码。
  • 你有添加这个脚本吗? &lt;script src="https://www.paypalobjects.com/api/checkout.js" data-version-4&gt;&lt;/script&gt;
  • 在我将它添加到&lt;head&gt; 之后,它就起作用了>

标签: javascript html css paypal


【解决方案1】:

您可能无法加载按钮,因为:或者您没有放置脚本,或者您在编写脚本时出现了错误。

为了工作 &lt;div&gt; &lt;div id="paypal-button"&gt;&lt;/div&gt; &lt;/div&gt; 需要两个脚本。

要包含 checkout.js 脚本,请将此行添加到要呈现 PayPal 按钮的页面或标题中:

<script src="https://www.paypalobjects.com/api/checkout.js" data-version-4></script>

使用 &lt;div id="paypal-button"&gt;&lt;/div&gt; 为 PayPal 按钮创建容器元素之后。

您还需要渲染按钮,请尝试在页眉中按钮所在的页面中添加此代码。

<script>
    paypal.Button.render({

        env: 'production', // Specify 'sandbox' for the test environment

        payment: function() {
            // Set up the payment here, when the buyer clicks on the button
        },

        onAuthorize: function(data, actions) {
            // Execute the payment here, when the buyer approves the transaction
       }

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

这样你就可以看到按钮了。

【讨论】:

    猜你喜欢
    • 2020-08-06
    • 2017-11-14
    • 2016-02-28
    • 2014-11-28
    • 2021-12-17
    • 2018-06-18
    • 2021-04-29
    • 2014-02-15
    • 2013-05-30
    相关资源
    最近更新 更多