Closed nathhenry3 closed 3 years ago
I'm actually working on this now. Should be ready tomorrow.
Thank you! You guys are legends
haha thanks!
It should work now. You'll need to install the latest version of polished from GitHub using remotes::install_github("tychobra/polished")
and then restart your R session.
I went ahead and made a bunch of long overdue changes to the API to get this working, so it is likely that I introduced a couple bugs. I'll work on cleaning up any bugs over the next few days. Let me know if you run into any issues!
Hmm. When I run my code now, I get the following warning:
Warning: Unknown or uninitialised column: `stripe_subscription_id`.
followed by the error message:
<simpleError in if (is.na(sub_db$stripe_subscription_id)) { shiny::updateQueryString(queryString = "?page=account", session = session, mode = "replace") session$reload()} else { stripe_sub <- get_stripe_subscription(sub_db$stripe_subscription_id) if (stripe_sub$trial_days_remaining > 0 || !is.na(stripe_sub$default_payment_method)) { session$userData$subscription(list(free_user = FALSE, price_id = stripe_sub$plan_id, nickname = stripe_sub$nickname, is_billing_enabled = if (is.na(stripe_sub$default_payment_method)) FALSE else TRUE, trial_days_remaining = stripe_sub$trial_days_remaining)) return() } else { shiny::updateQueryString(queryString = "?page=account", session = session, mode = "replace") session$reload() }}: argument is of length zero>
Any thoughts? It appears that there may still be an issue when dealing with NULL values?
Whoops! I think it should work now. Please install the latest dev versions of {polished} and {polishedpayments}.
Progress! I can now see the payments page. However when I try to open a plan, it comes up with the following message:
[1] "unable to get invoices"
<http_400 in doTryCatch(return(expr), name, parentenv, handler): Bad Request (HTTP 400).>
This message appears for BOTH a paying user and for a 'free_user' role, which I've set up in polished.tech.
For some reason I am not getting the same error. When you have a minute, can you please pull the latest and give it another shot? I improved the error message, and I'm hoping this new error message will help us resolve this most recent bug.
Ok so the new error I'm seeing is the following, as soon as the payments screen appears (this doesn't occur for the free_user role):
[1] "unable to get invoices"
<simpleError: list(code = "resource_missing", doc_url = "https://stripe.com/docs/error-codes/resource-missing", message = "No such customer: 'cus_JxVeQfN74BGSmk'; a similar object exists in test mode, but a live mode key was used to make this request.", param = "customer", type = "invalid_request_error")>
I have tried this in test mode, and it appears to work fine, but I need to try an actual payment which is why I've been using production mode - this is where the error is occurring. Hence the 'similar object exists in test mode' - I already have customers with the same address in test mode.
Then when I try to select a subscription:
<http_400 in doTryCatch(return(expr), name, parentenv, handler): Bad Request (HTTP 400).>
I also see the following 'Error in setup intent' message at the bottom of the screen whenever I try to select a subscription:
Thanks for the detail! Yes currently you can only make a customer either in test mode or in production mode, not both. I set it up this way because I have 2 separate databases (one for development and one for production) where I can separate out the users, but naturally you only have access production. I'll update the package so that you can have a dev and production customer for each user.
I think the setup intent error is the same issue (i.e. we are sending the dev Stripe customer ID to your prod Stripe environment). Thanks again for the bug report!
That makes sense - tested with a new customer and it all appears to be working fine now. That was the last step for me - am currently building my app on Cloud Run and putting it into production in 2 hours.
Thank you so much!!
@nathhenry3 I just pushed the updates to the API and polishedpayments to distinguish between test and live Stripe customers. Please install the lastest dev version of polishedpayments.
Unfortunately I am not sure which of your existing customers are live/test. I set all the existing customers in the database to test customers, which will cause issues for any of your existing live Stripe customers. If you can give me the emails of any your live Stripe customers I can manually update in the database. You can email me the email addresses at andy.merlinoa@tychobra.com
Hi guys,
I notice in app_module.R that it is not possible to create a subscription unless the number of trial days is > 0 - see code snippet below:
Is there any way to enable this, or is this a feature of Stripe that you must have a trial period?
Thanks a lot!