当前位置: 首页>>代码示例>>Python>>正文


Python PayPalIPN.set_flag方法代码示例

本文整理汇总了Python中paypal.standard.ipn.models.PayPalIPN.set_flag方法的典型用法代码示例。如果您正苦于以下问题:Python PayPalIPN.set_flag方法的具体用法?Python PayPalIPN.set_flag怎么用?Python PayPalIPN.set_flag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在paypal.standard.ipn.models.PayPalIPN的用法示例。


在下文中一共展示了PayPalIPN.set_flag方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ipn

# 需要导入模块: from paypal.standard.ipn.models import PayPalIPN [as 别名]
# 或者: from paypal.standard.ipn.models.PayPalIPN import set_flag [as 别名]
def ipn(request, item_check_callable=None):
    """
    PayPal IPN endpoint (notify_url).
    Used by both PayPal Payments Pro and Payments Standard to confirm transactions.
    http://tinyurl.com/d9vu9d
    
    PayPal IPN Simulator:
    https://developer.paypal.com/cgi-bin/devscr?cmd=_ipn-link-session
    
    """    
    
    logging.info(request)
    
    form = PayPalIPNForm(request.POST)
    
    logging.info(form)
    logging.info(form.is_valid())
    
    if form.is_valid():
        try:
            ipn_obj = form.save(commit=False)
            logging.info(ipn_obj)
        except Exception, e:
            logging.error(e)
            ipn_obj = PayPalIPN()
            ipn_obj.set_flag("Exception while processing. (%s)" % form.errors)
            logging.info(ipn_obj)
开发者ID:alexissmirnov,项目名称:donomo,代码行数:29,代码来源:views.py

示例2: create_ipn

# 需要导入模块: from paypal.standard.ipn.models import PayPalIPN [as 别名]
# 或者: from paypal.standard.ipn.models.PayPalIPN import set_flag [as 别名]
def create_ipn(request):
    flag = None
    ipnObj = None
    form = PayPalIPNForm(request.POST)
    if form.is_valid():
        try:
            ipnObj = form.save(commit=False)
        except Exception as e:
            flag = "Exception while processing. (%s)" % e
    else:
        flag = "Invalid form. (%s)" % form.errors
    if ipnObj is None:
        ipnObj = PayPalIPN()
    ipnObj.initialize(request)
    if flag is not None:
        ipnObj.set_flag(flag)
    else:
        # Secrets should only be used over SSL.
        if request.is_secure() and 'secret' in request.GET:
            ipnObj.verify_secret(form, request.GET['secret'])
        else:
            donation = get_ipn_donation(ipnObj)
            if not donation:
                raise Exception('No donation associated with this IPN')
            verify_ipn_recipient_email(ipnObj, donation.event.paypalemail)
            ipnObj.verify(None)
    ipnObj.save()
    return ipnObj
开发者ID:TipoftheHats,项目名称:donation-tracker,代码行数:30,代码来源:paypalutil.py

示例3: ipn

# 需要导入模块: from paypal.standard.ipn.models import PayPalIPN [as 别名]
# 或者: from paypal.standard.ipn.models.PayPalIPN import set_flag [as 别名]
def ipn(request, item_check_callable=None):
    """
    PayPal IPN endpoint (notify_url).
    Used by both PayPal Payments Pro and Payments Standard to confirm transactions.
    http://tinyurl.com/d9vu9d

    PayPal IPN Simulator:
    https://developer.paypal.com/cgi-bin/devscr?cmd=_ipn-link-session
    """
    #TODO: Clean up code so that we don't need to set None here and have a lot
    #      of if checks just to determine if flag is set.
    flag = None
    ipn_obj = None

    # Clean up the data as PayPal sends some weird values such as "N/A"
    data = request.POST.copy()
    date_fields = ('time_created', 'payment_date', 'next_payment_date',
                   'subscr_date', 'subscr_effective')
    for date_field in date_fields:
        if data.get(date_field) == 'N/A':
            del data[date_field]

    form = PayPalIPNForm(data)
    if form.is_valid():
        try:
            #When commit = False, object is returned without saving to DB.
            ipn_obj = form.save(commit = False)
        except Exception as e:
            flag = "Exception while processing. (%s)" % e
    else:
        flag = "Invalid form. (%s)" % form.errors

    if ipn_obj is None:
        ipn_obj = PayPalIPN()

    #Set query params and sender's IP address
    ipn_obj.initialize(request)

    if flag is not None:
        #We save errors in the flag field
        ipn_obj.set_flag(flag)
    else:
        # Secrets should only be used over SSL.
        if request.is_secure() and 'secret' in request.GET:
            ipn_obj.verify_secret(form, request.GET['secret'])
        else:
            ipn_obj.verify(item_check_callable)

    ipn_obj.save()
    return HttpResponse("OKAY")
开发者ID:atul-bhouraskar,项目名称:django-paypal,代码行数:52,代码来源:views.py

示例4: PayPalIPNForm

# 需要导入模块: from paypal.standard.ipn.models import PayPalIPN [as 别名]
# 或者: from paypal.standard.ipn.models.PayPalIPN import set_flag [as 别名]
            del data[date_field]

    form = PayPalIPNForm(data)
    if form.is_valid():
        try:
            # When commit = False, object is returned without saving to DB.
            ipn_obj = form.save(commit=False)
        except Exception, e:
            flag = "Exception while processing. (%s)" % e
    else:
        flag = "Invalid form. (%s)" % form.errors
 
    if ipn_obj is None:
        ipn_obj = PayPalIPN()
    
    # Set query params and sender's IP address
    ipn_obj.initialize(request)

    if flag is not None:
        # We save errors in the flag field
        ipn_obj.set_flag(flag)
    else:
        # Secrets should only be used over SSL.
        if request.is_secure() and 'secret' in request.GET:
            ipn_obj.verify_secret(form, request.GET['secret'])
        else:
            ipn_obj.verify(item_check_callable)

    ipn_obj.save()
    return HttpResponseRedirect("/")
开发者ID:fernandoguirao,项目名称:joinity_old,代码行数:32,代码来源:views.py

示例5: ipn

# 需要导入模块: from paypal.standard.ipn.models import PayPalIPN [as 别名]
# 或者: from paypal.standard.ipn.models.PayPalIPN import set_flag [as 别名]
def ipn(request, item_check_callable=None):
    """
    PayPal IPN endpoint (notify_url).
    Used by both PayPal Payments Pro and Payments Standard to confirm transactions.
    http://tinyurl.com/d9vu9d

    PayPal IPN Simulator:
    https://developer.paypal.com/cgi-bin/devscr?cmd=_ipn-link-session
    """
    # TODO: Clean up code so that we don't need to set None here and have a lot
    #       of if checks just to determine if flag is set.
    flag = None
    ipn_obj = None

    # Clean up the data as PayPal sends some weird values such as "N/A"
    # Also, need to cope with custom encoding, which is stored in the body (!).
    # Assuming the tolerant parsing of QueryDict and an ASCII-like encoding,
    # such as windows-1252, latin1 or UTF8, the following will work:
    encoding = request.POST.get('charset', None)

    encoding_missing = encoding is None
    if encoding_missing:
        encoding = DEFAULT_ENCODING

    try:
        data = QueryDict(request.body, encoding=encoding).copy()
    except LookupError:
        data = None
        flag = "Invalid form - invalid charset"

    if data is not None:
        if hasattr(PayPalIPN._meta, 'get_fields'):
            date_fields = [f.attname for f in PayPalIPN._meta.get_fields() if f.__class__.__name__ == 'DateTimeField']
        else:
            date_fields = [f.attname for f, m in PayPalIPN._meta.get_fields_with_model()
                           if f.__class__.__name__ == 'DateTimeField']

        for date_field in date_fields:
            if data.get(date_field) == 'N/A':
                del data[date_field]

        form = PayPalIPNForm(data)
        if form.is_valid():
            try:
                # When commit = False, object is returned without saving to DB.
                ipn_obj = form.save(commit=False)
            except Exception as e:
                flag = "Exception while processing. (%s)" % e
        else:
            formatted_form_errors = ["{0}: {1}".format(k, ", ".join(v)) for k, v in form.errors.items()]
            flag = "Invalid form. ({0})".format(", ".join(formatted_form_errors))

    if ipn_obj is None:
        ipn_obj = PayPalIPN()

    # Set query params and sender's IP address
    ipn_obj.initialize(request)

    if flag is not None:
        # We save errors in the flag field
        ipn_obj.set_flag(flag)
    else:
        # Secrets should only be used over SSL.
        if request.is_secure() and 'secret' in request.GET:
            ipn_obj.verify_secret(form, request.GET['secret'])
        else:
            ipn_obj.verify(item_check_callable)

    ipn_obj.save()
    ipn_obj.send_signals()

    if encoding_missing:
        # Wait until we have an ID to log warning
        log.warning("No charset passed with PayPalIPN: %s. Guessing %s", ipn_obj.id, encoding)

    return HttpResponse("OKAY")
开发者ID:Lokorus,项目名称:Ruslan_Tsimbalyuk_clothers_store,代码行数:78,代码来源:views.py

示例6: ipn

# 需要导入模块: from paypal.standard.ipn.models import PayPalIPN [as 别名]
# 或者: from paypal.standard.ipn.models.PayPalIPN import set_flag [as 别名]
def ipn(request, item_check_callable=None):
    """
    PayPal IPN endpoint (notify_url).
    Used by both PayPal Payments Pro and Payments Standard to confirm transactions.
    http://tinyurl.com/d9vu9d
    
    PayPal IPN Simulator:
    https://developer.paypal.com/cgi-bin/devscr?cmd=_ipn-link-session
    """
    #TODO: Clean up code so that we don't need to set None here and have a lot
    #      of if checks just to determine if flag is set.
    flag = None
    ipn_obj = None

    # Clean up the data as PayPal sends some weird values such as "N/A"
    # Also, need to cope with custom encoding, which is stored in the body (!).
    # Assuming the tolerate parsing of QueryDict and an ASCII-like encoding,
    # such as windows-1252, latin1 or UTF8, the following will work:

    encoding = request.POST.get('charset', None)

    if encoding is None:
        flag = "Invalid form - no charset passed, can't decode"
        data = None
    else:
        try:
            data = QueryDict(request.body, encoding=encoding).copy()
        except LookupError:
            data = None
            flag = "Invalid form - invalid charset"

    if data is not None:
        date_fields = ('time_created', 'payment_date', 'next_payment_date',
                       'subscr_date', 'subscr_effective')
        for date_field in date_fields:
            if data.get(date_field) == 'N/A':
                del data[date_field]

        form = PayPalIPNForm(data)
        if form.is_valid():
            try:
                #When commit = False, object is returned without saving to DB.
                ipn_obj = form.save(commit=False)
            except Exception as e:
                flag = "Exception while processing. (%s)" % e
        else:
            flag = "Invalid form. (%s)" % form.errors

    if ipn_obj is None:
        ipn_obj = PayPalIPN()

    #Set query params and sender's IP address
    ipn_obj.initialize(request)

    if flag is not None:
        #We save errors in the flag field
        ipn_obj.set_flag(flag)
    else:
        # Secrets should only be used over SSL.
        if request.is_secure() and 'secret' in request.GET:
            ipn_obj.verify_secret(form, request.GET['secret'])
        else:
            ipn_obj.verify(item_check_callable)

    ipn_obj.save()
    return HttpResponse("OKAY")
开发者ID:LoveToBeHated,项目名称:django-paypal,代码行数:68,代码来源:views.py

示例7: create_ipn

# 需要导入模块: from paypal.standard.ipn.models import PayPalIPN [as 别名]
# 或者: from paypal.standard.ipn.models.PayPalIPN import set_flag [as 别名]
def create_ipn(request):
  flag = None
  ipnObj = None
  form = PayPalIPNForm(request.POST)
  if form.is_valid():
    try:
      ipnObj = form.save(commit=False)
    except Exception, e:
      flag = "Exception while processing. (%s)" % e
  else:
    flag = "Invalid form. (%s)" % form.errors
  if ipnObj is None:
    ipnObj = PayPalIPN()
  ipnObj.initialize(request)
  if flag is not None:
    ipnObj.set_flag(flag)
  else:
    # Secrets should only be used over SSL.
    if request.is_secure() and 'secret' in request.GET:
      ipnObj.verify_secret(form, request.GET['secret'])
    else:
      donation = get_ipn_donation(ipnObj)
      ipnObj.verify(None, donation.event.paypalemail)
  ipnObj.save()
  return ipnObj

def get_ipn(request):
  ipnObj = PayPalIPN()
  ipnObj.initialize(request)
  return ipnObj
开发者ID:GamesDoneQuick,项目名称:donation-tracker,代码行数:32,代码来源:paypalutil.py

示例8: ipn

# 需要导入模块: from paypal.standard.ipn.models import PayPalIPN [as 别名]
# 或者: from paypal.standard.ipn.models.PayPalIPN import set_flag [as 别名]

#.........这里部分代码省略.........
    u'custom': [u''],
    u'notify_version': [u'3.8'],
    u'address_name': [u'XXXXXXXXX'], 
    u'test_ipn': [u'1'],
    u'item_number': [u''], 
    u'receiver_id': [u'7EEGW6KXU7H3G'],
    u'transaction_subject': [u''], 
    u'business': [u'[email protected]'], 
    u'payer_id': [u'YQG53MRMSMVT8'],
    u'verify_sign': [u'AMIsJErLWFh1ByQ-Pn.oseCWp0SBAOA1.0fCwFL.qfIIq6GQoS36n5i8'],
    u'address_zip': [u'95131'], 
    u'payment_fee': [u'3.20'], 
    u'address_country_code': [u'US'],
    u'address_city': [u'San Jose'],
    u'address_status': [u'confirmed'], 
    u'mc_fee': [u'3.20'],
    u'mc_currency': [u'USD'],
    u'shipping': [u'0.00'], 
    u'payer_email': [u'[email protected]'],
    u'payment_type': [u'instant'],
    u'mc_gross': [u'100.00'], 
    u'ipn_track_id': [u'59b0e84327236'],
    u'quantity': [u'1']
    }

    """
    
    """
    PayPal IPN endpoint (notify_url).
    Used by both PayPal Payments Pro and Payments Standard to confirm transactions.
    http://tinyurl.com/d9vu9d
    
    PayPal IPN Simulator:
    https://developer.paypal.com/cgi-bin/devscr?cmd=_ipn-link-session
    """
    #TODO: Clean up code so that we don't need to set None here and have a lot
    #      of if checks just to determine if flag is set.
    flag = None
    ipn_obj = None

    # Clean up the data as PayPal sends some weird values such as "N/A"
    # Also, need to cope with custom encoding, which is stored in the body (!).
    # Assuming the tolerate parsing of QueryDict and an ASCII-like encoding,
    # such as windows-1252, latin1 or UTF8, the following will work:

    encoding = request.POST.get('charset', None)

    if encoding is None:
        flag = "Invalid form - no charset passed, can't decode"
        data = None
    else:
        try:
            data = QueryDict(request.body, encoding=encoding).copy()
        except LookupError:
            data = None
            flag = "Invalid form - invalid charset"

    if data is not None:
        date_fields = ('time_created', 'payment_date', 'next_payment_date',
                       'subscr_date', 'subscr_effective')
        for date_field in date_fields:
            if data.get(date_field) == 'N/A':
                del data[date_field]

        form = PayPalIPNForm(data)
        if form.is_valid():
            try:
                #When commit = False, object is returned without saving to DB.
                ipn_obj = form.save(commit=False)
            except Exception as e:
                flag = "Exception while processing. (%s)" % e
        else:
            flag = "Invalid form. (%s)" % form.errors

    if ipn_obj is None:
        ipn_obj = PayPalIPN()

    #Set query params and sender's IP address
    ipn_obj.initialize(request)

    if flag is not None:
        #We save errors in the flag field
        ipn_obj.set_flag(flag)
    else:
        # Secrets should only be used over SSL.
        if request.is_secure() and 'secret' in request.GET:
            ipn_obj.verify_secret(form, request.GET['secret'])
        else:
            ipn_obj.verify(item_check_callable)

    ipn_obj.save()
    
          
    # Send Notification mail to logged in user
    try:
        send_payment_success_mail(request, ipn_obj=ipn_obj)
    except Exception as e:
        print str(e)
        
    return HttpResponse("OKAY")
开发者ID:jswope00,项目名称:pp_cart,代码行数:104,代码来源:views.py

示例9: ipn

# 需要导入模块: from paypal.standard.ipn.models import PayPalIPN [as 别名]
# 或者: from paypal.standard.ipn.models.PayPalIPN import set_flag [as 别名]
def ipn(request, item_check_callable=None, host_id=None, trans_id=None):
    """
    PayPal IPN endpoint (notify_url).
    Used by both PayPal Payments Pro and Payments Standard to confirm transactions.
    http://tinyurl.com/d9vu9d
    
    PayPal IPN Simulator:
    https://developer.paypal.com/cgi-bin/devscr?cmd=_ipn-link-session
    
    #what triggers this view?
    """
    #TODO: Clean up code so that we don't need to set None here and have a lot
    #      of if checks just to determine if flag is set.
    flag = None
    ipn_obj = None
    
    # Clean up the data as PayPal sends some weird values such as "N/A"
    # Also, need to cope with custom encoding, which is stored in the body (!).
    # Assuming the tolerant parsing of QueryDict and an ASCII-like encoding,
    # such as windows-1252, latin1 or UTF8, the following will work:

    encoding = request.POST.get('charset', None)

    if encoding is None:
        flag = "Invalid form - no charset passed, can't decode"
        data = None
    else:
        try:
            data = QueryDict(request.body, encoding=encoding).copy()
        except LookupError:
            data = None
            flag = "Invalid form - invalid charset"

    if data is not None:
        date_fields = ('time_created', 'payment_date', 'next_payment_date',
                       'subscr_date', 'subscr_effective')
        for date_field in date_fields:
            if data.get(date_field) == 'N/A':
                del data[date_field]

        form = PayPalIPNForm(data) #from paypal.standard.ipn.forms import PayPalIPNForm
        if form.is_valid():
            try:
                #When commit = False, object is returned without saving to DB.
                ipn_obj = form.save(commit=False)
            except Exception as e:
                flag = "Exception while processing. (%s)" % e
        else:
            flag = "Invalid form. (%s)" % form.errors
		    
    if ipn_obj is None:
        ipn_obj = PayPalIPN() #from paypal.standard.ipn.models import PayPalIPN
        
    #Set query params and sender's IP address
    ipn_obj.initialize(request)
    
    #Store the invoice value so i can use it to update the transactions model
    invoice_sent = ipn_obj.invoice
    
    #Add other host characteristicsto the model
    #Eventually add transaction_id to the ipn_obj model
    if host_id:
        host = get_object_or_404(UserInfo, pk=host_id)
        ipn_obj.host_email = host.email
        ipn_obj.host_fname = host.first_name
        ipn_obj.host_lname = host.last_name
        ipn_obj.host_st_address1 = host.st_address1
        ipn_obj.host_st_address2 = host.st_address2
    if trans_id:
        trans = Transaction.objects.get(pk=trans_id) 
        ipn_obj.trans_table_id = trans.id	
    #the following set_flag is defined in paypal.standard.modle.spy, flat var is passed as the "info" parameter
    if flag is not None:
        #We save errors in the flag field
        ipn_obj.set_flag(flag)
    else:
        # Secrets should only be used over SSL.
        if request.is_secure() and 'secret' in request.GET:
            ipn_obj.verify_secret(form, request.GET['secret'])
        else:
            ipn_obj.verify(item_check_callable)

    ipn_obj.save()
    ipn_obj.send_signals()
    
    #JMY ADDED: Update the Transaction Table to confirm we need to transation ID but only have invoice on the paypal IPN
    if trans_id:
        trans.payment_processed = True
        trans_table_id = trans.id
        trans.payment_method = "Paypal"
        trans.save()
        #update the userinfo table to add an account balance
        new_balance = trans.balance_created_packages
        userinfo = UserInfo.objects.get(pk=trans.enduser.id)
        if new_balance:
    		    userinfo.account_balance_packages = new_balance
    		    userinfo.save()
        #send emails
        notify_host_shipment_paid(request,trans_table_id)
        notify_enduser_shipment_paid(request, trans_table_id) 
#.........这里部分代码省略.........
开发者ID:JessAtBlocBoxCo,项目名称:blocbox,代码行数:103,代码来源:views.py


注:本文中的paypal.standard.ipn.models.PayPalIPN.set_flag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。