'Verifies that the inapp has been purchased.'

def check_purchase_inapp(self):

    self.setup_db()
    sql = 'SELECT    i.guid,    c.type    FROM    stats_contributions    c\n                                                                    JOIN    inapp_products    i    ON    i.id=c.inapp_product_id\n                                                                    WHERE    c.id    =    %(contribution_id)s    LIMIT    1;'
    self.cursor.execute(sql, {'contribution_id': self.get_contribution_id()})
    result = self.cursor.fetchone()
    if (not result):
        log_info('Invalid    in-app    receipt,    no    purchase')
        raise InvalidReceipt('NO_PURCHASE')
    (contribution_inapp_id, purchase_type) = result
    self.check_purchase_type(purchase_type)
    self.check_inapp_product(contribution_inapp_id)
