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

    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.

  • traviscf

    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.

  • Aaron

    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

    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

    @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

    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

    @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

    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

    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

    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

    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

    @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.

  • Jonathan

    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

    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

    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

    @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.