Ejemplo n.º 1
0
    def process_referrals(self):
        invoice = self.transaction.get_invoice()

        if invoice.amount >= 0:
            return

        buyer = AccountPrototype.get_by_id(invoice.recipient_id)

        if buyer.referral_of_id is None:
            return

        owner = AccountPrototype.get_by_id(buyer.referral_of_id)

        transaction_logic(account=owner,
                          amount=-int(invoice.amount*payments_settings.REFERRAL_BONUS),
                          description='Часть от потраченного вашим рефералом',
                          uid='referral-bonus',
                          force=True)
Ejemplo n.º 2
0
    def process_referrals(self):
        invoice = self.transaction.get_invoice()

        if invoice.amount >= 0:
            return

        buyer = AccountPrototype.get_by_id(invoice.recipient_id)

        if buyer.referral_of_id is None:
            return

        owner = AccountPrototype.get_by_id(buyer.referral_of_id)

        transaction_logic(account=owner,
                          amount=-int(invoice.amount*payments_settings.REFERRAL_BONUS),
                          description=u'Часть от потраченного вашим рефералом',
                          uid='referral-bonus',
                          force=True)
Ejemplo n.º 3
0
    def buy(self, account):
        if account.is_fast:
            raise exceptions.FastAccountError(purchase_uid=self.uid, account_id=account.id)

        self.additional_checks(account)

        transaction = transaction_logic(account=account,
                                        amount=-self.cost,
                                        description=self.transaction_description,
                                        uid='ingame-purchase-<%s>' % self.uid)

        postponed_logic = self.construct_postponed_task(account, transaction)

        postponed_task = PostponedTaskPrototype.create(postponed_logic)
        postponed_task.cmd_wait()

        return postponed_task
Ejemplo n.º 4
0
    def buy(self, account):
        if account.is_fast:
            raise exceptions.FastAccountError(purchase_uid=self.uid,
                                              account_id=account.id)

        self.additional_checks(account)

        transaction = transaction_logic(
            account=account,
            amount=-self.cost,
            description=self.transaction_description,
            uid='ingame-purchase-<%s>' % self.uid)

        postponed_logic = self.construct_postponed_task(account, transaction)

        postponed_task = PostponedTaskPrototype.create(postponed_logic)
        postponed_task.cmd_wait()

        return postponed_task