Pro-sites and stripe problem after updating to latest version $0 payment received

I just updated to the latest version of Pro-sites and when a payment came in from a customer it showed a payment of $0 and the customer's site was downgraded to "". I'm guessing that means no level. I have the pay to blog feature turned on so now they can't access their site.

I checked the logs in stripe and the payment did go through fine there. I am 100% sure my settings are correct because I did not change anything and only updated Pro-sites.

Everything has been working just great until I updated. Please help before this happens to other sites when they come up for renewal. Thanks.

  • traviscf
    • Site Builder, Child of Zeus

    Just for a little more info here's what the Pro Sites logs show:

    2014-01-23 11:09:54 am Pro Site level downgraded from "Pro" to "".

    2014-01-23 11:09:53 am Stripe webhook "invoice.payment_succeeded" received: The $0 payment was successfully received. Date: "January 23, 2014", Charge ID "ch_3MULY1qgRWycmA"

    2014-01-23 10:07:53 am Stripe webhook "customer.subscription.updated" received. The customer's subscription was successfully updated to Pro: $29 every 1 month.

  • Jack Kitterhing
    • Code Norris

    Hi there @traviscf,

    Hope you're well today and sorry to see of the problems your having here.

    Which version did you upgrade from? Are you using WordPress Multisite, 3.8 or an older version?

    As you're using the pay to blog module, do you give them a free trial at all?

    Please advise.

    Thanks!

    Kind Regards
    Jack.

  • traviscf
    • Site Builder, Child of Zeus

    I don't remember what version I upgraded from. It was quite a few versions back though. Probably about a year old.

    I'm using Wordpress Multisite 3.8.

    Yes they get a free trial. This particular user has already been a paid account for some time now. There will be other user's sites payments coming in soon so I'm a little worried that the same thing is going to happen to them as well.

    Also, how do I get that user back on the stripe gateway? Stripe is going to keep billing them but right now it shows that they are on the manual gateway because I had to manually make them a Pro level to get their site back online.

    In the Subscription Information section for this user is does show this:

    Last Payment Date: January 23, 2014
    Last Payment Amount: $29
    Last Payment Invoice ID: in_3MTLVGG5DNfnU6

    But it's on manual payment gateway right now.

  • Jack Kitterhing
    • Code Norris

    Hi there @traviscf,

    Hope you're well today, sorry about the delay, when you replied it was early morning for me :slight_smile:

    I've taken a look here and it looks like it's taking a free trial price of $0, though I can't replicate this behavior with Stripe and Pro sites.

    I've flagged the lead developer here to provide his valuable input.

    Thanks for your patience.

    Kind Regards
    Jack.

  • Aaron
    • CTO

    Hey there, in the latest pro sites we fixed a bug where the webhook would not extend and show a $0 payment. This would generally happen right after checkout.

    Perhaps you need to update to that still, can you please confirm your pro sites version?

    If it is the latest, then perhaps there is something in that fix that fixed the immediate payment webhook but left the subscription payments broken instead. We're gonna take a look at it, might not get back to you till monday though.

    Meanwhile please paste here the exact webhook bodies that were sent, you can find it in your Stripe account in the webhook log.

    Also, there should be no problem simply manually extending the blogs in question, when the next webhook comes through it will register it as back on the Stripe gateway.

  • Jonathan
    • The Bug Hunter

    Hey @traviscf,

    Could you sign into your Stripe account and upgrade your API keys to the latest version? You can do that by clicking on your name in the upper right hand corner of the Stripe dashboard. Then, click on API keys and click the "upgrade" button.

    Stripe made some API updates late last year and if you are still using an older API it may cause the webhooks to be received improperly. We've got some changes in the works for the next version of the Stripe Gateway that will prevent users from having to upgrade their API keys like this.

  • traviscf
    • Site Builder, Child of Zeus

    @Aaron I'm on 3.4.2 for Pro Sites.

    Here are the web hook bodies:

    {
      "id": "evt_3N3FYvDLdi6HwI",
      "created": 1390605254,
      "livemode": true,
      "type": "invoice.created",
      "data": {
        "object": {
          "date": 1390605254,
          "id": "in_3N3FKgOxxYSWDC",
          "period_start": 1387926671,
          "period_end": 1390605071,
          "lines": {
            "invoiceitems": [],
            "prorations": [],
            "subscriptions": [
              {
                "id": "sub_2G7eYWJ7pEegw1",
                "object": "line_item",
                "type": "subscription",
                "livemode": true,
                "amount": 2900,
                "currency": "usd",
                "proration": false,
                "period": {
                  "start": 1390605071,
                  "end": 1393283471
                },
                "quantity": 1,
                "plan": {
                  "interval": "month",
                  "name": "Pro: Monthly",
                  "amount": 2900,
                  "currency": "usd",
                  "id": "1_1",
                  "object": "plan",
                  "livemode": true,
                  "interval_count": 1,
                  "trial_period_days": null,
                  "metadata": {}
                },
                "description": null,
                "metadata": null
              }
            ]
          },
          "subtotal": 2900,
          "total": 2900,
          "customer": "cus_2G7e1h4wXu0uAc",
          "object": "invoice",
          "attempted": false,
          "closed": false,
          "paid": false,
          "livemode": true,
          "attempt_count": 0,
          "amount_due": 2900,
          "currency": "usd",
          "starting_balance": 0,
          "ending_balance": null,
          "next_payment_attempt": 1390608854,
          "charge": null,
          "discount": null,
          "application_fee": null,
          "subscription": "sub_2G7eYWJ7pEegw1"
        }
      },
      "object": "event",
      "pending_webhooks": 2,
      "request": null
    }
    {
      "id": "evt_3N3F6gAPI9QlRm",
      "created": 1390605254,
      "livemode": true,
      "type": "customer.subscription.updated",
      "data": {
        "object": {
          "id": "sub_2G7eYWJ7pEegw1",
          "plan": {
            "interval": "month",
            "name": "Pro: Monthly",
            "amount": 2900,
            "currency": "usd",
            "id": "1_1",
            "object": "plan",
            "livemode": true,
            "interval_count": 1,
            "trial_period_days": null,
            "metadata": {}
          },
          "object": "subscription",
          "start": 1374707471,
          "status": "active",
          "customer": "cus_2G7e1h4wXu0uAc",
          "cancel_at_period_end": false,
          "current_period_start": 1390605071,
          "current_period_end": 1393283471,
          "ended_at": null,
          "trial_start": null,
          "trial_end": null,
          "canceled_at": null,
          "quantity": 1,
          "application_fee_percent": null,
          "discount": null
        },
        "previous_attributes": {
          "current_period_start": 1387926671,
          "current_period_end": 1390605071
        }
      },
      "object": "event",
      "pending_webhooks": 2,
      "request": null
    }
    {
      "id": "evt_3N4IJEMTyz9ell",
      "created": 1390609141,
      "livemode": true,
      "type": "charge.succeeded",
      "data": {
        "object": {
          "id": "ch_3N4IQHWx9gcy1r",
          "object": "charge",
          "created": 1390609139,
          "livemode": true,
          "paid": true,
          "amount": 2900,
          "currency": "usd",
          "refunded": false,
          "card": {
            "id": "cc_2G7ej1gSI2Utz7",
            "object": "card",
            "last4": "5273",
            "type": "Visa",
            "exp_month": 1,
            "exp_year": 2016,
            "fingerprint": "oab84ZN2j0eDYoFV",
            "customer": "cus_2G7e1h4wXu0uAc",
            "country": "US",
            "name": "Chris Buttrum",
            "address_line1": null,
            "address_line2": null,
            "address_city": null,
            "address_state": null,
            "address_zip": null,
            "address_country": null,
            "cvc_check": null,
            "address_line1_check": null,
            "address_zip_check": null
          },
          "captured": true,
          "balance_transaction": "txn_3N4IZUZaKCnf4a",
          "failure_message": null,
          "failure_code": null,
          "amount_refunded": 0,
          "customer": "cus_2G7e1h4wXu0uAc",
          "invoice": "in_3N3FKgOxxYSWDC",
          "description": null,
          "dispute": null,
          "metadata": {},
          "fee": 114,
          "fee_details": [
            {
              "amount": 114,
              "currency": "usd",
              "type": "stripe_fee",
              "description": "Stripe processing fees",
              "application": null,
              "amount_refunded": 0
            }
          ],
          "disputed": false
        }
      },
      "object": "event",
      "pending_webhooks": 2,
      "request": null
    }
    {
      "id": "evt_3N4Iz4hYCiz14l",
      "created": 1390609141,
      "livemode": true,
      "type": "invoice.payment_succeeded",
      "data": {
        "object": {
          "date": 1390605254,
          "id": "in_3N3FKgOxxYSWDC",
          "period_start": 1387926671,
          "period_end": 1390605071,
          "lines": {
            "invoiceitems": [],
            "prorations": [],
            "subscriptions": [
              {
                "id": "sub_2G7eYWJ7pEegw1",
                "object": "line_item",
                "type": "subscription",
                "livemode": true,
                "amount": 2900,
                "currency": "usd",
                "proration": false,
                "period": {
                  "start": 1390605071,
                  "end": 1393283471
                },
                "quantity": 1,
                "plan": {
                  "interval": "month",
                  "name": "Pro: Monthly",
                  "amount": 2900,
                  "currency": "usd",
                  "id": "1_1",
                  "object": "plan",
                  "livemode": true,
                  "interval_count": 1,
                  "trial_period_days": null,
                  "metadata": {}
                },
                "description": null,
                "metadata": null
              }
            ]
          },
          "subtotal": 2900,
          "total": 2900,
          "customer": "cus_2G7e1h4wXu0uAc",
          "object": "invoice",
          "attempted": true,
          "closed": true,
          "paid": true,
          "livemode": true,
          "attempt_count": 1,
          "amount_due": 2900,
          "currency": "usd",
          "starting_balance": 0,
          "ending_balance": 0,
          "next_payment_attempt": null,
          "charge": "ch_3N4IQHWx9gcy1r",
          "discount": null,
          "application_fee": null,
          "subscription": "sub_2G7eYWJ7pEegw1"
        }
      },
      "object": "event",
      "pending_webhooks": 2,
      "request": null
    }
    {
      "id": "evt_3N4IR4Tp0IPlRq",
      "created": 1390609141,
      "livemode": true,
      "type": "invoice.updated",
      "data": {
        "object": {
          "date": 1390605254,
          "id": "in_3N3FKgOxxYSWDC",
          "period_start": 1387926671,
          "period_end": 1390605071,
          "lines": {
            "invoiceitems": [],
            "prorations": [],
            "subscriptions": [
              {
                "id": "sub_2G7eYWJ7pEegw1",
                "object": "line_item",
                "type": "subscription",
                "livemode": true,
                "amount": 2900,
                "currency": "usd",
                "proration": false,
                "period": {
                  "start": 1390605071,
                  "end": 1393283471
                },
                "quantity": 1,
                "plan": {
                  "interval": "month",
                  "name": "Pro: Monthly",
                  "amount": 2900,
                  "currency": "usd",
                  "id": "1_1",
                  "object": "plan",
                  "livemode": true,
                  "interval_count": 1,
                  "trial_period_days": null,
                  "metadata": {}
                },
                "description": null,
                "metadata": null
              }
            ]
          },
          "subtotal": 2900,
          "total": 2900,
          "customer": "cus_2G7e1h4wXu0uAc",
          "object": "invoice",
          "attempted": true,
          "closed": true,
          "paid": true,
          "livemode": true,
          "attempt_count": 1,
          "amount_due": 2900,
          "currency": "usd",
          "starting_balance": 0,
          "ending_balance": 0,
          "next_payment_attempt": null,
          "charge": "ch_3N4IQHWx9gcy1r",
          "discount": null,
          "application_fee": null,
          "subscription": "sub_2G7eYWJ7pEegw1"
        },
        "previous_attributes": {
          "attempted": false,
          "closed": false,
          "paid": false,
          "ending_balance": null,
          "next_payment_attempt": 1390608854,
          "charge": null
        }
      },
      "object": "event",
      "pending_webhooks": 2,
      "request": null
    }

    @Johnathan Okay I just upgraded the API keys.

  • webatonic1
    • Site Builder, Child of Zeus

    The thing is that this plugin is broken/incomplete at its current state due to lack of proper testing, and the WPMUdev staff dont have an answer for you nor I at the moment since the lead developers are too busy taking care of other plugins. Waiting for a fix could take months so at the moment this plugin is unusable.

    As you can see Jonathan has already offered the same solution to me in my thread here - https://premium.wpmudev.org/forums/topic/i-have-setup-prosites-with-stripe-payments-i-have-it-live#post-594434

    which I have done with no result, so Im not sure why this solution is offered to you as Jonathan knows that its not the issue here :slight_smile:

  • Jonathan
    • The Bug Hunter

    @webatonic1

    The Pro Sites plugin is not "unusable". It's the Stripe Gateway (that is currently clearly marked Beta) that is giving you issues. The webhooks that @traviscf supplied are from an API dated back in 2012 so that is why I recommended he update his webhooks. His issue may be different than yours - I'm just trying to rule everything out. :slight_smile:

    From my testing it looks like there is about an hour delay between when the old subscription ends and when Stripe processes the actual payment and sends an update Webhook. I think that's what the issue is here. Here's an example:

    Last night at 9:30PM I created a new site and while still trialing I upgraded to Level 2. Everything processed as expected.

    Tonight at 9:30PM, I expected Stripe to send new webhooks and update my account. Which didn't happen. I said to myself, "Ok, I see what these guys are seeing."

    BUT... then an hour later (on the dot) I received an email... "Your Pro Site subscription payment was successful!". Went to the database - everything had updated and now I'm back in business. I did some further digging in the Stripe forums and there's definitely an hour lag between when things expire and when things renew. I don't know if it's a bug or what, but it's definitely documented with Stripe.

    So I think what we need to do is when creating a subscription add some padding in there to allow for the hour time difference, plus a little more for good faith. I'm attaching a screenshot so you can see what I'm talking about.

  • traviscf
    • Site Builder, Child of Zeus

    @Jonathan

    I have another subscription coming due tomorrow so I'll see what happens. Is that hour lag something that just creeped up lately? I've never noticed that before. I'll have to check the logs and see if that was happening before.

  • traviscf
    • Site Builder, Child of Zeus

    Ok so it looks like my problem has been fixed. I guess it was because of the outdated API. I'm not sure if that hour lag is a problem but I can confirm that my subscriber did not receive an email saying that their site was down because of it. It seems that the hour lag doesn't make a difference. I'll wait for confirmation of that.

    @webatonic1 I haven't really been following what your problem is but I can confirm that Pro Sites works great with Stripe and I've been using it for about a year and a half and love it. Hope you get your problem worked out.

  • Jonathan
    • The Bug Hunter

    We recently made a ton of changes to the Stripe gateway to support some cool features in the upcoming 3.5 release of Pro Sites as well to fix some other bugs with the gateway.

    Up until now, we've always used to our own formula to calculate when things expired and when a payment was received how much time would be added on to the site's subscription. But there was some issues with this ,so we now use the expiration date that Stripe passes with the webhooks - so everything is literally in sync down to the second. We hadn't noticed the 1 hour lag either until we started digging into these issues for you guys.

    I'm going to get an updated gateway file for you guys to test shortly. :slight_smile:

  • Jonathan
    • The Bug Hunter

    Hey Guys,

    Please give this gateway-stripe.php file a try. I've tested in my local environment and it works nicely. Basically, I've taken the expiration date that Stripe provides and added 3 hours to it. This will ensure that there is some padding between when a site expires locally and when Stripe sends the appropriate webhooks.

    You'll want to unzip it and upload file to plugins/pro-sites/pro-sites-files/gateways. Make sure you overwrite the existing file that is already there.

    Thanks!

  • traviscf
    • Site Builder, Child of Zeus

    Ok I haven't tried your uploaded gateway-stripe.zip file yet but it looks like I've got a new problem here. Everything looks fine with current pro site members and their site recurring revenue coming in but now I have a problem with new pro site customers.

    When the client's trial expires and they upgrade to pro, their account is created in Stripe but it is showing a $0 payment. They are not downgraded in the plugin though. It seems their trial just restarts and they are still on the trial. It's showing the gateway as trial and the level as Pro and the Payment term is 1 month.

    This has happened on all new clients since updating and I really need this fixed asap. I really wish I would not have updated to the latest version as my older version was working just fine.

    Here is the log:

    2014-02-08 4:33:53 pm Stripe webhook "customer.subscription.created" received: Customer successfully subscribed to Pro: $29 every 1 month.
    2014-02-08 4:33:52 pm Payment receipt email sent to ######@gmail.com
    2014-02-08 4:33:51 pm Pro Site status expiration extended until March 10, 2014.
    2014-02-08 4:33:50 pm Stripe webhook "invoice.payment_succeeded" received: The $0 payment was successfully received. Date: "February 8, 2014", Charge ID "in_3SZBl3ttxlyAdm"
    2014-02-08 4:33:46 pm Stripe webhook "customer.card.created" received: Customer ID: cus_3SZBe7K8Va5Nvn
    2014-02-08 4:33:45 pm User creating new subscription via CC: Subscription created (Pro: $29 USD each month) - Customer ID: cus_3SZBe7K8Va5Nvn
    2014-02-08 2:13:09 am Expired email sent to ######@gmail.com
    2014-02-08 2:13:08 am Pro Site status has been withdrawn.
    2014-01-09 12:11:29 am Pro Site status expiration extended until February 8, 2014.

    Please get a developer on this asap to figure out what's going on. This is on a live site with paying customers and I would really expect a working update. Again, I really wish I wouldn't have updated because it's been a headache ever since. Thanks.

  • traviscf
    • Site Builder, Child of Zeus

    One more thing to add. It looks like it's giving them 30 days free after they sign up for a Pro level. I was looking in Stripe and it shows that their next payment is going to be for the correct amount of $29. It should be charging them that right up front though because their trial was already up. I also confirmed that the plan in stripe has No trial.

  • Jonathan
    • The Bug Hunter

    Hi @chobson,

    I just pushed a 3.4.3 update so you should be able to download that through your WP dashboard. If it doesn't show up right away you can to go WPMU DEV > Updates and then click the "check for updates" link at the bottom of that screen.

  • Gabe
    • The Bug Hunter

    @Jonathan

    Thanks for fixing this bug, I'll give the updated version a try tonight.

    We recently made a ton of changes to the Stripe gateway to support some cool features in the upcoming 3.5 release of Pro Sites as well to fix some other bugs with the gateway.

    Any ETA on the 3.5 release? Weeks? Months? Just looking for a rough idea for planning purposes. Thanks!

  • Jonathan
    • The Bug Hunter

    @Gabe,

    Unfortunately, we aren't allowed give out any sort of ETAs. We put a hold on the release of 3.5 until we can get some of these bugs ironed out with Stripe as it's one of the most popular gateways used. We've also added some other big features that are still in alpha testing.

  • traviscf
    • Site Builder, Child of Zeus

    So what can I do about the subscribers that got the $0 payment? Is there a way to manually collect that payment in stripe? For example, I have someone who signed up on Jan 8, their trial expired on Feb 7, and they then signed up for a paid account but it shows that they don't owe a payment until March when it should have taken a payment right away.

  • Jonathan
    • The Bug Hunter

    Hey @traviscf,

    Yes, there are a couple of ways to do this. Login into your Stripe account and find the customer in question then click on their email address. Once you're in the customer screen you add a new charge OR you can add an invoice item which will be tacked onto their next month's automatic payment. See screenshots.

  • traviscf
    • Site Builder, Child of Zeus

    @Jonathan,

    I still feel like something isn't right here. Please correct me if I'm wrong though.

    I had a customer sign up for a 14 day trial on Feb 10th. That means their trial is going to expire on Feb 24th. On Feb 15th, the customer signed up for a paid plan. There was a $0 payment (I guess because they are still in the trial?). But in the Stripe invoice line item is says:

    Subscription to Pro: Monthly ($29.00/month) Feb 15, 2014 — Mar 1, 2014 $0.00

    It shows that the next payment is on March 1st. Shouldn't their next payment be on Feb 24th though since that's when the trial is over? How did it get March 1st? Also, is that supposed to be a $0 charge when they signed up for a paid plan on Feb 15th? I can see it being a $0 charge if the period was from the 15th -24th since that was still the trial period.

  • traviscf
    • Site Builder, Child of Zeus

    I've had a chance to see a little more of what's going on. It really looks like it's adding the trial period even after they have already gone through the trial period.

    I even had this happen for existing customers. Someone's payment failed so they corrected their payment information and now it gave them 14 days and says they are trialing until Mar 2nd.

  • Jonathan
    • The Bug Hunter

    Hey @traviscf,

    I'm seeing that too. Basically, the logic is breaking when determining if a free trial should be allowed or not. If someone signs up for a free trial and then decides to change their plan or give their billing info before their trial ends they should still be allowed to finish their trial before actually being charged. But that's where things are getting messed up.

    I'm working on it... :slight_smile:

  • traviscf
    • Site Builder, Child of Zeus

    My Pro-Sites / Stripe problems are still not over but now I've got a new problem. I just had a customer try to checkout after their trial ended today. They got this error:

    invalid timestamp: must be an integer unix timestamp in the future

    Please help!

  • traviscf
    • Site Builder, Child of Zeus

    This is the error in the logs in stripe:

    Parsed Request POST Body

    plan: "pro_1_1"
    prorate: "true"
    trial_end: "1393536191"

    Response body

    error:
    type: "invalid_request_error"
    message: "Invalid timestamp: must be an integer Unix timestamp in the future."
    param: "trial_end"

    Does it have something to do with prorating? I guess there shouldn't be any prorating going on here though because the trial has ended today.

  • Jonathan
    • The Bug Hunter

    Hey @traviscf,

    Ugh - sorry about the continued bug! I see what's going on this particular case. If you could open gateway-stripe.php and go to line 878 - looks like this:

    /***** DETERMINE TRIAL END (IF APPLICABLE) *****/
    
    if ( !$psts->is_existing($blog_id) ) {
    	//customer is new - add trial days
    	$args['trial_end'] = strtotime('+ ' . $trial_days . ' days');
    } elseif ( is_pro_trial($blog_id)  ) {
    	//customer's trial is still valid - carry over existing expiration date
    	$args['trial_end'] = $psts->get_expire($blog_id);
    }

    Replace with the following:

    /***** DETERMINE TRIAL END (IF APPLICABLE) *****/
    
    if ( !$psts->is_existing($blog_id) ) {
    	//customer is new - add trial days
    	$args['trial_end'] = strtotime('+ ' . $trial_days . ' days');
    } elseif ( is_pro_trial($blog_id) && $psts->get_expire($blog_id) > time() ) {
    	//customer's trial is still valid - carry over existing expiration date
    	$args['trial_end'] = $psts->get_expire($blog_id);
    }

    Basically, I added an additional check to see if the current expiration has passed and if it has just skip over the "trial_end" argument all together.

  • traviscf
    • Site Builder, Child of Zeus

    @Jonathan

    I think there's still a problem.

    I had a client sign up for a 14 day trial on Feb 24. Their site was set to expire on March 10th. They upgraded to pro on March 5th. I see that a payment was taken yesterday in stripe yet in the Prosites plugin it shows that the site has expired. It was never changed over to Pro from Trial.

    UPDATE: Please disregard. There was a problem with my site at the time the web hook went through so that's why it didn't show up in Prosites plugin. Everything should be fine.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.