0

I tried to call the Express Checkout Paypal API by $http.get(AngularJS) and I get error 81002(Method Specified is not Supported). After I tried to call the Express Checkout Paypal API by using the search bar of Google Chrome and I get the token so the call is successful. I also tried to call the Express Checkout Paypal API by form, and the call is successful. I do not understand why.

I tried to call Paypal API in this way:

$http.jsonp("https://api-3t.sandbox.paypal.com/nvp?USER=[user]&PWD=[PWD]&SIGNATURE=[SIGNATURE]&VERSION=109.0&PAYMENTREQUEST_0_PAYMENTACTION=Sale&PAYMENTREQUEST_0_AMT=19.95&RETURNURL=http%3A%2F%2Flocalhost%3A3000%2FexpressCheckout.html&CANCELURL=http%3A%2F%2Flocalhost%3A3000%2FpagamentoAnnullato.html&METHOD=SetExpressCheckout")
    .success(function(data){
      console.log(data);
    }).error(function(error){
        console.log(error);
    });

And if I see the response, I get the token, but in the console I get this error: Uncaught SyntaxError: Unexpected identifier and I'm not able to get the return data.

Lorenzo
  • 215
  • 4
  • 10

1 Answers1

1

An ajax call accross domains will require the use of JSONP to parse the response. Here's an AngularJS JSONP example: http://jsfiddle.net/saarmstrong/hYACX/8/light/

$http.jsonp("/echo/jsonp/?callback=JSON_CALLBACK&data=" + params)
.then(function(json) {
    $scope.response = json.data.data;
});
circusdei
  • 1,967
  • 12
  • 28
  • Needs a "?callback=JSON_CALLBACK" for Angular to fire the correct function on the return. – circusdei Apr 25 '16 at 20:40
  • Credentials issue? Doublecheck Sandbox-vs-live API (credentials are specific to each). https://support.bigcommerce.com/articles/Public/What-does-Security-Header-is-Not-Valid-10002-for-PayPal-mean – circusdei Apr 25 '16 at 20:50
  • I just updated in `https://api-3t.sandbox.paypal.com/nvp?callback=JSON_CALLBACK&data={"USER":[USER],"PWD":[PWD],"SIGNATURE":[SIGNATURE],"VERSION":"109.0","RETURNURL":"http://localhost:3000/expressCheckout.html","CANCELURL":"http://localhost:3000/pagamentoAnnullato.html","METHOD":"SetExpressCheckout","PAYMENTREQUEST_0_PAYMENTACTION":"Sale","L_PAYMENTREQUEST_0_AMT":"20.00"}` but in the console I get this error `Invalid left-hand side in assignment`. Moreover if I see the response, I get this error `Method Specified is not Supported` @circusdei – Lorenzo Apr 25 '16 at 20:56
  • I'll have to double check how the data should be encoded, but with the right encoding that should work. – circusdei Apr 25 '16 at 21:01
  • please check [here](http://stackoverflow.com/questions/36887028/create-paypal-sandbox-merchant-seller-account) – fresher Apr 27 '16 at 10:45