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


Python GlobalUtilities.getAccountEmails方法代码示例

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


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

示例1: update

# 需要导入模块: import GlobalUtilities [as 别名]
# 或者: from GlobalUtilities import getAccountEmails [as 别名]
    def update(self, name, email, mc_use, mc_apikey, mc_donorlist, paypal_id, impressions, donate_parent, amount1,
               amount2, amount3, amount4, use_custom, confirmation_header, confirmation_info, confirmation_footer,
               confirmation_text, donor_report_text):
        s = self

        if name != s.name:
            s.name = name

        if email != s.email:
            s.email = email

            if email in tools.getAccountEmails():
                raise Exception("Cannot have the same email as another organization.")

        if mc_use != s.mc_use:
            s.mc_use = mc_use

        if mc_apikey != s.mc_apikey:
            s.mc_apikey = mc_apikey

        if mc_donorlist != s.mc_donorlist:
            s.mc_donorlist = mc_donorlist

        if paypal_id != s.paypal_id:
            s.paypal_id = paypal_id

        if impressions != s.impressions:
            s.impressions = impressions

        if donate_parent != s.donate_parent:
            s.donate_parent = donate_parent

        if int(amount1) != s.amount1:
            s.amount1 = int(amount1)

        if int(amount2) != s.amount2:
            s.amount2 = int(amount2)

        if int(amount3) != s.amount3:
            s.amount3 = int(amount3)

        if int(amount4) != s.amount4:
            s.amount4 = int(amount4)

        if use_custom != s.use_custom:
            s.use_custom = use_custom

        if confirmation_header != s.confirmation_header:
            s.confirmation_header = confirmation_header

        if confirmation_info != s.confirmation_info:
            s.confirmation_info = confirmation_info

        if confirmation_footer != s.confirmation_footer:
            s.confirmation_footer = confirmation_footer

        if confirmation_text != s.confirmation_text:
            s.confirmation_text = confirmation_text

        if donor_report_text != s.donor_report_text:
            s.donor_report_text = donor_report_text

        s.put()
开发者ID:rhefner1,项目名称:ghidonations,代码行数:65,代码来源:DataModels.py

示例2: post

# 需要导入模块: import GlobalUtilities [as 别名]
# 或者: from GlobalUtilities import getAccountEmails [as 别名]
    def post(self):
        # Below URL used for the live version.
        PP_URL = "https://www.paypal.com/cgi-bin/webscr"

        # Below URL used for testing with the sandbox - if this is uncommented, all real
        # donations will not be authenticated. ONLY use with dev versions.
        # PP_URL = "https://www.sandbox.paypal.com/cgi-bin/webscr"

        # Gets all account emails from Settings data models
        # to authenticate PayPal (don't accept payment from unknown)
        all_account_emails = tools.getAccountEmails()

        parameters = None
        if self.request.POST:
            parameters = self.request.POST.copy()
        if self.request.GET:
            parameters = self.request.GET.copy()

        payment_status = self.request.get("payment_status")
        logging.info("Payment status: " + payment_status)

        # Check payment is completed, not Pending or Failed.
        if payment_status == "Failed" or payment_status == "Pending":
            logging.error("Payment status is " + payment_status + ", so not continuing.")

        else:
            logging.info("All parameters: " + str(parameters))

            # Check the IPN POST request came from real PayPal, not from a fraudster.
            if parameters:
                parameters['cmd'] = '_notify-validate'

                # Encode the parameters in UTF-8 out of Unicode
                str_parameters = {}
                for k, v in parameters.iteritems():
                    str_parameters[k] = unicode(v).encode('utf-8')

                params = urllib.urlencode(str_parameters)
                status = urlfetch.fetch(
                    url=PP_URL,
                    method=urlfetch.POST,
                    payload=params,
                ).content
                if not status == "VERIFIED":
                    logging.debug("PayPal returned status:" + str(status))
                    logging.debug('Error. The request could not be verified, check for fraud.')
                    parameters['homemadeParameterValidity'] = False

            # Comparing receiver email to list of allowed email addresses
            try:
                receiver_email = parameters['receiver_email']
                authenticated = False
                settings = None

                # If the receiver_email isn't in the database, this will fail
                settings = all_account_emails[receiver_email]
                authenticated = True
                logging.info("Getting payment to account: " + receiver_email + ", #: " + settings)

            except:
                authenticated = False
                logging.info("No match for incoming payment email address. Not continuing.")

            # Make sure money is going to the correct account - otherwise fraudulent
            if authenticated == True:
                # Currency of the donation
                # currency = parameters['mc_currency']

                s = tools.getKey(settings).get()
                ipn_data = str(parameters)

                # Email and payer ID  numbers
                try:
                    email = parameters['payer_email']
                except:
                    email = None

                try:
                    name = parameters['first_name'] + " " + parameters['last_name']
                except:
                    name = "Anonymous Donor"

                # Check if an address was given by the donor
                try:
                    # Stich all the address stuff together
                    address = [parameters['address_street'], parameters['address_city'], parameters['address_state'],
                               parameters['address_zip']]

                except:
                    address = None

                # Reading designation and notes values encoded in JSON from
                # donate form
                decoded_custom = None

                try:
                    decoded_custom = json.loads(parameters["custom"])

                    team_key = tools.getKeyIfExists(decoded_custom[0])
                    individual_key = tools.getKeyIfExists(decoded_custom[1])
#.........这里部分代码省略.........
开发者ID:rhefner1,项目名称:ghidonations,代码行数:103,代码来源:mooha.py


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