本文整理汇总了Python中r2.models.retrieve_gold_transaction函数的典型用法代码示例。如果您正苦于以下问题:Python retrieve_gold_transaction函数的具体用法?Python retrieve_gold_transaction怎么用?Python retrieve_gold_transaction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了retrieve_gold_transaction函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: process_webhook
def process_webhook(self, event_type, passthrough, transaction_id, pennies,
months):
if event_type == 'noop':
return
try:
payment_blob = validate_blob(passthrough)
except GoldException as e:
g.log.error('%s %s: bad payment_blob %s' % (self.name,
transaction_id,
e))
self.abort403()
goldtype = payment_blob['goldtype']
buyer = payment_blob['buyer']
recipient = payment_blob.get('recipient', None)
signed = payment_blob.get('signed', False)
giftmessage = payment_blob.get('giftmessage', None)
comment = payment_blob.get('comment', None)
comment = comment._fullname if comment else None
existing = retrieve_gold_transaction(transaction_id)
if event_type == 'cancelled':
subject = 'gold payment cancelled'
msg = ('your gold payment has been cancelled, contact '
'%(gold_email)s for details' % {'gold_email':
g.goldthanks_email})
send_system_message(buyer, subject, msg)
if existing:
# note that we don't check status on existing, probably
# should update gold_table when a cancellation happens
reverse_gold_purchase(transaction_id)
elif event_type == 'succeeded':
if existing and existing.status == 'processed':
g.log.info('POST_goldwebhook skipping %s' % transaction_id)
return
payer_email = ''
payer_id = ''
subscription_id = None
complete_gold_purchase(passthrough, transaction_id, payer_email,
payer_id, subscription_id, pennies, months,
goldtype, buyer, recipient, signed,
giftmessage, comment)
elif event_type == 'failed':
subject = 'gold payment failed'
msg = ('your gold payment has failed, contact %(gold_email)s for '
'details' % {'gold_email': g.goldthanks_email})
send_system_message(buyer, subject, msg)
# probably want to update gold_table here
elif event_type == 'refunded':
if not (existing and existing.status == 'processed'):
return
subject = 'gold refund'
msg = ('your gold payment has been refunded, contact '
'%(gold_email)s for details' % {'gold_email':
g.goldthanks_email})
send_system_message(buyer, subject, msg)
reverse_gold_purchase(transaction_id)
开发者ID:Alastiran,项目名称:reddit,代码行数:60,代码来源:ipn.py
示例2: process_webhook
def process_webhook(self, event_type, webhook):
if event_type == "noop":
return
existing = retrieve_gold_transaction(webhook.transaction_id)
if not existing and webhook.passthrough:
try:
webhook.load_blob()
except GoldException as e:
g.log.error("%s: payment_blob %s", webhook.transaction_id, e)
self.abort403()
msg = None
if event_type == "cancelled":
subject = _("reddit gold payment cancelled")
msg = _("Your reddit gold payment has been cancelled, contact " "%(gold_email)s for details") % {
"gold_email": g.goldthanks_email
}
if existing:
# note that we don't check status on existing, probably
# should update gold_table when a cancellation happens
reverse_gold_purchase(webhook.transaction_id)
elif event_type == "succeeded":
if existing and existing.status == "processed":
g.log.info("POST_goldwebhook skipping %s" % webhook.transaction_id)
return
self.complete_gold_purchase(webhook)
elif event_type == "failed":
subject = _("reddit gold payment failed")
msg = _("Your reddit gold payment has failed, contact " "%(gold_email)s for details") % {
"gold_email": g.goldthanks_email
}
elif event_type == "failed_subscription":
subject = _("reddit gold subscription payment failed")
msg = _(
"Your reddit gold subscription payment has failed. "
"Please go to http://www.reddit.com/subscription to "
"make sure your information is correct, or contact "
"%(gold_email)s for details"
) % {"gold_email": g.goldthanks_email}
elif event_type == "refunded":
if not (existing and existing.status == "processed"):
return
subject = _("reddit gold refund")
msg = _("Your reddit gold payment has been refunded, contact " "%(gold_email)s for details") % {
"gold_email": g.goldthanks_email
}
reverse_gold_purchase(webhook.transaction_id)
if msg:
if existing:
buyer = Account._byID(int(existing.account_id), data=True)
elif webhook.buyer:
buyer = webhook.buyer
else:
return
send_system_message(buyer, subject, msg)
开发者ID:tolgaek,项目名称:reddit,代码行数:59,代码来源:ipn.py
示例3: reverse_gold_purchase
def reverse_gold_purchase(transaction_id):
transaction = retrieve_gold_transaction(transaction_id)
if not transaction:
raise GoldException('gold_table %s not found' % transaction_id)
buyer = Account._byID(int(transaction.account_id), data=True)
recipient = None
days = transaction.days
months = days / 31
secret = transaction.secret
if '{' in secret:
secret.strip('{}') # I goofed
pieces = secret.split(',')
else:
pieces = secret.split('-')
goldtype = pieces[0]
if goldtype == 'gift':
recipient_name, secret = pieces[1:]
recipient = Account._by_name(recipient_name)
gold_recipient = recipient or buyer
with gold_lock(gold_recipient):
gold_recipient._sync_latest()
if goldtype in ('onetime', 'autorenew'):
subtract_gold_days(buyer, days)
elif goldtype == 'creddits':
subtract_gold_creddits(buyer, months)
elif goldtype == 'gift':
subtract_gold_days(recipient, days)
subject = 'your gifted gold has been reversed'
message = 'sorry, but the payment was reversed'
send_system_message(recipient, subject, message)
update_gold_transaction(transaction_id, 'reversed')
开发者ID:AD42,项目名称:reddit,代码行数:38,代码来源:ipn.py
示例4: reverse_gold_purchase
def reverse_gold_purchase(transaction_id):
transaction = retrieve_gold_transaction(transaction_id)
if not transaction:
raise GoldException("gold_table %s not found" % transaction_id)
buyer = Account._byID(int(transaction.account_id), data=True)
recipient = None
days = transaction.days
months = days / 31
secret = transaction.secret
if "{" in secret:
secret.strip("{}") # I goofed
pieces = secret.split(",")
else:
pieces = secret.split("-")
goldtype = pieces[0]
if goldtype == "gift":
recipient_name, secret = pieces[1:]
recipient = Account._by_name(recipient_name)
gold_recipient = recipient or buyer
with gold_lock(gold_recipient):
gold_recipient._sync_latest()
if goldtype in ("onetime", "autorenew"):
subtract_gold_days(buyer, days)
elif goldtype == "creddits":
subtract_gold_creddits(buyer, months)
elif goldtype == "gift":
subtract_gold_days(recipient, days)
subject = "your gifted gold has been reversed"
message = "sorry, but the payment was reversed"
send_system_message(recipient, subject, message)
update_gold_transaction(transaction_id, "reversed")
开发者ID:tolgaek,项目名称:reddit,代码行数:38,代码来源:ipn.py
示例5: process_webhook
def process_webhook(self, event_type, webhook):
if event_type == 'noop':
return
existing = retrieve_gold_transaction(webhook.transaction_id)
if not existing and webhook.passthrough:
try:
webhook.load_blob()
except GoldException as e:
g.log.error('%s: payment_blob %s', webhook.transaction_id, e)
self.abort403()
msg = None
if event_type == 'cancelled':
subject = _('reddit gold payment cancelled')
msg = _('Your reddit gold payment has been cancelled, contact '
'%(gold_email)s for details') % {'gold_email':
g.goldthanks_email}
if existing:
# note that we don't check status on existing, probably
# should update gold_table when a cancellation happens
reverse_gold_purchase(webhook.transaction_id)
elif event_type == 'succeeded':
if (existing and
existing.status in ('processed', 'unclaimed', 'claimed')):
g.log.info('POST_goldwebhook skipping %s' % webhook.transaction_id)
return
self.complete_gold_purchase(webhook)
elif event_type == 'failed':
subject = _('reddit gold payment failed')
msg = _('Your reddit gold payment has failed, contact '
'%(gold_email)s for details') % {'gold_email':
g.goldthanks_email}
elif event_type == 'failed_subscription':
subject = _('reddit gold subscription payment failed')
msg = _('Your reddit gold subscription payment has failed. Please '
'go to [your gold subscription page](%(gold_subscription)s) '
'to make sure your information is correct, or contact '
'%(gold_email)s for details')
msg %= {'gold_subscription': '/gold/subscription',
'gold_email': g.goldthanks_email}
elif event_type == 'refunded':
if not (existing and existing.status == 'processed'):
return
subject = _('reddit gold refund')
msg = _('Your reddit gold payment has been refunded, contact '
'%(gold_email)s for details') % {'gold_email':
g.goldthanks_email}
reverse_gold_purchase(webhook.transaction_id)
if msg:
if existing:
buyer = Account._byID(int(existing.account_id), data=True)
elif webhook.buyer:
buyer = webhook.buyer
else:
return
try:
send_system_message(buyer, subject, msg)
except MessageError:
g.log.error('process_webhook: send_system_message error')
开发者ID:dinxx,项目名称:reddit,代码行数:64,代码来源:ipn.py
示例6: process_webhook
def process_webhook(self, event_type, webhook):
if event_type == 'noop':
return
existing = retrieve_gold_transaction(webhook.transaction_id)
if not existing and webhook.passthrough:
try:
webhook.load_blob()
except GoldException as e:
g.log.error('%s: payment_blob %s', webhook.transaction_id, e)
if self.abort_on_error:
self.abort403()
else:
return
msg = None
if event_type == 'cancelled':
subject = _('reddit gold payment cancelled')
msg = _('Your reddit gold payment has been cancelled, contact '
'%(gold_email)s for details') % {'gold_email':
g.goldthanks_email}
if existing:
# note that we don't check status on existing, probably
# should update gold_table when a cancellation happens
reverse_gold_purchase(webhook.transaction_id)
elif event_type == 'succeeded':
if (existing and
existing.status in ('processed', 'unclaimed', 'claimed')):
g.log.info('POST_goldwebhook skipping %s' % webhook.transaction_id)
return
self.complete_gold_purchase(webhook)
elif event_type == 'failed':
subject = _('reddit gold payment failed')
msg = _('Your reddit gold payment has failed, contact '
'%(gold_email)s for details') % {'gold_email':
g.goldthanks_email}
elif event_type == 'deleted_subscription':
# the subscription may have been deleted directly by the user using
# POST_delete_subscription, in which case gold_subscr_id is already
# unset and we don't need to message them
if webhook.buyer and webhook.buyer.gold_subscr_id:
subject = _('reddit gold subscription cancelled')
msg = _('Your reddit gold subscription has been cancelled '
'because your credit card could not be charged. '
'Contact %(gold_email)s for details')
msg %= {'gold_email': g.goldthanks_email}
webhook.buyer.gold_subscr_id = None
webhook.buyer._commit()
elif event_type == 'refunded':
if not (existing and existing.status == 'processed'):
return
subject = _('reddit gold refund')
msg = _('Your reddit gold payment has been refunded, contact '
'%(gold_email)s for details') % {'gold_email':
g.goldthanks_email}
reverse_gold_purchase(webhook.transaction_id)
if msg:
if existing:
buyer = Account._byID(int(existing.account_id), data=True)
elif webhook.buyer:
buyer = webhook.buyer
else:
return
try:
send_system_message(buyer, subject, msg)
except MessageError:
g.log.error('process_webhook: send_system_message error')
开发者ID:6r3nt,项目名称:reddit,代码行数:71,代码来源:ipn.py
示例7: process_webhook
def process_webhook(self, event_type, passthrough, transaction_id, pennies, months):
if event_type == "noop":
return
try:
payment_blob = validate_blob(passthrough)
except GoldError as e:
g.log.error("%s %s: bad payment_blob %s" % (self.name, transaction_id, e))
self.abort403()
goldtype = payment_blob["goldtype"]
buyer = payment_blob["buyer"]
recipient = payment_blob.get("recipient", None)
signed = payment_blob.get("signed", False)
giftmessage = payment_blob.get("giftmessage", None)
comment = payment_blob.get("comment", None)
comment = comment._fullname if comment else None
existing = retrieve_gold_transaction(transaction_id)
if event_type == "cancelled":
subject = "gold payment cancelled"
msg = "your gold payment has been cancelled, contact " "%(gold_email)s for details" % {
"gold_email": g.goldthanks_email
}
send_system_message(buyer, subject, msg)
if existing:
# note that we don't check status on existing, probably
# should update gold_table when a cancellation happens
reverse_gold_purchase(transaction_id)
elif event_type == "succeeded":
if existing and existing.status == "processed":
g.log.info("POST_goldwebhook skipping %s" % transaction_id)
return
payer_email = ""
payer_id = ""
subscription_id = None
complete_gold_purchase(
passthrough,
transaction_id,
payer_email,
payer_id,
subscription_id,
pennies,
months,
goldtype,
buyer,
recipient,
signed,
giftmessage,
comment,
)
elif event_type == "failed":
subject = "gold payment failed"
msg = "your gold payment has failed, contact %(gold_email)s for " "details" % {
"gold_email": g.goldthanks_email
}
send_system_message(buyer, subject, msg)
# probably want to update gold_table here
elif event_type == "refunded":
if not (existing and existing.status == "processed"):
return
subject = "gold refund"
msg = "your gold payment has been refunded, contact " "%(gold_email)s for details" % {
"gold_email": g.goldthanks_email
}
send_system_message(buyer, subject, msg)
reverse_gold_purchase(transaction_id)
开发者ID:new-day-international,项目名称:reddit,代码行数:69,代码来源:ipn.py
注:本文中的r2.models.retrieve_gold_transaction函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论