[Resolved] MODx: subscription integration

bkavanaghbkavanagh Member
in Help edited April 2008
Hi Guys

First off I just want to say I'm mightily impressed with the work you're doing here. Very slick cart and MODx integration and I love the flexibility you've built in.

I'm trying to integrate the webuser subscriptions snippet into my MODx site but have run into problem that's foxing me. I'm using the PayPal UK test account and when I go through the checkout process the foxycart_subscriptions table isn't being updated and the user isn't being added to the specified web group.

The transactions and subscriptions are showing up in the foxycart admin but I notice that the subscriptions are marked as inactive. I read in another post that this is the default behaviour but is this stopping the snippet from processing the response and updating the user permissions and table?

Or have I just messed up the install?

Any help appreciated, I can provide more details if needed.

Brian
Comments
  • brettbrett FoxyCart Team
    Ah, yes, subscriptions sent under a test gateway are automatically marked as inactive. I'm not sure how that would affect the datafeed, but can you check if you're getting datafeed errors in your error log?

    Also, if you could confirm that your webuser snippet is actually working using the test script, that'd be a good start. I'd recommend downloading the latest version of the test script here:
    http://wiki.foxycart.com/integration?datasrt=&dataflt=system:FoxyCart

    Use the one that writes the XML to a file on your server to see what's actually being sent. Then you could copy that out and use it in the test script to see if there's an issue.

    (If you're not getting any XML sent at all it's probably because subscriptions are immediately set to inactive if you're using a test gateway. I'm not 100% and don't have the time to dig through the code to check right now, but I think that'd be the issue.)
  • I'm using a (live) foxy instance in test mode with subscriptions -- and I do get the XML datafeed updates.

    I did have the URL target for the datafeeds setup wrong once -- but this triggered errors to be logged in the error log, so that might be a helpful place to check too. (I suppose you could setup foxy in live mode, but have the 3rd party payment gateway in test mode to make sure this isn't the issue...although you would have "live test" data in the live sections of FC. Or, you could basic test with something like this http://wiki.foxycart.com/integration:mysql just to make sure the feed is coming in.)

    BTW, Brett, the error logging system is wonderful, and I'm very glad you included something like that early on!

    /me scurries away :)
  • lukeluke FoxyCart Team
    Inactive subscriptions won't be processed as transactions so you won't see them in the datafeed (hence the term "inactive" :). If you mark them as active but the date has already passed, they won't come through either... so you'll probably want to run some example subscriptions for the next day and then go into the admin and mark them as active or get them in the system and change the date to be in the future.

    Let us know if there's anything else we can do to help.

    Tookings, thanks for the feedback. As developers, we figured that would be pretty important as well.
  • Thanks for the quick feedback.
    I managed to grab a copy of the XML datafeed. It looks OK to me, it has all the right data including the correct user ID. I put that back through the test script and it returns foxy. I'm also not getting any errors in the error log. Can I assume the feed is working as it should?
    Luke, I'm trying your suggestion of a future subscription, I've sent one through for tomorrow and marked it active but of course I have to wait a day to see if it's worked! But if I'm seeing them in the datafeed and they appear in the transaction history does that not mean they are being processed as transactions even if they are marked inactive?
  • I managed to solve this. I went through the subscription manager snippet line by line to find where it was going wrong and came to this line:
    //	Get the page ID that has this product code
    $query = "SELECT contentid FROM ".$prefix."site_tmplvar_contentvalues WHERE (tmplvarid='".$codeTVId."' AND value='".$code."')";
    

    The TV id and value weren't being added to the table so the script was skipping the transaction. Because the site only has one product (a subscription to the site), I'd used default values when creating the TVs. When I removed the default values and added values on the product page, the snippet worked, updating the foxycart_subscriptions table and adding the user to the specified group.

    This is a MODx issue rather than a foxycart one but it might help anyone else with a similar problem.

    When I checked the subscriptions in the foxycart admin, the subscription that worked is still marked as inactive which suggests that doesn't affect the the outcome of the process. In which case, what does that active checkbox do? I would guess it's a way to manually toggle a subscription but doesn't seem to do that, unless it's disabled for test accounts!

    One last question, was a solution found to the problem of a user having to log out and back in for the user group permissions to take effect?
  • brettbrett FoxyCart Team
    Ah, good catch. You're right though that when a TV is empty and a default value exists, MODx will use the default value stored in a different db table... The snippet could be modified to pull that value if available, which might prevent problems in the future.

    The user login/logout is more a MODx issue, I believe.

    As far as inactive subscriptions go, I think Luke can clarify that.

    Glad you got it working. Send me an email or a whisper when it goes live so we can feature the site. (That goes for everybody, incidentally.)
  • lukeluke FoxyCart Team
    Only the active subscriptions should be processing through the system. However, if you ran a subscription transaction with a first payment date of today, then that initial transaction will come through to the datafeed. If that's not what you're experiencing, please let us know and include which store version you're on.
  • Subscriptions can start at any time so yes it uses 'today's' date. I put some more test subs through and they all work but show as inactive. If that's what it's supposed to do that's fine, as long as it works I'm happy :) So what does the active checkbox do for live accounts? Does it send through a new datafeed to update the foxycart_subscriptions table?

    I've got a few more things to do on the MODx side of things and some live account testing to do before it goes live but I'll let you know. I'd be happy to write up some documentation for the wiki too if that would help, as an example implementation.
  • brettbrett FoxyCart Team
    For live accounts, the subscriptions are "active" automatically. You can deactivate them if somebody wants to cancel or suspend their subscription. For test accounts they come in as inactive, since we figured people probably wouldn't want test subscriptions happening over and over.

    Does that make sense? It seems like it is indeed working as expected, so that's good.
  • lukeluke FoxyCart Team
    Every time you send a transaction to FoxyCart, you get a datafeed entry. So, unless you set the initial transaction to be a future subscription (which means it would charge the customer nothing at the time of the order), then you'll always get that datafeed entry for the initial transaction.

    Subsequent subscription transactions will only come through if they are active. The query specifically checks for active subscriptions to process.

    Does that make sense?
Sign In or Register to comment.