'The purchase is completed, this OrderItem type will generate Registration Codes that will
be redeemed by users'

def purchased_callback(self):

    if (not modulestore().has_course(self.course_id)):
        msg = u"The    customer    purchased    Course    {0},    but    that    course    doesn't    exist!".format(self.course_id)
        log.error(msg)
        raise PurchasedCallbackException(msg)
    total_registration_codes = int(self.qty)
    from lms.djangoapps.instructor.views.api import save_registration_code
    for i in range(total_registration_codes):
        save_registration_code(self.user, self.course_id, self.mode, order=self.order)
    log.info('Enrolled    {0}    in    paid    course    {1},    paid    ${2}'.format(self.user.email, self.course_id, self.line_cost))
