def enforce_time_window(time): """ given a datetime, return the start time of it's TIME_WINDOW aka - 'round down' a time into our TIME_WINDOW """ if not Config.get('TIME_WINDOW'): return time return from_epoch( epoch(time) // Config.get('TIME_WINDOW') * Config.get('TIME_WINDOW'))
def get_js_api_parameter(self, prepay_id): data = { "appId": self.appid, "timeStamp": epoch(datetime.datetime.now()), "nonceStr": self.get_nonce_str(), "package": "prepay_id={0}".format(prepay_id), "signType": "MD5", } sign = self.get_sign(data) data['paySign'] = sign return data