PayPal JavaScript SDK:如何将“立即购买”按钮更改为“立即付款”?

时间:2021-05-18 10:06:42

标签: javascript paypal

我的付款页面使用的是最新版本的 PayPal JavaScript SDK(而不是已弃用的 checkout.js)和智能按钮。当 PayPal 在底部显示信用卡/借记卡数据输入表单时,我希望它显示 'Pay Now' 而不是 'Buy Now',我该怎么做那个?

followed this example,但它只更改了带有'Pay with PayPal' 和'Credit/Debit Card' 按钮的主按钮,但蓝色的'Buy Now' 仍然显示在表格下方:

paypal.Buttons({
  style: {
    layout: 'vertical',
    color:  'gold',
    shape:  'rect',
    label:  'pay' // I changed to 'pay' instead
  }
}).render('#paypal-button-container');

我什至 follow this guidecommit=true 参数添加到 SDK 但没有运气:

<script src="https://www.paypal.com/sdk/js?client-id=YOUR_CLIENT_ID&commit=true"></script>

以下是我的完整代码,以备不时之需:

            paypal.Buttons({
                style: {
                    layout: 'vertical',
                    color: 'gold',
                    shape: 'rect',
                    label: "pay"
                },
                createOrder: function (data, actions) {
                    // This function sets up the details of the transaction, including the amount and line item details.
                    return actions.order.create({
                        purchase_units: [{
                            amount: {
                                currency_code: "MYR",
                                value: "1.00"
                            }
                        }],
                        application_context: {
                            shipping_preference: "NO_SHIPPING"
                        }
                    });
                },
                onApprove: function (data, actions) {
                    // This function captures the funds from the transaction.
                    return actions.order.capture()
                        .then(function (details) {
                            // This function shows a transaction success message to your buyer.
                            alert('Transaction completed by ' + details.payer.name.given_name);
                        });
                }
            }).render('#gPayContainer');
            //This function displays Smart Payment Buttons on your web page.

如有任何建议,将不胜感激,谢谢!

1 个答案:

答案 0 :(得分:0)

正如@Preston PHX 评论的那样,无论是立即付款还是立即购买,都是由 PayPal 翻译的 locale。看看下面的截图,如果选择英格兰(默认),按钮文字是立即购买

enter image description here

However, when Malaysia is selected (and only AFTER the country selection dropdown list is losing the focus), the button text changes to Pay Now:

enter image description here

我们不知道为什么 PayPal 会以这种方式进行转换以及其背后的必要性,因为:

  1. 从被英国殖民之日起,甚至在独立日之后,马来西亚英语实际上就遵循英国英语标准。
  2. Pay NowBuy Now 都是英文,但意义不同。
  3. Buy Now 翻译成马来语应该是 Beli Sekarang,而不是 Pay Now
  4. 当您将 label 对象的 style 更改为 pay 时,PayPal 会将主金色按钮标签更改为 Pay with PayPal 而不是 Buy with PayPal。< /li>

所以现在的解决方案是让马来西亚付款人选择马来西亚,以免在支付非商品商品时被按钮标签混淆。