Exemple #1
0
def paypal_ipn(request, *args, **kwargs):
    
    try:
        #validate that this ipn was initiated from the site
        if request.POST.get('receiver_email') != settings.PAYPAL_RECEIVER_EMAIL:
            log.error('Received maliscious IPN.  Possible thread!  IPN DATA = %s' % request.POST)

        data = request.POST.copy()

        username = request.POST.get('custom')
        user = User.objects.get(username=username)
        profile = user.get_profile()
        
        #make sure the user is verified
        if data.get('payer_status') != 'verified':
            log.error('user %s is not active in paypal' % username)
            return HttpResponse('error')

        if data.get('txn_type') == 'subscr_signup':
            log.warn('received singup IPN with data %s' % (data))
            utils.create_subscription(user, data, profile.ipaddress)
        elif data.get('txn_type') == 'subscr_payment':
            log.warn('received subscr_payment IPN with data %s' % (data))
            utils.activate_subscription(user, data, profile.ipaddress)
            #now email the user that their subscription is active
            from mailer import send_email as send_mail
            send_mail(template='subscription_active', subject="Your Subscription is activated", to_email=[user.email])

    except Exception, e:
        log.error("Error occured in IPN %s" % e.message)
        return HttpResponse('error')
Exemple #2
0
def paypal_ipn(request, *args, **kwargs):

    try:
        #validate that this ipn was initiated from the site
        if request.POST.get(
                'receiver_email') != settings.PAYPAL_RECEIVER_EMAIL:
            log.error(
                'Received maliscious IPN.  Possible thread!  IPN DATA = %s' %
                request.POST)

        data = request.POST.copy()

        username = request.POST.get('custom')
        user = User.objects.get(username=username)
        profile = user.get_profile()

        #make sure the user is verified
        if data.get('payer_status') != 'verified':
            log.error('user %s is not active in paypal' % username)
            return HttpResponse('error')

        if data.get('txn_type') == 'subscr_signup':
            log.warn('received singup IPN with data %s' % (data))
            utils.create_subscription(user, data, profile.ipaddress)
        elif data.get('txn_type') == 'subscr_payment':
            log.warn('received subscr_payment IPN with data %s' % (data))
            utils.activate_subscription(user, data, profile.ipaddress)
            #now email the user that their subscription is active
            from mailer import send_email as send_mail
            send_mail(template='subscription_active',
                      subject="Your Subscription is activated",
                      to_email=[user.email])

    except Exception, e:
        log.error("Error occured in IPN %s" % e.message)
        return HttpResponse('error')
Exemple #3
0
def subscription_activate(request, course_id, activation_key):

    if activate_subscription(activation_key):
        return redirect('/main/profile/' % course_id)