如何调试Django的贝宝IPN? [英] How to debug Django PayPal IPN?

查看:152
本文介绍了如何调试Django的贝宝IPN?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这个Django应用程序实施贝宝IPN。我使用的是测试它的PayPal的 IPN模拟器,但它告诉我

I'm using this django app to implement PayPal IPN. I'm testing it using PayPal's IPN simulator, but it's telling me

IPN传递失败。 HTTP错误code 500:内部服务器错误

IPN delivery failed. HTTP error code 500: Internal Server Error

所以,我怎么能调试这,看看到底发生了什么呢?我已经挖成code:

So how can I debug this and see what's really going on? I've dug into code:

@require_POST
def ipn(request, item_check_callable=None):
    """
    PayPal IPN endpoint (notify_url).
    Used by both PayPal Payments Pro and Payments Standard to confirm transactions.
    http://tinyurl.com/d9vu9d

    PayPal IPN Simulator:
    https://developer.paypal.com/cgi-bin/devscr?cmd=_ipn-link-session
    """
    flag = None
    ipn_obj = None
    form = PayPalIPNForm(request.POST)
    if form.is_valid():
        try:
            ipn_obj = form.save(commit=False)
        except Exception, e:
            flag = "Exception while processing. (%s)" % e
    else:
        flag = "Invalid form. (%s)" % form.errors

    if ipn_obj is None:
        ipn_obj = PayPalIPN()    

    ipn_obj.initialize(request)

    if flag is not None:
        ipn_obj.set_flag(flag)
    else:
        # Secrets should only be used over SSL.
        if request.is_secure() and 'secret' in request.GET:
            ipn_obj.verify_secret(form, request.GET['secret'])
        else:
            ipn_obj.verify(item_check_callable)

    ipn_obj.save()
    return HttpResponse("OKAY")

所有的看起来的罚款和花花公子那里,但因为它不是发送到响应的我的的浏览器,它有点棘手的调试。我该怎么办?我想看看我的Apache日志,但它确实没有告诉我了。

All looks fine and dandy there, but since it's not sending a response to my browser, it's kinda tricky to debug. What should I do? I'm trying to look at my apache logs, but it really isn't telling me much.

216.113.191.33 - - [06 /月/ 2010:14:10:3​​0 -0600]POST /贝宝/ IPN HTTP / 1.0500 16282 - -

216.113.191.33 - - [06/Mar/2010:14:10:30 -0600] "POST /paypal/ipn HTTP/1.0" 500 16282 "-" "-"

我试图发送电子邮件和日志信息时,这一观点被称为,但也想工作。这可能是我输入了错误的网址为:)我禁用后需要装饰,并到页面直接看到发生了什么事情的IPN模拟器。我的系统向我发送该数据开始记录预期(因为没有数据后)无效交易,然后我在黑暗中了一个随机的防刺和计算过,Django的CSRF保护被踢和preventing贝宝。添加 @csrf_exempt 装饰似乎已经解决了。耶的猜测错误。


I tried to send emails and log messages when this view was called, but neither wanted to work. It's possible that I entered the wrong URL into the IPN simulator :) I disabled the "post required" decorator and went to the page directly to see what was going on. My system started to logging "invalid transactions" as expected (since there was no post-data) and then I took a random stab in the dark and figured that Django's CSRF protection was kicking in and preventing PayPal from sending me the data. Adding the @csrf_exempt decorator seems to have fixed it. Yay for guessing errors.

推荐答案

我记得曾触及(类似)使用Django的贝宝时得此。我不记得知道什么我的原因是,但你有没有创建/包括你setttings.py IPN的应用程序迁移后,在数据库中的相应的IPN表?

I recall having hit (something like) this when using django-paypal too. I can't remember for sure what my cause was, but have you created/migrated the appropriate IPN tables in your database after including the ipn app in your setttings.py?

这篇关于如何调试Django的贝宝IPN?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆