Esempio n. 1
0
    def _notify_purchaser(self):
        """ Notify the purchaser that the refund has been processed. """
        site_configuration = self.order.site.siteconfiguration
        site_code = site_configuration.partner.short_code

        if not site_configuration.send_refund_notifications:
            logger.info(
                'Refund notifications are disabled for Partner [%s]. No notification will be sent for Refund [%d]',
                site_code, self.id)
            return

        # NOTE (CCB): The initial version of the refund email only supports refunding a single course.
        product = self.lines.first().order_line.product
        product_class = product.get_product_class().name

        if product_class != SEAT_PRODUCT_CLASS_NAME:
            logger.warning((
                'No refund notification will be sent for Refund [%d]. The notification supports product lines '
                'of type Course, not [%s].'), self.id, product_class)
            return

        course_name = self.lines.first().order_line.product.course.name
        order_number = self.order.number
        order_url = get_receipt_page_url(site_configuration, order_number)
        amount = format_currency(self.currency, self.total_credit_excl_tax)

        send_course_refund_email.delay(self.user.email,
                                       self.id,
                                       amount,
                                       course_name,
                                       order_number,
                                       order_url,
                                       site_code=site_code)
        logger.info('Course refund notification scheduled for Refund [%d].',
                    self.id)
Esempio n. 2
0
    def _notify_purchaser(self):
        """ Notify the purchaser that the refund has been processed. """
        site_configuration = self.order.site.siteconfiguration
        site_code = site_configuration.partner.short_code

        if not site_configuration.send_refund_notifications:
            logger.info(
                'Refund notifications are disabled for Partner [%s]. No notification will be sent for Refund [%d]',
                site_code, self.id
            )
            return

        # NOTE (CCB): The initial version of the refund email only supports refunding a single course.
        product = self.lines.first().order_line.product
        product_class = product.get_product_class().name

        if product_class != SEAT_PRODUCT_CLASS_NAME:
            logger.warning(
                ('No refund notification will be sent for Refund [%d]. The notification supports product lines '
                 'of type Course, not [%s].'),
                self.id, product_class
            )
            return

        course_name = self.lines.first().order_line.product.course.name
        order_number = self.order.number
        order_url = get_receipt_page_url(site_configuration, order_number)
        amount = format_currency(self.currency, self.total_credit_excl_tax)

        send_course_refund_email.delay(self.user.email, self.id, amount, course_name, order_number,
                                       order_url, site_code=site_code)
        logger.info('Course refund notification scheduled for Refund [%d].', self.id)