0

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.

Preston PHX
  • 27,642
  • 4
  • 24
  • 44
Jj Jj
  • 11
  • 3

1 Answers1

0

You might find this skeleton demo a more useful base: https://developer.paypal.com/demo/checkout/#/pattern/server

But your question seems to be about how to access POST variables in... java, according to your tag?

Perhaps something like this would help, for actual java: Get the POST request body from HttpServletRequest

Or for node.js , if by chance you're using that server side: How to process POST data in Node.js?

Preston PHX
  • 27,642
  • 4
  • 24
  • 44