javascript - cannot return promised value to paypal button


I am trying to implement paypal express checkout on my website (Ubuntu 14.02 LAMP) with Codeigniter v2 and bespoke php. I have chosen the server implementation model where I am responsible for returning the payment id to paypal (to create the payment). However, even though I am happy that I can return a json structure of the form {"payToken":"token_value"} from my php functions, the paypal checkout.js keeps on saying my first character is a '<', and the window just dies. I can only assume somehow I am returning HTML but simply cannot find the problem. Am I missing some important detail about how I code the return value to the function when the button js script code in my html is as follows:

 return'/payment/create/').then(function(res) {
                            return res.payToken;

This is copied from paypals guides and my create function returns the json as above.

Any help would be really apperciated as I have spent weeks going nowhere.

Thanks, Paul

People are also looking for solutions to the problem: php - Symfony, how to use form event to validate dynamic client-side form


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.