简体   繁体   中英

PayPal Subscriptions - IPN Handling and Site Flow?

For my membership site, I've got the IPN handler done. My question is one of site "flow".

Here's how it goes: User -> Landing -> SignUp -> Verify -> PayPal -> ThankYou

So here's the problem (which could just all be in my head). Let's say you've signed up and verified your account. Then you click the "Subscribe!" link and are sent to paypal - where you complete payment and get sent to the "Thank You" page.

What if the IPN doesn't arrive back to my site quickly? The subscribe link will still be there, and users may click it again thinking they've not subscribed (even though they have, it's just taking time).

If I combat this by updating their profile to say... "Activating..." when they click the "Subscribe" link, and they don't complete the PayPal process... it could be forever saying "Activating...".

Just curious, as this is my first time integrating PayPal:

  • How do you handle the state between the time the user clicks the subscribe link and it takes for the IPN process to complete?

  • Have you ever had any issues with IPN's not arriving quickly?

I've never had any issue with IPN not arriving quickly, but then again I have never really had a huge website with a lot of users. I also didn't make any significant changes to a user account until I received the IPN.

I made a paid registration for one of my websites using the paypal API. A user would fill out their username, password, etc. and I would pass the variables to the paypal API. The data wouldn't be acted on until I did receive the IPN.

You could always associate a timestamp with a pending payment if you feel the status "Activating..." is important within a user profile. A pending payment could timeout after 10 minutes.

Your question suggests that the connection to the remote server is asynchronous (ajax)?

It's probably easier to write it in a synchronous manner, so the IPN is guaranteed to return. If it doesn't, it means that:

a) The user closed the browser after being redirected to the remote server;
b) The remote server did not respond.

Good payment gateways will redirect the user back to your site if they click maybe the "Cancel" button, but a return is never guaranteed, so you need to handle it correctly.

I would have a separate table to log the transactions for a given user; that is:

one user, many transactions

Some payment gateways allow you to define as callback to your server when a transaction is completed. That is, the connection is initiated by the gateway -- it does not run the browser, as the user can close the tab/window -- where it does a post to your callback URL, and then you update the status of the transaction.

I'm not sure if PayPal does allow for such things, but so far, I've never had issues with PayPal because I've always written it in a synchronous manner.

Of course, if asynchronous is required, then your ajax function has to have a timeout/error handler -- I recommend jQuery, of course.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM