stripe test mode

This commit is contained in:
Russell Ballestrini 2024-12-13 00:58:29 +00:00
parent 11c5b7eecb
commit e84a58061d
3 changed files with 24 additions and 4 deletions

View file

@ -53,6 +53,10 @@ app.bucket.secure_uploads.access_key = ${MPS_APP_SECURE_UPLOADS_ACCESS_KEY}
app.bucket.secure_uploads.secret_key = ${MPS_APP_SECURE_UPLOADS_SECRET_KEY}
# stripe test mode is enabled for development & disabled by default.
app.stripe.test_mode = True
# set this to the path of your private DKIM key.
# reference: https://russell.ballestrini.net/quickstart-to-dkim-signed-email-with-python/
#app.email.dkim_private_key_path = ${MPS_APP_DKIM_PRIVATE_KEY_PATH}

View file

@ -387,6 +387,7 @@ def shop_settings(request):
"plausible_domain_name", shop.plausible_domain_name or ""
).strip()
stripe_test_mode = request.app.get("stripe.test_mode", False)
stripe_public_api_key = request.params.get(
"stripe_public_api_key", shop.stripe_public_api_key
)
@ -505,8 +506,14 @@ def shop_settings(request):
if stripe_public_api_key != shop.stripe_public_api_key:
if stripe_public_api_key.startswith("pk_"):
shop.stripe_public_api_key = stripe_public_api_key
msg = ("You set the shop's stripe_public_api_key.", "success")
if not stripe_test_mode and "_test_" in stripe_public_api_key:
msg = (
"Test Stripe keys are not allowed. Please create a test shop at test.makepostsell.com.",
"error",
)
else:
shop.stripe_public_api_key = stripe_public_api_key
msg = ("You set the shop's stripe_public_api_key.", "success")
else:
msg = (
"The shop's stripe_public_api_key must start with 'pk_'.",
@ -516,8 +523,14 @@ def shop_settings(request):
if stripe_secret_api_key != shop.stripe_secret_api_key:
if stripe_secret_api_key.startswith("sk_"):
shop.stripe_secret_api_key = stripe_secret_api_key
msg = ("You set the shop's stripe_secret_api_key.", "success")
if not stripe_test_mode and "_test_" in stripe_secret_api_key:
msg = (
"Test Stripe keys are not allowed. Please create a test shop at test.makepostsell.com.",
"error",
)
else:
shop.stripe_secret_api_key = stripe_secret_api_key
msg = ("You set the shop's stripe_secret_api_key.", "success")
else:
msg = (
"The shop's stripe_secret_api_key must start with 'sk_'.",

View file

@ -27,6 +27,9 @@ app.bucket.secure_uploads.get_endpoint = https://plan-period-files.nyc3.digitalo
app.bucket.secure_uploads.access_key = ${MPS_APP_SECURE_UPLOADS_ACCESS_KEY}
app.bucket.secure_uploads.secret_key = ${MPS_APP_SECURE_UPLOADS_SECRET_KEY}
# stripe test mode is enabled for development & disabled by default.
app.stripe.test_mode = True
[pshell]
setup = make_post_sell.scripts.pshell.setup