diff --git a/development.ini b/development.ini index e209f09..631696b 100644 --- a/development.ini +++ b/development.ini @@ -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} diff --git a/make_post_sell/views/shop.py b/make_post_sell/views/shop.py index e63e92b..62fb309 100644 --- a/make_post_sell/views/shop.py +++ b/make_post_sell/views/shop.py @@ -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_'.", diff --git a/test.ini b/test.ini index 26888c8..213a9f2 100644 --- a/test.ini +++ b/test.ini @@ -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