【问题标题】:django-paypal suddenly stop recieving signals from Paypaldjango-paypal 突然停止接收来自 Paypal 的信号
【发布时间】:2018-08-18 18:58:30
【问题描述】:

我正在使用 Django-Paypal 包将 Paypal 集成到我的 Django 项目中。我已经成功配置了所有内容并且它正在工作,但突然间来自 PayPal 的信号停止了。

会出现什么问题?

这是我所做的:

来自 view.py:

def payment_process(request):
minutes = int(request.user.tagging.count()) * 5
testhours = minutes / 60
hours = str(round(testhours, 3))
# pdb.set_trace()
# What you want the button to do.
invoice = generate_cid()
userInfo = {
    "name": str(request.user.first_name + ' ' + request.user.last_name),
    "hours": str(hours),
    "taggedArticles": str(request.user.tagging.count())
}
paypal_dict = {
    "business": settings.PAYPAL_RECEIVER_EMAIL,
    "item_name": "Certificate of Completion from Nami Montana",
    "custom": userInfo,
    "invoice": str(invoice),
    "amount": "5.00",
    "notify_url": "https://6fd5e31b.ngrok.io/users/paypal/",
    # "return_url": "https://6fd5e31b.ngrok.io/users/profile/",
    "cancel_return": "https://6fd5e31b.ngrok.io/users/cancel/",
}
print(paypal_dict)
# Create the instance.
form = PayPalPaymentsForm(initial=paypal_dict)
context = {"form": form}
return render(request, "users/generateCert.html", context)

来自 urls.py:

urlpatterns = [
   url('^paypal/', include('paypal.standard.ipn.urls')),
   url('^profile/buildCertificate/$', views.CertificateProcess.as_view(), name='certificate'),
   url('^cancel/$', views.payment_canceled, name='cancel'),
   url('^done/$', views.payment_done, name='done'),
   url('^process/$', views.payment_process, name='payment'),
]

来自 signals.py:

def show_me_the_money(sender, **kwargs):
ipn_obj = sender
custom = ipn_obj.custom
# Undertake some action depending upon `ipn_obj`.
if ipn_obj.payment_status == ST_PP_COMPLETED:
    print('Get success signal')
    user_info = ast.literal_eval(ipn_obj.custom)
    if int(user_info['taggedArticles']) > 11:
        # here i need to generate and send a pdf file to the user in a new tab
        pass
else:
    print('Get fail signal')


payment_was_successful.connect(show_me_the_money)

更新:当我用实时 IPN 沙箱测试它时,它返回 IPN was sent and the handshake was verified


付款成功存入PayPal沙盒商户账户,只是信号出现问题。

请帮帮我!

提前致谢!

【问题讨论】:

  • 根据我的经验,paypal 沙箱有时会很慢。你等了多久的信号?另外,如果您不知道,您还可以在 django admin 中检查收到的 ipn 调用,这非常有用
  • 嗨@hwhite4,即使在 Django 管理员中,PayPal IPN 也不会出现。
  • 好的,你等了多久?沙箱有时发送 ipn 很慢
  • 嗨@hwhite4,如果你的意思是等待回复,那么我想我已经通过等待2-3分钟来测试它!
  • 好的,我还使用 ngrok 在沙盒上完成了测试,有时需要 20 多分钟才能获得 ipn,但有时会非常快。

标签: python django python-3.x paypal


【解决方案1】:

我也有同样的问题。我的应用程序工作,现在它没有。我尝试了很多东西(使用 python3.5 而不是 3.6,删除所有 .pyc,卸载并安装 django-paypa,更改端口......)它似乎没有改变任何东西。

我放弃了,但我一下子收到了所有信号。过了很久。之后我立即尝试,没有任何信号。

所以,对我来说,问题出在贝宝的服务器上。他们需要时间。我们必须等。

希望我的经验能帮到你:)

目前,它对我来说正常工作(2018 年 3 月 11 日上午 11 点)。我希望你也一样:)

【讨论】:

  • 嗨@Romain,你是对的,现在它也对我有用。谢谢,
猜你喜欢
  • 2017-08-05
  • 2021-06-21
  • 1970-01-01
  • 2012-07-04
  • 2011-08-15
  • 1970-01-01
  • 2023-03-13
  • 1970-01-01
  • 2016-11-16
相关资源
最近更新 更多