django - Django Paypal 集成 - 更改语言时渲染按钮不起作用
问题描述
我已将 Paypal 集成到我的网站,一切都按预期工作。但是,当我添加一种新语言(希腊语)时,我在使用 paypal 按钮按下付款时遇到了问题。当改回英文时,一切正常,按钮渲染没有问题。
我从贝宝得到的错误是:
我正在使用的代码:
<div id="paypal-button-container">
<!--Paypal button will load-->
</div>
// Render the PayPal button into #paypal-button-container
paypal.Buttons({
style: {
color: 'blue',
shape: 'rect',
label: 'pay',
height: 40
},
// Set up the transaction
createOrder: function(data, actions) {
console.log('kostas');
console.log(actions);
return actions.order.create({
purchase_units: [{
amount: {
value: amount,
}
}]
});
},
// Finalize the transaction
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
// Show a success message to the buyer
console.log(details);
sendData();
function sendData() {
fetch(url, {
method: "POST",
headers: {
"Content-type": "application/json",
"X-CSRFToken": csrftoken,
},
body: JSON.stringify ({
orderID: orderID,
transID: details.id,
payment_method: payment_method,
status: details.status,
}),
})
.then((response) => response.json())
}).render('#paypal-button-container');
由于是第一次尝试使用贝宝,如果您能给我关于以下错误的任何提示或有关如何排除故障的任何想法,我将不胜感激。
非常感谢
解决方案
当我添加一种新语言(希腊语)时,我在使用 paypal 按钮按下付款时遇到了问题。
您没有显示要添加的代码,因此无法说出具体是什么触发了错误,但似乎它可能是订单创建调用中的某些内容,这不是更改按钮文本的正确位置。
要将按钮的语言更改为默认语言以外的语言(根据浏览器的语言自动检测),请使用locale
SDKsrc
行上的查询字符串参数。
这是文档:https ://developer.paypal.com/docs/checkout/reference/customize-sdk/#locale
推荐阅读
- python - 基于组中包含的字符串的条件
- android - WorkerManager 是在应用程序中实现警报/提醒功能的可行方式吗?
- python - 如何为某些列添加没有值的行
- java - 解析时无法检索 JSON 整数/双值
- regex - 正则表达式来区分单个数字和多个数字
- java - 有时当我单击应该打开新框架的图标时,由于无法解释的原因而出现 NullPointer 异常
- xamarin - Xamarin 无法在 Razor cshtml 中加载脚本
- javascript - While循环JS中的多个条件
- python - 识别 ssl/tls python 套接字服务器的数据包交换类型
- algorithm - Dijkstra 将图形存储在文本文件中