我正在按照以下示例将Paypal与我的Java Webapp集成: https://developer.paypal.com/docs/checkout/reference/server-integration/set-up-transaction/ 有点不同,我想向服务器发送几个值
在javascript函数中,我想发送多个值,并使用body属性将其发送到服务器: 我在服务器端尝试了所有操作: request.getParameter(“ action”)
request.getattribute(“ action”)
request.getReader()
但是一切正常。
<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>
我需要恢复在body属性中定义的值,以便使用此信息生成新订单。