我的PayPal按鈕(實際上是快速結帳)在https上不起作用,當我通過https訪問我的應用時,我意識到了這一點。PayPal按鈕無法在https上工作
不確定這是我的https阻止此腳本。
<script src="https://www.paypalobjects.com/api/checkout.js" data-version-4></script>
我沒有問題看到該按鈕被加載到本地主機(開發環境)。但在生產中以https,我得到這個錯誤
ppxo_xc_ppbutton_error Object
Error: Document is ready and element #paypal-button does not exist
我使用的角度,這個代碼塊是我的控制器內
paypal.Button.render({
env: 'production', // Optional: specify 'sandbox' environment
payment: function() {
var env = this.props.env;
var client = this.props.client;
return paypal.rest.payment.create(env, client, {
transactions: [{
amount: { total: 5 , currency: 'USD' },
item_list: {
items: [{
"name": "profile",
"price": "5",
"currency": "USD"
}]
}
}],
redirect_urls: {
"return_url": $location.absUrl(),
"cancel_url": $location.absUrl()
}
});
},
commit: true, // Optional: show a 'Pay Now' button in the checkout flow
onAuthorize: function(data, actions) {
return actions.payment.execute().then(function() {
actions.payment.get().then(function(data){
if(data.state === 'approved'){
$http.post('/paid',{qty:$scope.number_of_uses,user_email:user_email})
.then(function(response){
$scope.done = true;
});
}
});
});
}
}, '#paypal-button');
我再說一遍,它的工作在本地主機罰款,但不是在HTTPS (生產)。
請提供[mcve]。 –
元素'#paypal-button'不存在 – MackieeE
@MackieeE不,它的確如此。它只是不工作在https中,它運行良好,當我在發展URL是http:// localhost:3000 –