Paypal with angularjs $ http.post request

This is the standard PayPal purchase form.

<form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value=" you@youremail.com "> <input type="hidden" name="item_name" value="Item Name"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="amount" value="0.00"> <input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it fast, free and secure!"> </form> 

I do not want this form, I want to do this using angularJS:

 <button ng-click="checkOut()" class="btn btn-default">Buy</button> this.checkOut = function () { var data = { ... // handle all data }; $http.post('https://www.paypal.com/cgi-bin/webscr', data).success(function (data) { console.log("success " + data); }).error(function (data) { console.log("error " + data); }); } 

This gives me an error:

XMLHttpRequest cannot load https://www.paypal.com/cgi-bin/webscr . the request was redirected to ' https://www.paypal.com/home ', which is forbidden for cross-origin requests requiring preflight protection.

Any suggestions on how to do this angularJS, without form?

+6
source share
1 answer

PayPal does not support CORS right now, so POST cannot be used in PayPal using $http .

+3
source

All Articles