Php PayPal智能支付按钮错误PayPal。按钮不是功能
在我的网站正常运行之前,我正在整合智能支付按钮,但今天早些时候,我发现了这些错误 我在加载Php PayPal智能支付按钮错误PayPal。按钮不是功能,php,paypal,Php,Paypal,在我的网站正常运行之前,我正在整合智能支付按钮,但今天早些时候,我发现了这些错误 我在加载paypal.Buttons().render()函数之前加载了paypal SDK,该函数位于我的paypal.js文件中 <script src="https://www.paypal.com/sdk/js?client-id=<MY_CLIENT_ID_HERE>¤cy=PHP"></script> <script type="text
paypal.Buttons().render()
函数之前加载了paypal SDK,该函数位于我的paypal.js
文件中
<script src="https://www.paypal.com/sdk/js?client-id=<MY_CLIENT_ID_HERE>¤cy=PHP"></script>
<script type="text/javascript" src="paypal.js"></script>
paypal.Buttons({
createOrder : function(data, actions){
return actions.order.create({
purchase_units : [{
amount : {
value : amount_to_pay
}
}],
application_context: {
shipping_preference: "NO_SHIPPING",
},
country_code : "PH"
})
},
style: {
color: 'gold',
shape: 'rect',
label: 'buynow',
size: 'responsive',
branding: true
},
onApprove: function(data, actions) {
// Capture the funds from the transaction
return actions.order.capture().then(function(details) {
return fetch('/pay-with-pp', {
method: 'post',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify({
orderID: data.orderID,
product_id : product_id,
_token : token
})
}).then(function(res){
alert('Payment has been made! Please see the delivery status on orders page!');
window.location.href = redirect_url
});
});
},
}).render('#paypal-button-container');
我仔细分析了错误,找到了解决办法 我在加载SDK的脚本标记中添加了一个
数据名称空间
属性
<script src="https://www.paypal.com/sdk/js?client-id=AaJMejIDjhumOr48XsycjfvQegxAku1dHdrA0DNfkqFSg7bFFkpJTnnwyaLIGUFsPijWx1g51gxp9F-5¤cy=USD" data-namespace="paypal_sdk"></script>
我曾经
paypal_sdk.Buttons().render()
而且它有效 太好了,它对我也有效,非常感谢!
paypal_sdk.Buttons().render()