gpt4 book ai didi

django paypal notify_url 未正确配置或工作

转载 作者:太空宇宙 更新时间:2023-11-03 16:27:42 24 4
gpt4 key购买 nike

我为 django paypal 安装了 pip。按钮呈现并且付款通过。返回 url 也有效,但 notify_url 部分无效。所以我无法更新我的数据库以了解销售已经完成。

我也没有收到任何错误,所以我很困惑。如果有人可以提供帮助,我将不胜感激。谢谢

Edit: I added from paypal.standard.ipn.signals import payment_was_successful to the top of my views page. and changed the name of my notify_url to show_me_the_money (Not sure if that matters) I got it from a blog called http://djangodersleri.blogspot.ie/2013/11/paypal-ipn-with-django.html. But the good thing is now at least I seem to be getting my transactions recorded in the table paypal_ipn. But that's all! So still dont know if the show_me_the_money view is being executed.

这是我的..

设置...

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

网址...

(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 的网址

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.views 文件并导入我的应用程序,并在返回 http 响应之前从 View 的最底部调用 show_me_the_money View .

所以 paypal 字典中的通知 url 是这样的...

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

我的 urls 文件中的 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 paypal notify_url 未正确配置或工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30035565/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com