def GetContext(self): tContext = {} tActionDic = {} tActionDic['signup'] = 'subscr_signup' tActionDic['payment'] = 'subscr_payment' tActionDic['cancel'] = 'subscr_cancel' tActionDic['fail'] = 'subscr_failed' tIpnList = [] tPaypalIpn = PaypalIPN().all() #variable filter tAction = str(self.request.get("action")) if (tAction in tActionDic.keys()): tPaypalIpn.filter('txn_type', tActionDic[tAction]) tPaypalIpn.order('-ipnMessageSent') tIpnList = tPaypalIpn.fetch(limit=150) tContext['ipnlist'] = tIpnList return tContext
def post(self): tCustomerHandler = CustomerHandler() tCustomer = Customer() tPaypalOrder = PaypalOrder() tIpnLogger = PaypalIPN() tCustomerList = [] tIpList = [] tOrderList = [] tResultDictionary = {} tPaypalPayload = {} tPayload = {} tArgumentDic = {} tRequest = self.request tArguments = tRequest.arguments() if (str(tRequest) == "VERIFIED"): return for tArgument in tArguments: tArgumentDic[tArgument] = tRequest.get(tArgument) #For clearing placeholder data from goldshop form if (tArgumentDic[tArgument] == "."): tArgumentDic[tArgument] = "" #logging.debug("==========Beginning Request==========") tIpnLogger.ipnRawMessage = str(self.request) tIpnLogger._dynamic_properties = tArgumentDic tIpnLogger.put() for tArgKey in tArgumentDic.keys(): try: logging.debug("Paypal Post Key: " + str(tArgKey) + " with Value: " + str(tArgumentDic[tArgKey])) except: logging.debug("Error Storing Key: " + str(tArgKey)) #logging.debug("==========Stored Request==========") if ((tArgumentDic.has_key('txn_type')) and (tArgumentDic['txn_type'] == "web_accept")): self.response.out.write("cmd=_notify-validate" + str(tRequest)) if ((tArgumentDic.has_key('payment_status')) and (tArgumentDic['payment_status'] == "Completed")): tPaypalOrder.ProcessOrder(tArgumentDic) else: logging.debug( "Attemped Storage Canceled Due To It Not Being Completed Status" ) if ((tArgumentDic.has_key('case_type') and (len(tArgumentDic['case_type']) > 0))): tPaypalOrder.ProcessChargeback(tArgumentDic) elif (tArgumentDic.has_key('txn_type')): if (tArgumentDic['txn_type'] == "new_case"): tPaypalOrder.ProcessChargeback(tArgumentDic) #unsure why I included subscr_signup here #elif(tArgumentDic['txn_type'] == "subscr_payment" or tArgumentDic['txn_type'] == "subscr_signup"): elif (tArgumentDic['txn_type'] == "subscr_payment"): if (tArgumentDic.has_key('payment_status')): if (tArgumentDic['payment_status'] == 'Completed'): tPaypalOrder.ProcessSubscription(tArgumentDic) else: pass elif (tArgumentDic['txn_type'] == "subscr_cancel" or tArgumentDic['txn_type'] == "subscr_failed" or tArgumentDic['txn_type'] == "subscr_eot"): tPaypalOrder.ProcessSubscriptionCancellation(tArgumentDic) #elif((tArgumentDic.has_key('profile_status')) and (tArgumentDic['profile_status'] == "Suspended")): #tPaypalOrder.ProcessSubscriptionCancellation(tArgumentDic) elif ((tArgumentDic.has_key('payment_status')) and (tArgumentDic['payment_status'] == "Reversed")): tPaypalOrder.ProcessChargeback(tArgumentDic)