Paypal IPN notify_url未在Django项目中调用

2024-06-11 21:26:27 发布

您现在位置:Python中文网/ 问答频道 /正文

除了通知url接收者回拨不起作用外,其他一切都正常 以下是我的代码视图.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)")

还有中的接收器方法视图.py在

^{pr2}$

以下是我的网址.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'),

Tags: thekeynameurlrequestshowinvoicepaypal