当我将其更改为我的域和 https 时,Stripe Webhook 不起作用

问题描述

我正在尝试使用 Stripe 配置 Django 应用程序。

当使用“IP 地址”和“http”设置端点 URL 时,Webhook 运行良好。

这是端点 URL。

http://3.129.xx.xxx/subscriptions/webhook/

但是当我将其更改为我的域并添加“https”时,它不起作用。

这是包含我的域的端点 URL。

https://mysite12345.com/subscriptions/webhook/

1.HTTP statas 代码是“超时”。

2.事件类型为“checkout.session.completed”

3.日志为“200 OK”但“Webhook event”失败,反复重试还是失败。

4.当然,域名是有效的(我可以访问其他页面

5.SSL 证书由 AWS 颁发。

6.Testing 端点只是手动执行 POST 请求,它说。

KeyError at /subscriptions/webhook/
'HTTP_STRIPE_SIGNATURE'
Request Method: GET
Request URL:    http://mysite12345.com/subscriptions/webhook/
Django Version: 3.2.4
Exception Type: KeyError
Exception Value:    
'HTTP_STRIPE_SIGNATURE'
Exception Location: /home/app_admin/venv_ruling/ruling/subscriptions/views.py,line 103,in stripe_webhook
Python Executable:  /home/app_admin/venv_ruling/bin/python3
Python Version: 3.7.8
Python Path:    
['/home/app_admin/venv_ruling/ruling','/usr/lib64/python37.zip','/usr/lib64/python3.7','/usr/lib64/python3.7/lib-dynload','/home/app_admin/venv_ruling/lib64/python3.7/site-packages','/home/app_admin/venv_ruling/lib/python3.7/site-packages']

在“请求 URL:”中,它说的是“http”而不是“https”,我也想知道是否可以。

7.下面是对端点的请求

{
  "id": "evt_1JFX0XJvSJBZN02KlqeHjJWi","object": "event","api_version": "2020-08-27","created": 1626841569,"data": {
    "object": {
      "id": "cs_test_a1VJ8H3hotDNG0bw8q583Q4r86u5J7Q0ZC4lrmCjXwwdNYE866YJiOmcza","object": "checkout.session","allow_promotion_codes": null,"amount_subtotal": 3900,"amount_total": 3900,"automatic_tax": {
        "enabled": false,"status": null
      },"billing_address_collection": null,"cancel_url": "https://mysite12345.com/subscriptions/cancel/","client_reference_id": "1","currency": "usd","customer": "cus_JtJdr9wDqNEdBf","customer_details": {
        "email": "myemail@gmail.com","tax_exempt": "none","tax_ids": [
        ]
      },"customer_email": null,"livemode": false,"locale": null,"Metadata": {
      },"mode": "subscription","payment_intent": null,"payment_method_options": {
      },"payment_method_types": [
        "card"
      ],"payment_status": "paid","setup_intent": null,"shipping": null,"shipping_address_collection": null,"submit_type": null,"subscription": "sub_JtJdTWtjY315lM","success_url": "https://mysite12345.com/subscriptions/success?session_id={CHECKOUT_SESSION_ID}","total_details": {
        "amount_discount": 0,"amount_shipping": 0,"amount_tax": 0
      },"url": null
    }
  },"pending_webhooks": 1,"request": {
    "id": "req_NX2udo8Xr4P94W","idempotency_key": null
  },"type": "checkout.session.completed"
}

我想知道为什么 IP 地址和“http”端点 URL 可以正常工作,而域名和“https”却不行。

当我将“http”更改为“https”时,我需要调整某些内容还是遗漏了某些内容

我刚刚在这个问题中提到了上述设置,但如果需要更多代码,请告诉我我会用这些信息更新我的问题。

谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)