(app_configs=None, **kwargs)
return messages
Check the user has configured API live/test keys correctly.
Check the user has configured API live/test keys correctly.
Check the user has configured API live / test keys correctly .
def check_stripe_api_key(app_configs=None, **kwargs):
    """Check the user has configured API live/test keys correctly."""
    from .settings import djstripe_settings

    messages = []

    if not djstripe_settings.STRIPE_SECRET_KEY:
        msg = "Could not find a Stripe API key."
        hint = "Add STRIPE_TEST_SECRET_KEY and STRIPE_LIVE_SECRET_KEY to your settings."
        messages.append(checks.Critical(msg, hint=hint, id="djstripe.C001"))
    elif djstripe_settings.STRIPE_LIVE_MODE:
        if not djstripe_settings.LIVE_API_KEY.startswith(("sk_live_", "rk_live_")):
            msg = "Bad Stripe live API key."
            hint = 'STRIPE_LIVE_SECRET_KEY should start with "sk_live_"'
            messages.append(checks.Critical(msg, hint=hint, id="djstripe.C002"))
    else:
        if not djstripe_settings.TEST_API_KEY.startswith(("sk_test_", "rk_test_")):
            msg = "Bad Stripe test API key."
            hint = 'STRIPE_TEST_SECRET_KEY should start with "sk_test_"'
            messages.append(checks.Critical(msg, hint=hint, id="djstripe.C003"))

    return messages
def check_stripe_api_key ( app_configs = None , * * kwargs ) : from . settings import djstripe_settings messages = [ ] if not djstripe_settings . STRIPE_SECRET_KEY : msg = "Could not find a Stripe API key." hint = "Add STRIPE_TEST_SECRET_KEY and STRIPE_LIVE_SECRET_KEY to your settings." messages . append ( checks . Critical ( msg , hint = hint , id = "djstripe.C001" ) ) elif djstripe_settings . STRIPE_LIVE_MODE : if not djstripe_settings . LIVE_API_KEY . startswith ( ( "sk_live_" , "rk_live_" ) ) : msg = "Bad Stripe live API key." hint = 'STRIPE_LIVE_SECRET_KEY should start with "sk_live_"' messages . append ( checks . Critical ( msg , hint = hint , id = "djstripe.C002" ) ) else : if not djstripe_settings . TEST_API_KEY . startswith ( ( "sk_test_" , "rk_test_" ) ) : msg = "Bad Stripe test API key." hint = 'STRIPE_TEST_SECRET_KEY should start with "sk_test_"' messages . append ( checks . Critical ( msg , hint = hint , id = "djstripe.C003" ) ) return messages