Alan Smith
Posts: 0
Joined: Tue Jun 10, 2014 4:59 pm

Paypal API return URL

I have created an app that uses the paypal API to take payment via the app. I used the tutorial on your youtube page https://www.youtube.com/watch?v=1w-_z...

Everything works great, i am redirected to paypal sandbox, the payment is taken and then redirected back to a specified page on my app (specified in the return URL as stated in the tutorial).

I exported the app as an .apk file and published in to the play store. BUT when i downloaded it to the my Samsung device, the return URL doesn't work, it just redirects to the appery login screen.

There also seems to be an issue with local storage, or variables being sent via post to an external script on a seperate server.

Do i need to alter the return URL once the app is packaged?

Thanks
Alan

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Paypal API return URL

Alan Smith
Posts: 0
Joined: Tue Jun 10, 2014 4:59 pm

Paypal API return URL

Hi Katya

Thanks for the reference to the previous post. You seem to offer the OP some custom code which seems to be specific to his application, so I dont see how that would help me.

Do i need to use the plugin, or can I do it the way that is suggested on the above youtube tutorial?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Paypal API return URL

Hi Alan,

The main idea is to replace codewindow.location.href/code (the example in video works only in browser) with opening in InAppBrowser codewindow.open/code and add listeners as follows: https://getsatisfaction.com/apperyio/...

Alan Smith
Posts: 0
Joined: Tue Jun 10, 2014 4:59 pm

Paypal API return URL

Hi

Im afraid I cant really make any sense of that post. The code that you gave as I stated above is custom to their application, so it doesnt work on my application and makes no sense on how i need to use it.

I understand that I need to use window.open instead of window.location.href but I dont get the listeners part.

If I am sending to paypal the page it needs to redirect to, how does this differ, could you please offer a more thorough explanation instead of pointing me to a post that has no relevance to my application.

Is there a tutorial that deals with the specific issue of the return URL from paypal?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Paypal API return URL

Hi Alan,

Unfortunately we do not have another tutorial. Please find more about listeners here:
http://cordova.apache.org/docs/en/3.3...

Alan Smith
Posts: 0
Joined: Tue Jun 10, 2014 4:59 pm

Paypal API return URL

I have tried using the code you mentioned in the post. But it is still just redirecting to the appery login page. Here is the code I am using (Breakdown.html is the page that sends data and redirects to paypal). Can you see anything wring with it?

if (typeof(cordova) !== "undefined") {
var ref = window.open(localStorage.getItem('approval_url'), '_blank', 'location=yes');
ref.addEventListener('loadstart', function(event) {
if (event.url.indexOf("Breakdown.html") = 0) {
ref.close();
var vars = [];
var params = event.url.slice(event.url.indexOf('?'));
params = params.slice(1).split('&');
for (var i in params) {
var item = params.split('=');
vars.push(item[0]);
vars[item[0]] = item[1];
}
Appery.navigateTo('Breakdown', {
reverse: false
}); /* Navigate to page 'result' */
}
});
} else {
window.location.href=localStorage.getItem('approval_url');
}

Alan Smith
Posts: 0
Joined: Tue Jun 10, 2014 4:59 pm

Paypal API return URL

Can someone please help me solve this issue?

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Paypal API return URL

Hello Alan,

Sorry for delay. As soon as we have updates, we'll let you know.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Paypal API return URL

Hi Alan,

There is an error in code. A value of 'vars' will be lost (please save needed data in localStorage variable) but this doesn't affect redirect.

Could you please clarify on what device you test it?

If we understand you correctly, InAppBrowser opens, and closes after payment, then you navigate to Login page. Or does something else happen? We'd appreciate if you could tell in detail.

Return to “Issues”