Я строию интернет-магазин.Как получить данные запроса в функции IPN django-paypal?
Данные моего заказа хранятся в запросе. Мои взгляды имеют следующую общую структуру:
payment.py
def payment(request):
order = request.order # Getting the order instance
# do some stuff
return render_to_response("payment.html")
Я использую django-paypal
. Я следую this tutorial. Следующая функция вызывается PayPal, и она сигнализирует мне, что платеж был успешным.
payment_paypal_ipn_signal_handler.py
# Almost entirely copied from the django-paypal tutorial
from paypal.standard.models import ST_PP_COMPLETED
from paypal.standard.ipn.signals import valid_ipn_received
def payment_paypal_ipn_signal_handler(sender, **kwargs):
ipn_obj = sender
if ipn_obj.payment_status == ST_PP_COMPLETED:
# WARNING !
# Check that the receiver email is the same we previously
# set on the business field request. (The user could tamper
# with those fields on payment form before send it to PayPal)
if ipn_obj.receiver_email != "[email protected]":
# Not a valid payment
return
# ALSO: for the same reason, you need to check the amount
# received etc. are all what you expect.
# Undertake some action depending upon `ipn_obj`.
if ipn_obj.custom == "Upgrade all users!":
Users.objects.update(paid=True)
# Here I should add the code that handles a successful payment
request.order.paid = True # How do I get my 'request' here?
else:
#...
valid_ipn_received.connect(show_me_the_money)
Но, я все еще нужен мой order
экземпляр для того, чтобы установить его как платные, например. Как я могу получить свои данные внутри этой функции, которая вызывается PayPal?