PayPal button callback fails to get controllers return value |
I am trying to integrate a simple PayPal button for express checkout into my website. We are using Ubuntu 14.02 lamp with v2 cofeigniter. The PayPal button uses a .then function to asynchronously wait for a return value from a posted method call. I am certain that call works and returns a Json structure similar to {"payToken":"some value"} but the .then promised function never sees any data and the button dialog fails to open. Tracing complains about the first character being '<' suggestion either some html or perhaps a Php header. Is there something I have missed here within CI?
Sadly I can make no sense of what's wrong here in what at first sight seems quite simple. Any help much appreciated, Paul
Is the callback a POST call back to your site from PayPal and are you using CSRF protection?
csrf_protection is set to false in config.php
the code I am trying to debug is in one of our webpages as follows: // Wait for the PayPal button to be clicked payment: function() { // Make a call to the merchant server to set up the payment return paypal.request.post('/payment/create/').then(function(res) { return res.payToken; }); },
the create is routed to the real function which returns the json as I described earlier
Are you sure the create method is being called? Do you log any message or can you view the request via your console?
As I said I trace the function progress and log values to a file so yes I am
What is being printed to screen by the called method? A response of 200 does not mean an error did not occur
If the response starts with this '<' then it is probably an error that is being returned and not the expected JSON
Understood Martin thx for your patience. However when I look at the browser tools the create network/response tab says no data so I cannot see how to trap this potential error. I have suffered similar in the past so now run the script from the command line as a simple parse check. Should that be sufficient?
|
Welcome Guest, Not a member yet? Register Sign In |