def __init__(self, user, game, transaction_items):
        self.user = user
        self.game = game
        self.id = create_id()
        self.items = transaction_items

        total = 0

        game_store_items = StoreList.get(game)

        resource_keys = set()

        if len(transaction_items) == 0:
            raise StoreError('Basket is empty')

        for item_key, item in transaction_items.items():
            try:
                # convert string amounts to integers
                basket_amount = int(item['amount'])
                basket_price = int(item['price'])
            except (ValueError, KeyError, TypeError):
                raise StoreError('Item "%s" amount and price must be integers' % item_key)

            if basket_amount == 0:
                continue
            elif basket_amount < 0:
                raise StoreError('Item "%s" amount must be non-negative' % item_key)

            game_offering = game_store_items.get_offering(item_key)

            minor_price = game_offering.get_price().get_minor_amount()

            if basket_price != minor_price:
                raise StoreError('Item "%s" price does not match' % item_key)

            offering_output = game_offering.output
            try:
                basket_item_output = item['output']
                if not isinstance(basket_item_output, dict):
                    raise ValueError()
                if len(offering_output) != len(basket_item_output):
                    raise ValueError()

                for resource_key, amount in offering_output.items():
                    if amount != basket_item_output[resource_key]:
                        raise ValueError()
                    resource_keys.add(resource_key)
            except (KeyError, ValueError):
                raise StoreError('Offering "%s" output resources do not match' % item_key)

            self.items[item_key] = {
                'price': basket_price,
                'amount': basket_amount
            }

            total += minor_price * basket_amount

        for key in resource_keys:
            resource = game_store_items.get_resource(key)
            if resource is not None and resource.type == 'own':
                user_store_items = game_store_items.get_store_user(user)
                if user_store_items is not None:
                    try:
                        user_item = user_store_items.get_item(key)
                        if user_item['amount'] > 0:
                            raise StoreError('Basket contains an ownable item you already own')
                    except KeyError:
                        pass

        self.total = total

        self.completed = False
        self.completed_time = None

        UserTransactionsList.get(user).add_transaction(self.id, self)
dataset/ETHPy150Open turbulenz/turbulenz_local/turbulenz_local/models/apiv1/store.py/Transaction.__init__/original