def reverse_gold_purchase(transaction_id, goldtype, buyer, pennies, recipient=None): gold_recipient = recipient or buyer with gold_lock(gold_recipient): gold_recipient._sync_latest() months, days = months_and_days_from_pennies(pennies) 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')
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')
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")