def void_campaign(link, campaign): transactions = get_transactions(link, [campaign]) bid_record = transactions.get(campaign._id) if bid_record: a = Account._byID(link.author_id) authorize.void_transaction(a, bid_record.transaction, campaign._id) hooks.get_hook('campaign.void').call(link=link, campaign=campaign)
def auth_paid_promo(thing, user, pay_id, bid): """ promotes a promotion from 'unpaid' to 'unseen'. In the case that bid already exists on the current promotion, the previous transaction is voided and repalced with the new bid. """ if thing.promote_status == STATUS.finished: return elif (thing.promote_status > STATUS.unpaid and thing.promote_trans_id): # void the existing transaction authorize.void_transaction(user, thing.promote_trans_id) # create a new transaction and update the bid trans_id = authorize.auth_transaction(bid, user, pay_id, thing) thing.promote_bid = bid if trans_id is not None: # we won't reset to unseen if already approved and the payment went ok promotion_log(thing, "updated payment and/or bid: SUCCESS") if trans_id < 0: promotion_log(thing, "FREEBIE") thing.promote_status = max(thing.promote_status, STATUS.unseen) thing.promote_trans_id = trans_id else: # something bad happend. promotion_log(thing, "updated payment and/or bid: FAILED") thing.promore_status = STATUS.unpaid thing.promote_trans_id = 0 PromoteDates.update_bid(thing) # commit last to guarantee consistency thing._commit() emailer.promo_bid(thing) return bool(trans_id)
def void_campaign(link, index, user): campaigns = getattr(link, "campaigns", {}).copy() if index in campaigns: sd, ed, bid, sr, trans_id = campaigns[index] transactions = get_transactions(link) if transactions.get(index): # void the existing transaction a = Account._byID(link.author_id) authorize.void_transaction(a, trans_id, index)
def void_campaign(link, campaign): transactions = get_transactions(link, [campaign]) bid_record = transactions.get(campaign._id) if bid_record: a = Account._byID(link.author_id) authorize.void_transaction(a, bid_record.transaction, campaign._id) campaign.trans_id = NO_TRANSACTION campaign._commit() text = "voided transaction for %s: (trans_id: %d)" % (campaign, bid_record.transaction) PromotionLog.add(link, text)
def delete_promo(thing): """ deleted promotions have to be specially dealt with. Reject the promo and void any associated transactions. """ thing.promoted = False thing._deleted = True reject_promo(thing, reason = "The promotion was deleted by the user") if thing.promote_trans_id > 0: user = Account._byID(thing.author_id) authorize.void_transaction(user, thing.promote_trans_id)
def void_campaign(link, campaign): transactions = get_transactions(link, [campaign]) bid_record = transactions.get(campaign._id) if bid_record: a = Account._byID(link.author_id) authorize.void_transaction(a, bid_record.transaction, campaign._id) campaign.trans_id = NO_TRANSACTION campaign._commit() text = ('voided transaction for %s: (trans_id: %d)' % (campaign, bid_record.transaction)) PromotionLog.add(link, text)
def void_campaign(link, campaign, reason): transactions = get_transactions(link, [campaign]) bid_record = transactions.get(campaign._id) if bid_record: a = Account._byID(link.author_id) authorize.void_transaction(a, bid_record.transaction, campaign._id) campaign.trans_id = NO_TRANSACTION campaign._commit() text = "voided transaction for %s: (trans_id: %d)" % (campaign, bid_record.transaction) PromotionLog.add(link, text) if bid_record.transaction > 0: # notify the user that the transaction was voided if it was not # a freebie emailer.void_payment(link, campaign, reason)
def void_campaign(link, campaign, reason): transactions = get_transactions(link, [campaign]) bid_record = transactions.get(campaign._id) if bid_record: a = Account._byID(link.author_id) authorize.void_transaction(a, bid_record.transaction, campaign._id) campaign.trans_id = NO_TRANSACTION campaign._commit() text = ('voided transaction for %s: (trans_id: %d)' % (campaign, bid_record.transaction)) PromotionLog.add(link, text) if bid_record.transaction > 0: # notify the user that the transaction was voided if it was not # a freebie emailer.void_payment(link, campaign, reason)
def void_campaign(link, campaign_id): transactions = get_transactions(link) bid_record = transactions.get(campaign_id) if bid_record: a = Account._byID(link.author_id) authorize.void_transaction(a, bid_record.transaction, campaign_id)