두 개의 타사 앱 (Django-paypal 및 django-registration)을 사용하려고합니다. 지불이 완료되면 PayPal은 제공된 URL로 IPN 신호를 전송합니다. 이 신호를 통해 장고 등록 사용자를 인증하고 싶습니다.사용자 등록을위한 PayPal IPN 신호
결제가 완료되면 IPN이 paypal 샌드 박스에서 보내지지 않고있는 것으로 보입니다. 그러나 신호 코드가 설정된 방식에 문제가 있다고 생각하지 않습니다.
signals.py는
import signals
으로 초기화 평에 가져 그리고 페이팔 샌드 박스 내 로컬 호스트에 액세스 할 수 있도록 ngrok 사용하고 있습니다.
views.py :
def payment(request):
"""
This is the view for the page a new user is redirected
to after registering (not activating) a new account.
"""
paypal_dict = {
"cmd": "_xclick-subscriptions",
"business": settings.PAYPAL_RECEIVER_EMAIL,
"a3": "7.99",
"p3": "1",
"t3": "M",
"src": "1",
"sra": "1",
"no_note": "1",
"item_name": "My Item",
"notify_url": "http://localhost:8000/accounts/register/account_activated/",
"return_url": "http://localhost:8000/",
"cancel_return": "http//www.example.com/cancel-location/",
}
form = PayPalPaymentsForm(initial=paypal_dict, button_type="subscribe")
context = {"form": form}
return render_to_response("registration/registration_complete.html", context)
signlas.py :
from paypal.standard.models import ST_PP_COMPLETED
from paypal.standard.ipn.signals import valid_ipn_received, payment_was_flagged
from registration.models import RegistrationProfile
from registration.views import ActivationView
def payment_signal(sender, **kwargs):
ipn_object = sender
if ipn_object.payment_status == ST_PP_COMPLETED:
print "payment_status == ST_PP_COMPLETED"
"""
Here use django-registration to authenticate
the User
"""
activate_user(activation_key)
activation_key = ACTIVATED
#ActivationView.activate()
else:
print str(ipn_object.payment_status)
print "error"
valid_ipn_received.connect(payment_signal)
payment_was_flagged.connect(payment_signal)
print "SIGNALS MODULE IMPORTED"
urls.py :
url(r'^accounts/register/account_activated/$', include('paypal.standard.ipn.urls')),
당신은 내가 쓴 기사에 관심이있을 수 있습니다 [페이팔 IPN을 테스트하는 방법 (https://www.angelleye.com/test-paypal-ipn/). 당신이 그 단계를 수행하면 나는 당신이 당신의 문제를 발견 할 것이라고 확신합니다. –