paypal.Button.render({
payment: function() {
var booksPurchaseRequest = {};
booksPurchaseRequest.amount = 20;
return paypal.request
.post(CREATE_PAYMENT_URL, JSON.stringify(booksPurchaseRequest))
.then(function(data) {
return data.paymentId;
});
}
}, '#paypal-button');
In such approach on back-end server I'm receiving data in application/x-www-form-urlencoded format, but I need application/json. How can I achieve that? Can paypal.request.post() be replaced with simple $.ajax()?
return paypal.request({
method: 'post',
url: '/foo/bar',
json: {
foo: 'bar'
}
}).then(function(response) {
})
Or you can just use jQuery, you just need to return a promise
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With