calcom / docker

The Docker configuration for Cal.com is an effort powered by people within the community. Cal.com, Inc. does not provide official support for Docker, but we will accept fixes and documentation. Use at your own risk.
MIT License
691 stars 363 forks source link

Error while setting up Stripe #252

Closed vitis586 closed 1 year ago

vitis586 commented 1 year ago

Hi, I am trying to self host Calcom with Stripe. I managed to start the container with the .env file which has all the relevant entries for me. Some of them are fed as docker variables. The Stripe settings correctly read the Stripe API stuff but it does not load the payment fees. Problem is when I try to enable Stripe I am getting errors. Firefox gives me e is undefined or d is undefined (this probably depends on NODE_ENV being either production or development). Opera throws more at me with Cannot read properties of undefined (reading 'length').

# Set this value to 'agree' to accept our license:
# LICENSE: https://github.com/calendso/calendso/blob/main/LICENSE
#
# Summary of terms:
# - The codebase has to stay open source, whether it was modified or not
# - You can not repackage or sell the codebase
# - Acquire a commercial license to remove these terms by emailing: license@cal.com
NEXT_PUBLIC_LICENSE_CONSENT=agree

NEXT_PUBLIC_STRIPE_PUBLIC_KEY=pk_test_example
STRIPE_PRIVATE_KEY=sk_test_example
STRIPE_CLIENT_ID=ca_example
STRIPE_WEBHOOK_SECRET=whsec_example
PAYMENT_FEE_FIXED=0
PAYMENT_FEE_PERCENTAGE=0

# E-mail settings
# Configures the global From: header whilst sending emails.
EMAIL_FROM=viktor@example.com

# Configure SMTP settings (@see https://nodemailer.com/smtp/).
EMAIL_SERVER_HOST=smtp.example.com
EMAIL_SERVER_PORT=587
EMAIL_SERVER_USER=postmaster@example.com
EMAIL_SERVER_PASSWORD=example

NODE_ENV=production

Trying to enable Stripe without the payment fees set up give error of course. Container log also does not throw anything.

{ "code": "invalid_type", "expected": "number", "received": "null", "path": [ "payment_fee_fixed" ], "message": "Expected number, received null" }
{ "code": "invalid_type", "expected": "number", "received": "null", "path": [ "payment_fee_percentage" ], "message": "Expected number, received null" } ]

Console does not show any hints in either of the browsers.

I see that one explanation might be that I need an enterprise license for that but I would expect that it would tell me straight away instead of these errors. I even filled in the Cal.com Plan Evaluation form last week but I got no reply. I am trying to set this up for my wife who is a tour guide. I would like to have it self hosted because of customer data. We are not running an enterprise here, so I think that the licence is not for me really.

Thanks

krumware commented 1 year ago

tagging @zomars for visibility

vitis586 commented 1 year ago

I guess that somebody is having a look. I just had a look and the fees were loaded from the .env file!

vitis586 commented 1 year ago

Sorry for the delay. I got sidetracked. I cracked the part with http URI. Calcom uses ${WEBAPP_URL} which I had set to http://example.com/ and then it was failing. So switching the container variable to https fixed that. That was my mistake.

I have a better understanding how the Stripe app works in Calcom. It looks like I will have to set up two Stripe accounts - for platform and for the user. Which seems to be geared towards Teams and multiple users.

I also noticed that when I set up the platform Stripe account as a testing one (not live), I then cannot connect the user account to it because I cannot connect the user Stripe account in test mode or at least I don't know how yet. The connecting of the user Stripe account ends with {"message":"Passed in testmode API key but authorization code only supports returning live keys"}

I still cannot drive the fees. Sometimes they appear but most of the time they do not.

vitis586 commented 1 year ago

I set it up all again with new secrets and live Stripe accounts for platform and user and it is working. There is no issue from Cal.com s side

krumware commented 1 year ago

Awesome! Does your update config structure match the original example you provided? Or did you find any additional keys that were needed?

vitis586 commented 1 year ago

Yes, basically it does. At some point I copied the example .env again and cut it down to the ones I only want to use. The issue I saw was mostly based on the fact that this container was fresh for me and I did not understand how it worked. The steps I took to overcome the issue:

I also successfully connected a Nextcloud calendar via CalDAV. Then I made one paid booking (I set low price, so it only cost small amount on the Stripe fee) and it was looking very good. It is very straightforward to set up even for non tech savvy people.

I wanted to turn off all unnecessary apps and functions but the settings are not persistent and everything is back on when I restart the container. I also tried to move Calcom to the final domain and I cannot get rid of the testing URL. The NEXT_PUBLIC_WEBAPP_URL is set to https://booking.example.cz but when I load the initial set up there it still shows https://i.example2.cz. So some settings are more persistent then they should be and some are not persistent at all. :) I guess that some setting are stored somewhere else (like on Calcom servers?) and not everything is in database or the .env file. I still have some work to do..