Issue
I'm testing a sandbox PayPal for a learning project in the JSP servlet. I'm using NetBeans IDE with the glassfish server and XAMPP for the database. The following code runs the Paypal payment buttons, but when I click the payment button Paypal window pops up and crashes suddenly.
<html>
<head>
<title>Purchase</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://www.paypal.com/sdk/js?client-id=AbdB49QXlBjEzeWDSu1ws2QrNR3FpcpcGPOif2a7XvK6sDKMkD8ijA2q0c5CdI-w2cUHlKTj_LLyn5cu&locale=en_US" data-csp-nonce="xxx"></script>
</head>
<body>
<div id="paypal-button-container"></div>
<script>
paypal.Buttons({
createOrder: function(data, actions){
return actions.order.create({
purcchase_units: [{
amount:{
value: '295'
}
}]
});
}
}).render('#paypal-button-container')
</script>
</body>
The above code is in the index.jsp file and the auto close issue persists. According to what I found online it could be due to my localhost is HTTP and Paypal blocking non-https Requests. If so, please help me to set up HTTPS on my server. Or if the issue is something else hope to know about it.
Solution
The error in the browser console explains the problem
Uncaught Error: a.purchase_units is undefined
Answered By - Preston PHX
Answer Checked By - Gilberto Lyons (JavaFixing Admin)