小编Fig*_*ode的帖子

Stripe:未找到与使用 Django 的有效负载的预期签名匹配的签名

当 Stripe 调用定义的 Web 挂钩时,我收到以下错误

未找到与有效负载的预期签名匹配的签名

我正在关注这篇文章:https://stripe.com/docs/billing/subscriptions/checkout#provision-and-monitor

我有以下代码:

@csrf_exempt
def saaswebhookview(request):
    try:
        stripe.api_key = settings.STRIPE_SECRET_KEY
        webhook_secret = 'stripe_key'
        request_data = request.POST
        if webhook_secret:
            try:
                signature = request.headers.get('stripe-signature')
                # signature = request.META['stripe-signature']
                event = stripe.Webhook.construct_event(
                    payload=request.POST, sig_header=signature, secret=webhook_secret)
                data = event['data']
            except Exception as e:
                print(str(e))
                return JsonResponse({'status': 'error', 'error': str(e)})
            event_type = event['type']
        else:
            data = request_data['data']
            event_type = request_data['type']
        data_object = data['object']
        if event_type == 'checkout.session.completed':
            print(data)
        elif event_type == 'invoice.paid':
            print(data)
        elif event_type == 'invoice.payment_failed':
            print(data)
        else: …
Run Code Online (Sandbox Code Playgroud)

python django stripe-payments

5
推荐指数
2
解决办法
3826
查看次数

Django createsuperuser 抛出 django.core.exceptions.FieldDoesNotExist: User has no field named ' ' 错误

当我尝试使用 python manage.py createsuperuser 命令创建超级用户时,它抛出以下错误:

Username: wcud
Traceback (most recent call last):
  File "/home/Music/ENV/lib/python3.5/site-packages/django/db/models/options.py", line 617, in get_field
    return self.fields_map[field_name]
KeyError: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/home/Music/ENV/lib/python3.5/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "/home/Music/ENV/lib/python3.5/site-packages/django/core/management/__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/Music/ENV/lib/python3.5/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/Music/ENV/lib/python3.5/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 63, in execute
    return super(Command, self).execute(*args, **options)
  File "/home/Music/ENV/lib/python3.5/site-packages/django/core/management/base.py", line 330, in …
Run Code Online (Sandbox Code Playgroud)

python django django-users

1
推荐指数
1
解决办法
1833
查看次数

标签 统计

django ×2

python ×2

django-users ×1

stripe-payments ×1