I'm following this example to integrate paypal with my java webapp: https://developer.paypal.com/docs/checkout/reference/server-integration/set-up-transaction/ with a little difference that I want to send several values to server
In Javascript function I want to send several values and I use the body attribute to send it to server: I tried everything in server side: request.getParameter("action")
request.getAttribute("action")
request.getReader()
But nothing worked.
<script>
paypal.Buttons({
createOrder: function() {
return fetch('${pageContext.request.contextPath}/createOrder', {
method: 'post',
headers: {'content-type': 'application/json'},
body: JSON.stringify({
action: 'paypal',
page: 'paypal'
})
}).then(function(res) {
return res.json();
}).then(function (data) {
return data.id;
});
},
style: {
color: 'blue',
shape: 'rect',
label: 'paypal',
height: 40
}
}).render('#ppBtn');
</script>
What I need is to recover the values defined in the body attribute in order to generate the new order with this information.