Django项目未调用Paypal IPN notify_url

时间:2018-10-15 08:48:54

标签: python django paypal-sandbox paypal-ipn django-signals

除了通知url接收器,所有其他工作都无法正常进行 以下是我的views.py

中的代码
def view_that_asks_for_money(request):
# generating invoice id
total_invoices = 0
invoices_of_user = Invoice.objects.all().filter(user__username__exact=request.user.username)
if invoices_of_user:
    total_invoices = len(invoices_of_user)
total_invoices += 1
invoice_key = request.user.username + "-" + str(total_invoices)
Invoice.objects.create(user=request.user, invoice_no=invoice_key)
print(invoice_key, reverse('paypal-ipn'))
valid_ipn_received.connect(receiver=show_me_the_money)
print(valid_ipn_received.receivers)
# What you want the button to do.
paypal_dict = {
    "business": "osama.jameel.ahmad-facilitator@gmail.com",
    "amount": "14.99",
    "item_name": "One Month Premium Package",
    "invoice": invoice_key,
    "notify_url": "http://0.0.0.0:8000/" + reverse('paypal-ipn'),
    "return_url": "http://0.0.0.0:8000/app/dashboard",
    "cancel_return": "http://0.0.0.0:8000/app/change_password",
}
# Create the instance.
form = PayPalPaymentsForm(initial=paypal_dict)
context = {"form": form}

return render_to_response("core/payment.html", context)

@require_POST
@csrf_exempt
def ipn(request):
    print("ipn(request)")

也是views.py中的接收者方法

def show_me_the_money(sender, **kwargs):
print("show_me_the_money: ")
ipn_obj = sender
print("show_me_the_money: " + ipn_obj.payment_status)

以下是我urls.py中的网址

url(r'^paypal_ipn/', views.ipn, name="paypal-ipn"),
url(r'^something/paypal/', include('paypal.standard.ipn.urls')),
#patterns('paypal.standard.ipn.views',url(r'^paypal_notification/', 'ipn', name="paypal-ipn"),)
#url(r'^show_me_the_money/', core_views.show_me_the_money, name='show_me_the_money'),
url(r'^payment/', core_views.view_that_asks_for_money, name='paypal_page'),

0 个答案:

没有答案