使用CSS或HTML自定义PayPal按钮



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

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

我该如何定位?该文档的信息非常有限。

可能您无法加载按钮,因为:或者您没有写脚本,或者在编写脚本时错了一些东西。

工作 <div> <div id="paypal-button"></div> </div>需要两个脚本。

要包含Checkout.js脚本,请在要渲染PayPal按钮或标题中的页面上添加此行,这还可以:

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

使用<div id="paypal-button"></div>后为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>

通过这种方式,您将看到按钮。

最新更新