Subscriptions with pricing table - customer not found response

Hi folks! I’m having an issue and have been hacking away at it for a few days, with no success, so hoping someone here might be able to help :slight_smile:

Discourse 3.4.0.beta1-dev
Subscriptions 2.8.1 - f0b4984
Docker install on Linux VM

I’ve installed and activated the subscriptions plugin, and it works most of the time when using the built-in pricing table (occasionally a user is not added to groups after a sub, but that’s a separate issue I guess).

However, I really need to use the Stripe pricing table and checkout for the familiar UX and trust it brings. To this end I have everything set up for webhooks, with all the secrets etc configured (currently using test mode so using test mode keys and secrets).

I can successfully go to the subscription page, go through the checkout flow from the pricing table, and check out with the test cards.

However, this results in no subscription being created in Discourse and no change in user’s groups, and looking at the web hooks in Stripe’s dashboard I see that they are getting a 422 response with the body:

{
  "errors": [
    "customer not found"
  ]
}

I’ve tried this with a few different users now, and the result is always the same.

Having looked in the database, I’m not seeing the customers noted in the Stripe webhook in the discourse_subscriptions_customers table, and no corresponding subscription in the discourse_subscriptions_subscriptions table either - which I guess might be expected since the webhook call is never being processed?

FWIW I have verified Stripe webhook calls can succeed in general - if I have the “use Stripe pricing table” setting disabled, and go through the built-in checkout to create a subscription then everything is fine - and if I then cancel the subscription from Stripe then the customer.subscription.deleted webhook comes through no problem.

Hoping I’ve just done something silly here and it’s not set up correctly, but really struggling to figure out what I need to do to get it working.

Thanks in advance!
Ross

1 Like

Sorry you are having issues, but thank you for bringing this up. Hopefully we can figure out what is going on. First question I have is are the products you have selected for the pricing table ones that you have created from inside of Discourse or were they created inside of Stripe?

I’m getting this error as well in my production environment that I set up, but not locally, so it’s kind of hard to debug. I’m looking into though!

Thanks for the reply :slight_smile:

I have tried it both ways, initially I had products set up in Stripe, and then found threads here suggesting they needed to be created inside of Discourse so I switched to doing that instead. However, I still see the same issue.

I’m assuming (and apologies if incorrect) that the link to groups is driven by the product metadata? I see this under there:

(The group_name varies depending on the price tier, which is what I’d expect based on how I have things set up in Discourse).

Thank you for looking into this, let me know if there’s anything more I can do to help :slight_smile:

I’ve created a fix for the customer not found response with the pricing table. If you update your subscriptions plugin and try again it should work now.

2 Likes

Apologies for the delay getting back to you, and thanks again for looking at it :slight_smile:

I just got everything updated and did a quick test, and am still seeing the same response (i.e. customer not found) to the stripe web hooks.

Do you think I maybe should create a completely new pricing table / set of products and test with that, to rule out any issues that might be left over from previous tests (I did use a new user for this test, but the products are the ones that were there from before).

Can you confirm again what you have for the commit hash underneath the version number on the /admin/plugins page?

And is this for a subscription or a one-off purchase with the pricing table?

I did add a new setting for the subscription plugin for debugging. It is called discourse_subscriptions_enable_verbose_logging. Once that is enabled you can visit /logs and try the checkout process again and see if you see any output from it. Feel free to send me some screenshots of it in a PM and can help debug things further for you.

Sure, no probs. The commit hash I have is the same as in your screenshot, f1b9c96 :slight_smile:

This is for a subscription, with the pricing table.

Okay, awesome, thanks. I’ll try and enable that setting and take a look at the logs :slight_smile:

Thanks again for your help :slight_smile:

2 Likes