Пример #1
0
 def post(self):
     pEmail = self.request.get('email')
     pCustomerId = self.request.get('custid')
     pMarkVerified = self.request.get('verified')
     
     #logging.debug(str(pEmail))
     #logging.debug(str(pCustomerId))
     #logging.debug(str(pMarkVerified))
     
     tCustomer = Customer()
     tCustomer = Customer.get(pCustomerId)
     
     if(pMarkVerified != None and pMarkVerified == 'True'):
         tCustomer.customerIdVerified = True
         tCustomer.put()
             
         self.response.headers['Cache-Control'] = 'Cache-Control: no-cache, must-revalidate'
         self.response.headers['Content-Type'] = 'Content-Type: plain/text'
         self.response.out.write("Verified")
Пример #2
0
    def post(self):
        pEmail = self.request.get('email')
        pCustomerId = self.request.get('custid')
        pMarkVerified = self.request.get('verified')

        #logging.debug(str(pEmail))
        #logging.debug(str(pCustomerId))
        #logging.debug(str(pMarkVerified))

        tCustomer = Customer()
        tCustomer = Customer.get(pCustomerId)

        if (pMarkVerified != None and pMarkVerified == 'True'):
            tCustomer.customerIdVerified = True
            tCustomer.put()

            self.response.headers[
                'Cache-Control'] = 'Cache-Control: no-cache, must-revalidate'
            self.response.headers['Content-Type'] = 'Content-Type: plain/text'
            self.response.out.write("Verified")
Пример #3
0
    def PostContext(self):
        tCustomerKey = ""
        tCustomer = Customer()
        tCustomerLookup = CustomerHandler()

        tAction = str(self.request.get('action')).lower()
        tCustomerKey = str(self.request.get('key'))
        tItem = str(self.request.get('item')).lower()

        if (tAction != None and len(tAction) > 0 and tAction == "search"):
            tSearchEmail = str(urllib.unquote(
                self.request.get('email'))).lower()
            tSearchPpid = str(urllib.unquote(self.request.get('ppid')))
            if (tSearchEmail != None and len(tSearchEmail) > 0):
                tCustomerList = tCustomerLookup.GetCustomerByEmail(
                    tSearchEmail)
            elif (tSearchPpid != None and len(tSearchPpid) > 0):
                tCustomerList = tCustomerLookup.GetCustomerByPpid(tSearchPpid)
            tCustomer = tCustomerList[0]
        elif (tCustomerKey != None and len(tCustomerKey) > 0):
            tCustomer = Customer().get(tCustomerKey)
            if (tAction == 'phone'):
                tCustomer.customerPhone = tItem
                #logging.debug("Number saving success: " + tItem)
            if (tAction == 'idverified'):
                tCustomer.customerIdVerified = True
                #logging.debug("Customer Id Verified")
            if (tAction == 'idverify'):
                tCustomer.customerIdLink = tItem
                #logging.debug("Customer Id: " + tItem)
            if (tAction == 'memo'):
                tCustomer.customerMemo = tItem
                #logging.debug("Customer Memo: " + tItem)
            tCustomer.put()
        if (tCustomer):
            tCustomerKey = str(tCustomer.key())

        self.LOCATION = '/customerlookup?key=' + str(tCustomerKey)
        self.REDIRECT = True
        return {}  #need to return something for processing
 def PostContext(self):
     tCustomerKey = ""
     tCustomer = Customer()
     tCustomerLookup = CustomerHandler()
     
     tAction = str(self.request.get('action')).lower()
     tCustomerKey = str(self.request.get('key'))
     tItem = str(self.request.get('item')).lower()
     
     if (tAction != None and len(tAction) > 0 and tAction == "search"):
         tSearchEmail = str(urllib.unquote(self.request.get('email'))).lower()
         tSearchPpid = str(urllib.unquote(self.request.get('ppid')))
         if (tSearchEmail != None and len(tSearchEmail) > 0):
             tCustomerList = tCustomerLookup.GetCustomerByEmail(tSearchEmail)
         elif (tSearchPpid != None and len(tSearchPpid) > 0):
             tCustomerList = tCustomerLookup.GetCustomerByPpid(tSearchPpid)
         tCustomer = tCustomerList[0]
     elif (tCustomerKey != None and len(tCustomerKey) > 0):
         tCustomer = Customer().get(tCustomerKey)
         if (tAction == 'phone'):
             tCustomer.customerPhone = tItem
             #logging.debug("Number saving success: " + tItem)
         if (tAction == 'idverified'):
             tCustomer.customerIdVerified = True
             #logging.debug("Customer Id Verified")
         if (tAction == 'idverify'):
             tCustomer.customerIdLink = tItem
             #logging.debug("Customer Id: " + tItem)
         if (tAction == 'memo'):
             tCustomer.customerMemo = tItem
             #logging.debug("Customer Memo: " + tItem)
         tCustomer.put()
     if(tCustomer):
         tCustomerKey = str(tCustomer.key())
     
     self.LOCATION = '/customerlookup?key=' + str(tCustomerKey)
     self.REDIRECT = True
     return {} #need to return something for processing
Пример #5
0
    def ProcessOrder(self, pArgumentDic):
        tOrderHandler = OrderHandler()
        tCustomerHandler = CustomerHandler()
        tCustomer = Customer()
        tPaypalOrder = PaypalOrder()
        tArgumentDic = pArgumentDic

        #Assign Values from POST from Paypal IPN
        tTransactionId = tArgumentDic['txn_id']
        tAlphaMatch = re.compile('[^A-Za-z0-9]+')
        tAlphaSpaceMatch = re.compile('[^A-Za-z0-9 ]+')

        #Short circuits the order process for special PA page
        if ('payer_email' in tArgumentDic.keys()):
            if (tArgumentDic['payer_email'] == '*****@*****.**'):
                tPaypalOrder.ProcessPlayerAuctions(tArgumentDic)
                return

        try:
            tGoldAmount = tArgumentDic['option_name7']
        except:
            tGoldAmount = ""

        try:
            tCustomerFirstName = tAlphaSpaceMatch.sub(
                '', tArgumentDic['first_name'])
        except:
            tCustomerFirstName = ""

        try:
            tCustomerLastName = tAlphaSpaceMatch.sub('',
                                                     tArgumentDic['last_name'])
        except:
            tCustomerLastName = ""

        try:
            tCustomerName = tAlphaSpaceMatch.sub('',
                                                 tArgumentDic['option_name1'])
        except:
            tCustomerName = ""

        try:
            tEmail = tArgumentDic['option_name2']
        except:
            tEmail = ""
        tPaypalEmail = str(tArgumentDic['payer_email']).lower()
        try:
            tMobilePhone = tArgumentDic['option_name3']
            tMobilePhone = re.sub(r'\D', '', tMobilePhone)
        except:
            tMobilePhone = ""
        try:
            tRsName = tArgumentDic['option_name4'].strip().lower()
            tRsName = tRsName.replace(' ', '_')
            tRsName = tRsName.replace('-', '_')
        except:
            tRsName = ""
        try:
            tCombatLevel = ""
        except:
            tCombatLevel = ""

        #try:
        #tReferCode = str(tArgumentDic['option_name5']).strip()
        #except:
        tReferCode = ""

        try:
            tPromotionCode = str(tArgumentDic['option_name5']).strip()
        except:
            tPromotionCode = ""

        tOrderIp = tArgumentDic['custom']
        tMembers = ""

        try:
            tOrderQuery = Order.all().filter('orderTransactionId',
                                             tTransactionId)
            tOrder = tOrderQuery.fetch(1)[0]
        except:
            tOrder = Order()

        if ('fake' in tArgumentDic.keys()):
            #logging.debug('Fake key hit')
            #logging.debug(str(tArgumentDic['fake']))
            if (tArgumentDic['fake'] == 'True'):
                tOrder.orderIsGenerated = True

        tOrder.orderFormName = tCustomerName
        tOrder.orderCombatLevel = tCombatLevel

        if (len(tGoldAmount) == 0):
            tUrl = "https://api-3t.paypal.com/nvp"
            #tOperation = "AddressVerify"
            tOperation = "GetTransactionDetails"
            #Get Paypal Information
            #tPaypal = PaypalTrigger()
            tResultDictionary = {}
            tPaypalPayload = {}
            tPayload = {}
            tPaypalPayload['METHOD'] = tOperation
            tPaypalPayload['TRANSACTIONID'] = tTransactionId

            tPayloadEncoded = tOrderHandler.GeneratePayload(tPaypalPayload)
            request_cookies = mechanize.CookieJar()
            request_opener = mechanize.build_opener(
                mechanize.HTTPCookieProcessor(request_cookies))
            request_opener.addheaders = [('Content-Type',
                                          'application/x-www-form-urlencoded')]
            mechanize.install_opener(request_opener)
            tResponse = mechanize.urlopen(url=tUrl,
                                          timeout=25.0,
                                          data=tPayloadEncoded)
            tResult = str(urllib.unquote(tResponse.read()))
            tResultSplit = tResult.split('&')

            for tPair in tResultSplit:
                tSplitPair = tPair.split("=")
                if (len(tSplitPair) == 1):
                    tSplitPair.append("")
                tResultDictionary[tSplitPair[0]] = tSplitPair[1]
                logging.debug(tSplitPair[0] + "    " + tSplitPair[1])
            tGoldAmountString = tResultDictionary['L_NAME0']
            logging.debug("Gold amount string %s".format(tGoldAmountString))
            try:
                tGoldRegex = re.compile("([0-9]*?[m|M]).T")
                tGoldMatch = tGoldRegex.findall(tGoldAmountString)
                #logging.debug("Backup gold amount parser hit, string " + tGoldAmountString + "   Match: " + tGoldMatch[0])
                tGoldAmount = tGoldMatch[0]
            except:
                tGoldRegex = re.compile("([0-9]*?[m|M]).T")
                tGoldMatch = tGoldRegex.findall(tGoldAmountString)
                try:
                    #logging.debug("Backup gold amount parser hit, string " + tGoldAmountString + "   Match: " + tGoldMatch[0])
                    tGoldAmount = tGoldMatch[0]
                except:
                    #logging.debug("No gold match")
                    tGoldAmount = ""

        tOrder.orderQuantity = NumberToGp.ConvertBetToInt(tGoldAmount)
        tOrder.orderSimpleGoldAmount = tGoldAmount
        tOrder.orderFormEmail = tEmail
        tOrder.orderAccountName = tRsName
        tOrder.orderMobileNumber = tMobilePhone
        tOrder.orderPromotionalCode = tPromotionCode.lower()
        tOrder.orderIp = tOrderIp
        if (tMembers == "yes"):
            tOrder.orderCustomerIsMember = True
        else:
            tOrder.orderCustomerIsMember = False

        #Paypal Info
        tOrder.orderTransactionId = tTransactionId

        tOrder.orderPaypalFirstName = tCustomerFirstName
        tOrder.orderPaypalLastName = tCustomerLastName

        tOrder.orderCost = float(tArgumentDic['payment_gross'])
        tOrder.orderCustomerPaypalId = tArgumentDic['payer_id']
        tOrder.orderPaypalEmail = str(tPaypalEmail).lower()

        tAssignedAgentNick = tPaypalOrder.GetAssignedAgent(tOrder)
        tOrder.orderAssignedAgent = tAssignedAgentNick
        #logging.debug("Order assigned to agent: " + str(tAssignedAgentNick))

        tOrder.orderReferralCode = tReferCode

        tOrder.orderDeliver = 'False'

        if (tOrder.orderVerificationCode == None
                or tOrder.orderVerificationCode == ''):
            tOrder.orderVerificationCode = re.sub(r'\W', '',
                                                  str(uuid.uuid4())).lower()

        tCurrentEocPrices = PriceContainer.GetCurrentPriceDic()
        tCurrent07Prices = PriceContainer.GetCurrentPriceDic07()

        tSkip07 = False
        if tOrder.orderSimpleGoldAmount in tCurrentEocPrices.keys():
            if str(tOrder.orderCost) == str(
                    tCurrentEocPrices[tOrder.orderSimpleGoldAmount]):
                tOrder.orderGoldType = 'eoc'
                tSkip07 = True

        if not tSkip07:
            if tOrder.orderSimpleGoldAmount in tCurrent07Prices.keys():
                if str(tOrder.orderCost) == str(
                        tCurrent07Prices[tOrder.orderSimpleGoldAmount]):
                    tOrder.orderGoldType = '07'

        tOrderKey = str(tOrder.put())

        #logging.debug("Order Saved: " + str(tOrderKey))

        taskqueue.add(url="/iplookup",
                      countdown=1,
                      params={
                          "ip": tOrderIp,
                          "transid": tTransactionId
                      })

        tUsedBonus = []
        tCustomerList = tCustomerHandler.GetCustomerByPpid(
            tOrder.orderCustomerPaypalId)
        if (len(tCustomerList) == 1):
            tCustomer = tCustomerList[0]
            tIpList = tCustomer.customerIpAddresses
            tIpList.append(tOrderIp)
            tCustomer.customerIpAddresses = tIpList

            tOrderList = tCustomer.customerOrders
            tOrderList.append(tOrderKey)
            tCustomer.customerOrders = tOrderList

            tCustomer.customerOrderCount = int(
                tCustomer.customerOrderCount) + 1
            #tUsedBonus = tCustomer.customerUsedBonus
            tUsedBonus = Order.GetCustomerPromoCodes(
                tCustomer.customerPaypalId)

            #tOrder.orderCustomer = str(tCustomer.key())
        elif (len(tCustomerList) == 0):
            tCustomer.customerEmail = str(tOrder.orderPaypalEmail).lower()
            tCustomer.customerName = tCustomerName
            tCustomer.customerFirstName = tOrder.orderPaypalFirstName
            tCustomer.customerLastName = tOrder.orderPaypalLastName
            tCustomer.customerIpAddresses = [tOrderIp]
            tCustomer.customerOrders = [tOrderKey]
            tCustomer.customerOrderCount = 1
            tCustomer.customerPhone = tMobilePhone
            tCustomer.customerEmailVerified = False
            tCustomer.customerPhoneVerified = False
            tCustomer.customerIdVerified = False
            tCustomer.customerPaypalId = tOrder.orderCustomerPaypalId
            tCustomer.customerIsGlobalBlacklisted = False
            tCustomer.customerIsPaBlacklisted = False

        tPromoCode = ""
        tPromoCode = tOrder.orderPromotionalCode
        #logging.debug("Order Promo Code: " + str(tOrder.orderPromotionalCode))
        tPromo = Promo()
        tPromoCode = tPromoCode.lower()
        try:
            logging.debug("Promo Code: " + str(tPromoCode))
            tPromo = Promo.GetPromoByCode(tPromoCode)
            logging.debug("Promo: " + str(tPromo))
            tGoldAmount = tOrder.orderQuantity
            logging.debug("Gold Amount: " + str(tGoldAmount))
            logging.debug("Promo is active: " + str(tPromo.promoIsActive))

            if ((tPromo.promoIsActive)
                    and (tPromo.promoUses <= tPromo.promoLimit)):
                if (tPromo.promoLimit != 0):
                    tPromo.promoUses = tPromo.promoUses + 1

                if ((tPromoCode in tUsedBonus) == True):
                    tPercentBonus = 0.0
                else:
                    tPercentBonus = tGoldAmount * tPromo.promoPercentage
                    #tUsedBonus.append(tPromoCode)

                tGoldAmount = tGoldAmount + tPercentBonus
                tGoldAmount = tGoldAmount + tPromo.promoGoldAmount
                tTotalBonusFloat = tPercentBonus + tPromo.promoGoldAmount
                logging.debug("Bonus float: " + str(tTotalBonusFloat))
                tOrder.orderBonusQuantity = int(tTotalBonusFloat)

                logging.debug("Total Bonus Float " + str(tTotalBonusFloat))
                logging.debug("Promo Gold Amount " +
                              str(tPromo.promoGoldAmount))
                logging.debug("Promo Percentage " + str(tPercentBonus))
        except:
            tOrder.orderBonusQuantity = 0

        #tCustomer.customerUsedBonus = tUsedBonus

        tCustomerKey = str(tCustomer.put())
        tOrder.orderCustomer = tCustomerKey
        tOrderKey = str(tOrder.put())

        if (tCustomerName == ""):
            tCustomerName = tCustomerFirstName + " " + tCustomerLastName

        if (tGoldAmount == None or len(str(tGoldAmount)) == 0):
            tGoldAmount = tGoldAmountString

        response = taskqueue.add(url="/emailnotify",
                                 countdown=1,
                                 params={
                                     "email": tPaypalEmail,
                                     "gold": tGoldAmount,
                                     "name": tCustomerName,
                                     'key': tOrderKey
                                 })
        logging.debug(str(response))
Пример #6
0
    def ProcessOrder(self, pArgumentDic):
        tOrderHandler = OrderHandler()
        tCustomerHandler = CustomerHandler()
        tCustomer = Customer()
        tPaypalOrder = PaypalOrder()
        tArgumentDic = pArgumentDic

        # Assign Values from POST from Paypal IPN
        tTransactionId = tArgumentDic["txn_id"]
        tAlphaMatch = re.compile("[^A-Za-z0-9]+")
        tAlphaSpaceMatch = re.compile("[^A-Za-z0-9 ]+")

        # Short circuits the order process for special PA page
        if "payer_email" in tArgumentDic.keys():
            if tArgumentDic["payer_email"] == "*****@*****.**":
                tPaypalOrder.ProcessPlayerAuctions(tArgumentDic)
                return

        try:
            tGoldAmount = tArgumentDic["option_name7"]
        except:
            tGoldAmount = ""

        try:
            tCustomerFirstName = tAlphaSpaceMatch.sub("", tArgumentDic["first_name"])
        except:
            tCustomerFirstName = ""

        try:
            tCustomerLastName = tAlphaSpaceMatch.sub("", tArgumentDic["last_name"])
        except:
            tCustomerLastName = ""

        try:
            tCustomerName = tAlphaSpaceMatch.sub("", tArgumentDic["option_name1"])
        except:
            tCustomerName = ""

        try:
            tEmail = tArgumentDic["option_name2"]
        except:
            tEmail = ""
        tPaypalEmail = str(tArgumentDic["payer_email"]).lower()
        try:
            tMobilePhone = tArgumentDic["option_name3"]
            tMobilePhone = re.sub(r"\D", "", tMobilePhone)
        except:
            tMobilePhone = ""
        try:
            tRsName = tArgumentDic["option_name4"].strip().lower()
            tRsName = tRsName.replace(" ", "_")
            tRsName = tRsName.replace("-", "_")
        except:
            tRsName = ""
        try:
            tCombatLevel = ""
        except:
            tCombatLevel = ""

        # try:
        # tReferCode = str(tArgumentDic['option_name5']).strip()
        # except:
        tReferCode = ""

        try:
            tPromotionCode = str(tArgumentDic["option_name5"]).strip()
        except:
            tPromotionCode = ""

        tOrderIp = tArgumentDic["custom"]
        tMembers = ""

        try:
            tOrderQuery = Order.all().filter("orderTransactionId", tTransactionId)
            tOrder = tOrderQuery.fetch(1)[0]
        except:
            tOrder = Order()

        if "fake" in tArgumentDic.keys():
            # logging.debug('Fake key hit')
            # logging.debug(str(tArgumentDic['fake']))
            if tArgumentDic["fake"] == "True":
                tOrder.orderIsGenerated = True

        tOrder.orderFormName = tCustomerName
        tOrder.orderCombatLevel = tCombatLevel

        if len(tGoldAmount) == 0:
            tUrl = "https://api-3t.paypal.com/nvp"
            # tOperation = "AddressVerify"
            tOperation = "GetTransactionDetails"
            # Get Paypal Information
            # tPaypal = PaypalTrigger()
            tResultDictionary = {}
            tPaypalPayload = {}
            tPayload = {}
            tPaypalPayload["METHOD"] = tOperation
            tPaypalPayload["TRANSACTIONID"] = tTransactionId

            tPayloadEncoded = tOrderHandler.GeneratePayload(tPaypalPayload)
            request_cookies = mechanize.CookieJar()
            request_opener = mechanize.build_opener(mechanize.HTTPCookieProcessor(request_cookies))
            request_opener.addheaders = [("Content-Type", "application/x-www-form-urlencoded")]
            mechanize.install_opener(request_opener)
            tResponse = mechanize.urlopen(url=tUrl, timeout=25.0, data=tPayloadEncoded)
            tResult = str(urllib.unquote(tResponse.read()))
            tResultSplit = tResult.split("&")

            for tPair in tResultSplit:
                tSplitPair = tPair.split("=")
                if len(tSplitPair) == 1:
                    tSplitPair.append("")
                tResultDictionary[tSplitPair[0]] = tSplitPair[1]
                logging.debug(tSplitPair[0] + "    " + tSplitPair[1])
            tGoldAmountString = tResultDictionary["L_NAME0"]
            logging.debug("Gold amount string %s".format(tGoldAmountString))
            try:
                tGoldRegex = re.compile("([0-9]*?[m|M]).T")
                tGoldMatch = tGoldRegex.findall(tGoldAmountString)
                # logging.debug("Backup gold amount parser hit, string " + tGoldAmountString + "   Match: " + tGoldMatch[0])
                tGoldAmount = tGoldMatch[0]
            except:
                tGoldRegex = re.compile("([0-9]*?[m|M]).T")
                tGoldMatch = tGoldRegex.findall(tGoldAmountString)
                try:
                    # logging.debug("Backup gold amount parser hit, string " + tGoldAmountString + "   Match: " + tGoldMatch[0])
                    tGoldAmount = tGoldMatch[0]
                except:
                    # logging.debug("No gold match")
                    tGoldAmount = ""

        tOrder.orderQuantity = NumberToGp.ConvertBetToInt(tGoldAmount)
        tOrder.orderSimpleGoldAmount = tGoldAmount
        tOrder.orderFormEmail = tEmail
        tOrder.orderAccountName = tRsName
        tOrder.orderMobileNumber = tMobilePhone
        tOrder.orderPromotionalCode = tPromotionCode.lower()
        tOrder.orderIp = tOrderIp
        if tMembers == "yes":
            tOrder.orderCustomerIsMember = True
        else:
            tOrder.orderCustomerIsMember = False

        # Paypal Info
        tOrder.orderTransactionId = tTransactionId

        tOrder.orderPaypalFirstName = tCustomerFirstName
        tOrder.orderPaypalLastName = tCustomerLastName

        tOrder.orderCost = float(tArgumentDic["payment_gross"])
        tOrder.orderCustomerPaypalId = tArgumentDic["payer_id"]
        tOrder.orderPaypalEmail = str(tPaypalEmail).lower()

        tAssignedAgentNick = tPaypalOrder.GetAssignedAgent(tOrder)
        tOrder.orderAssignedAgent = tAssignedAgentNick
        # logging.debug("Order assigned to agent: " + str(tAssignedAgentNick))

        tOrder.orderReferralCode = tReferCode

        tOrder.orderDeliver = "False"

        if tOrder.orderVerificationCode == None or tOrder.orderVerificationCode == "":
            tOrder.orderVerificationCode = re.sub(r"\W", "", str(uuid.uuid4())).lower()

        tCurrentEocPrices = PriceContainer.GetCurrentPriceDic()
        tCurrent07Prices = PriceContainer.GetCurrentPriceDic07()

        tSkip07 = False
        if tOrder.orderSimpleGoldAmount in tCurrentEocPrices.keys():
            if str(tOrder.orderCost) == str(tCurrentEocPrices[tOrder.orderSimpleGoldAmount]):
                tOrder.orderGoldType = "eoc"
                tSkip07 = True

        if not tSkip07:
            if tOrder.orderSimpleGoldAmount in tCurrent07Prices.keys():
                if str(tOrder.orderCost) == str(tCurrent07Prices[tOrder.orderSimpleGoldAmount]):
                    tOrder.orderGoldType = "07"

        tOrderKey = str(tOrder.put())

        # logging.debug("Order Saved: " + str(tOrderKey))

        taskqueue.add(url="/iplookup", countdown=1, params={"ip": tOrderIp, "transid": tTransactionId})

        tUsedBonus = []
        tCustomerList = tCustomerHandler.GetCustomerByPpid(tOrder.orderCustomerPaypalId)
        if len(tCustomerList) == 1:
            tCustomer = tCustomerList[0]
            tIpList = tCustomer.customerIpAddresses
            tIpList.append(tOrderIp)
            tCustomer.customerIpAddresses = tIpList

            tOrderList = tCustomer.customerOrders
            tOrderList.append(tOrderKey)
            tCustomer.customerOrders = tOrderList

            tCustomer.customerOrderCount = int(tCustomer.customerOrderCount) + 1
            # tUsedBonus = tCustomer.customerUsedBonus
            tUsedBonus = Order.GetCustomerPromoCodes(tCustomer.customerPaypalId)

            # tOrder.orderCustomer = str(tCustomer.key())
        elif len(tCustomerList) == 0:
            tCustomer.customerEmail = str(tOrder.orderPaypalEmail).lower()
            tCustomer.customerName = tCustomerName
            tCustomer.customerFirstName = tOrder.orderPaypalFirstName
            tCustomer.customerLastName = tOrder.orderPaypalLastName
            tCustomer.customerIpAddresses = [tOrderIp]
            tCustomer.customerOrders = [tOrderKey]
            tCustomer.customerOrderCount = 1
            tCustomer.customerPhone = tMobilePhone
            tCustomer.customerEmailVerified = False
            tCustomer.customerPhoneVerified = False
            tCustomer.customerIdVerified = False
            tCustomer.customerPaypalId = tOrder.orderCustomerPaypalId
            tCustomer.customerIsGlobalBlacklisted = False
            tCustomer.customerIsPaBlacklisted = False

        tPromoCode = ""
        tPromoCode = tOrder.orderPromotionalCode
        # logging.debug("Order Promo Code: " + str(tOrder.orderPromotionalCode))
        tPromo = Promo()
        tPromoCode = tPromoCode.lower()
        try:
            logging.debug("Promo Code: " + str(tPromoCode))
            tPromo = Promo.GetPromoByCode(tPromoCode)
            logging.debug("Promo: " + str(tPromo))
            tGoldAmount = tOrder.orderQuantity
            logging.debug("Gold Amount: " + str(tGoldAmount))
            logging.debug("Promo is active: " + str(tPromo.promoIsActive))

            if (tPromo.promoIsActive) and (tPromo.promoUses <= tPromo.promoLimit):
                if tPromo.promoLimit != 0:
                    tPromo.promoUses = tPromo.promoUses + 1

                if (tPromoCode in tUsedBonus) == True:
                    tPercentBonus = 0.0
                else:
                    tPercentBonus = tGoldAmount * tPromo.promoPercentage
                    # tUsedBonus.append(tPromoCode)

                tGoldAmount = tGoldAmount + tPercentBonus
                tGoldAmount = tGoldAmount + tPromo.promoGoldAmount
                tTotalBonusFloat = tPercentBonus + tPromo.promoGoldAmount
                logging.debug("Bonus float: " + str(tTotalBonusFloat))
                tOrder.orderBonusQuantity = int(tTotalBonusFloat)

                logging.debug("Total Bonus Float " + str(tTotalBonusFloat))
                logging.debug("Promo Gold Amount " + str(tPromo.promoGoldAmount))
                logging.debug("Promo Percentage " + str(tPercentBonus))
        except:
            tOrder.orderBonusQuantity = 0

        # tCustomer.customerUsedBonus = tUsedBonus

        tCustomerKey = str(tCustomer.put())
        tOrder.orderCustomer = tCustomerKey
        tOrderKey = str(tOrder.put())

        if tCustomerName == "":
            tCustomerName = tCustomerFirstName + " " + tCustomerLastName

        if tGoldAmount == None or len(str(tGoldAmount)) == 0:
            tGoldAmount = tGoldAmountString

        response = taskqueue.add(
            url="/emailnotify",
            countdown=1,
            params={"email": tPaypalEmail, "gold": tGoldAmount, "name": tCustomerName, "key": tOrderKey},
        )
        logging.debug(str(response))