0

두 개의 타사 앱 (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')), 
+0

당신은 내가 쓴 기사에 관심이있을 수 있습니다 [페이팔 IPN을 테스트하는 방법 (https://www.angelleye.com/test-paypal-ipn/). 당신이 그 단계를 수행하면 나는 당신이 당신의 문제를 발견 할 것이라고 확신합니다. –

답변

0

당신이 테스트 포트를 사용하고 있기 때문에 그것은 8000을 같은 (수) 표준 포트가 아닌 80입니다.

포트 80으로 전환하면 IPN 알림을 수신하고, 신호를 트리거하고, 신호를 적절하게 처리 할 수있었습니다.

이 질문은 그 길을 저를 아래로 주도 : How do I allow django-merchant to receive paypal IPN conformations?

+0

나는 이것을 할 수 있었고 ngrok와 IPN 테스터를 사용하여 IPN을 보내고 ngrok에서 200 코드를 얻을 수 있었지만 내 장고 개발 서버 콘솔에서 '200 502'를 보았습니다. –

+0

나는 이것이 당신을 의미한다고 믿습니다. django 개발 서버가 HTTP 패킷의 수신을 확인하고 있습니다 [코드 200 OK 참조] (http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html). app.ready() 메소드에서 django-paypal의 IPN 신호에 대한 수신기를 등록 했습니까? 그렇지 않다면, IPN은 django에 알릴 것이지만, 애플리케이션은 데이터를 가지고 아무 것도하지 않을 것입니다. – w8s