What I’m trying to do:
I am trying to integrate stripe payments flow into my app.
What I’ve tried and what’s not working:
I have added anvil stripe service to my app in test mode, and connected it to my stripe account. I added
import stripe.checkout
to my client side code.
After that, I am trying to test it by using
charge = stripe.checkout.charge(currency=“USD”,amount=499)
in the client side code.
I am getting the pop-up window, and when I enter the test credit card id ‘4242424242424242’, the button turns green. Then after a couple of seconds, I get
anvil.server.InternalError: Internal server error: 4ff657e585cd at Subscriptions, line 100
line 100 is the line which contains the stripe.checkout.charge line above is located.
I get the same error with a different number even if I use the code given in the docs for server side payment charging.
I have tried removing the stripe service and adding it again in test mode. Still the same.
I have tried ‘stripe.checkout.get_token’ on the client side code, which works fine. But the server side ‘anvil.stripe.new_customer’ gives me the same anvil.server.InternalError error.
I’ve implemented stripe a couple of times lately following the docs and the only additional think I needed to do was import stripe on my server side and it worked a treat. Not sure what’s happening for you but it may be a good idea to provide a clone app so the community can dip in.
Thanks. I wonder if this is an account specific thing. Some people are encountering this and others are not. There are a couple of these errors discussion on the forum, but it is unclear how they got resolved.
The fact that just the simplest stripe.checkout.charge on the client-side code, (after doing import stripe.checkout), is not working, and the error is anvil.server.InternalError, seems to me that there is some connectivity issue related to adding the stripe service to my app. I am not using the anvil server for my server side code - it is running on my own server.
When the stripe.checkout service is called, maybe anvil server is being used to connect with stripe servers and there is some error or misconfiguration specific to my account?
I have created the most basic app with just the suggested stripe code. I still get the same error. It appears there is something wrong with my account. My stripe account appears to connect with no visible problems.
I do see “Your app is connected to the xxx Stripe account”, and “The stripe service is currently in Test Mode” at the Stripe API service in my app. Whatever is happening to create the error is not visible to me.
I am sorry, this has been a frustrating last couple of days. I still have no idea what is happening with the stripe payments. I have even tried the Raw Stripe API keys, and setup the stripe api secret in anvil secrets. And then the error is ““Uplink code cannot access secrets for this app.”” WHY?? UPDATE: This is because anvil secrets is not accessible from an uplink as mentioned in the docs. (My mistake… I did not read the docs properly). So I created a server module on anvil servers just for the stripe payments. This sidesteps the above error with the secrets. However, I still get “no such token” error once the code runs as below
I have even tried to manually enter the keys directly into the code. Then the error becomes “No such token:”. Update: The “No such token” error is happening because I missed the “raw=True” entry. Once that is fixed, the actual problem has appeared. This issue is caused due to payments processing that are country specific (not particular to my account, but to the country). We cannot use the stripe charges API, but have to use stripe payment intent API due to local restrictions. I would not have understood this without using Stripe’s python API. Will have to recreate the workflow based on this new information
Thanks