django paypal notify_url未正确配置或工作



我为django paypal做了一个PIP安装。按钮渲染和付款通过。返回URL也有效,但notify_url部分无法正常工作。因此,我无法更新我的数据库,即销售已经通过。

我也没有任何错误,所以我很难过。如果有人可以帮助ID,真的很感激。谢谢

编辑:我将from paypal.standard.ipn.signals import payment_was_successful添加到视图页面的顶部。并将我的notify_url的名称更改为show_me_the_money(不确定这是否重要),我从一个名为http://djangodersleri.blogspleri.blogspot.ie/2013/11/paypal-ipn-ipn-with-with-django.html中获得了它。但是好事现在至少我似乎是在桌上记录了我的交易。但仅此而已!所以仍然不知道是否正在执行show_me_the_money视图。

这是我拥有的..

设置...

    INSTALLED_APPS = (
    ...
        'paypal.standard.ipn',
)
PAYPAL_RECEIVER_EMAIL = "my_sandbox_test_email_is_here@gmail.com"
PAYPAL_TEST = True

url ...

(r'^show_me_the_money /', include('paypal.standard.ipn.urls')),

视图...

from paypal.standard.models import ST_PP_COMPLETED
from paypal.standard.ipn.signals import valid_ipn_received 
from paypal.standard.ipn.signals import payment_was_successful
def show_me_the_money (sender, **kwargs):
    ipn_obj = sender
    if ipn_obj.payment_status == ST_PP_COMPLETED:
        doc_id=ipn_obj.item_number1 # :document_id,
        us_id=ipn_obj.item_number2 #user.id,
        obj_doc=Document.objects.get(id=doc_id)
        my_user = User.objects.get(id=us_id)
        obj_doc.users.add(my_user)
        obj_doc.save()

    try:
        ipn_obj.verify(item_check_callable)
    except:
        import sys, traceback
        traceback.print_exc(file=sys.stdout)           
    valid_ipn_received.connect(paid)
@csrf_exempt
def myvideos(request):

    try:
        my_vids=Document.objects.filter(users=request.user.id)#request.user.id
    except: 
        return render_to_response(
        'myvideos.html',
        context_instance=RequestContext(request)
        )
       #my_vids= Document.objects.filter(users=request.user.id)       
    return render_to_response(
        'myvideos.html',
        {'my_vids': my_vids},
        context_instance=RequestContext(request)
        )

def video(request, document_id):
    document = Document.objects.get(id=document_id)
    if request.user.id:
        d1 =datetime.datetime.now()
        t=d1.strftime('%y%m%d%h%m%s')
        pp_price = str(document.price)
        # What you want the button to do.
        paypal_dict = {
            "business": settings.PAYPAL_RECEIVER_EMAIL,
            "amount": pp_price + ".00",
            "item_number1":document_id,
            "item_number2":request.user.id,
            "item_name": document.name,
            "invoice": document.name+t,
            "notify_url": "http://wackosmackosite.com/"+ reverse('paypal-ipn'),
            "return_url": "http://wackosmackosite.com/myvideos/",
            "cancel_return": "http://wackosmackosite.com/video/"+document_id+"/",
        }
        form = PayPalPaymentsForm(initial=paypal_dict)
        context = {"form": form, "document":document }
        return render(request, "video.html", context)
    else:
        return render_to_response('video.html',{'document': document},
                                  context_instance=RequestContext(request))

这是paypal.standard.ipn的URL

from django.conf.urls import url
from paypal.standard.ipn import views
urlpatterns = [
    url(r'^$', views.ipn, name="paypal-ipn"),
]

首先,@mcastle非常感谢您的帮助。但是我只是找不到django信号。

好吧,我最终要做的是转到paypal.standard.ipn.ipn.views文件并导入我的应用程序,然后在视图的底部从那里调用show_me_the_money视图,然后返回HTTP响应。

因此,PayPal dict中的通知URL ...

"notify_url": "http://wackosmackosite.com/show_me_the_money/",

和我的URL文件中的URL就是这样..

 url(r'^show_me_the_money/', include('paypal.standard.ipn.urls')),

我能够从传递给show_me_the_money的参数中更新数据库所需的信息。这样...

def show_me_the_money(sender, **kwargs):
    ipn_obj = sender
    payStatus=ipn_obj.POST.get('payment_status','')
    if payStatus=='Completed':
        ....

然后在PayPal IPN视图中在顶部...

from myApp.views import show_me_the_money

在底部...

s_m_t_m=show_me_the_money(request, item_check_callable=None)
return HttpResponse("OKAY")

我发现整个设置非常令人困惑,并认为对我的文档却没有很多重要的东西。无论如何,这现在正常工作,我只是与Pay Pal下了电话,他们很高兴配置正确。

查看Django的信号文档。show_me_the_money看起来需要连接到信号。

相关内容

  • 没有找到相关文章

最新更新