Following the code from https://www.paypal.com/buttons, I follow the "Smart Buttons" link, generate and copy the code, so I add the following to our payments page (with our actual clientID instead of the XXXXXX....):
<div id="smart-button-container">
<div style="text-align: center;">
<div id="paypal-button-container"></div>
</div>
</div>
<script src="https://www.paypal.com/sdk/js?client-id=XXXXXXXXXXXXXXXXX¤cy=USD" data-sdk-integration-source="button-factory"></script>
<script>
function initPayPalButton() {
paypal.Buttons({
style: {
shape: 'rect',
color: 'gold',
layout: 'vertical',
label: 'paypal',
},
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{"description":"Subscription to our service","amount":{"currency_code":"USD","value":10}}]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert('Transaction completed by ' + details.payer.name.given_name + '!');
});
},
onError: function(err) {
console.log(err);
}
}).render('#paypal-button-container');
}
initPayPalButton();
</script>
The button seems to work, in that it opens the Paypal payment window; but the payment does not seem to take effect.
I then notice what I believe would be the reason: the URL of the Paypal payment window reads https://www.sandbox.paypal.com/checkoutnow .....
Question: how do I set up the code to enable the "live" functionality?
question from:
https://stackoverflow.com/questions/65660644/how-to-make-paypal-button-invoke-live-functionality 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…