Merged in feature/payment-templates (pull request #373)
Use different templates for invoice and cc
This commit is contained in:
commit
424b97f597
|
|
@ -62,13 +62,20 @@ class EmailTemplate(Enum):
|
|||
# VBV - Neues Feedback für Circle
|
||||
NEW_FEEDBACK = {"de": "d-40fb94d5149949e7b8e7ddfcf0fcfdde"}
|
||||
|
||||
# Versicherungsvermittler (after buying a course)
|
||||
WELCOME_MAIL_VV = {
|
||||
# Versicherungsvermittler CC (after buying a course with Credit Card)
|
||||
WELCOME_MAIL_VV_CC = {
|
||||
"de": "d-308a72c779b74c8487cdec03c772ad13",
|
||||
"fr": "d-77b3c3a0f185408da55ce006226ca3ff",
|
||||
"it": "d-d27db9fc96f34f55a8cacf7640787c4e",
|
||||
}
|
||||
|
||||
# Versicherungsvermittler invoice (after buying a course invoice)
|
||||
WELCOME_MAIL_VV_INVOICE = {
|
||||
"de": "d-9cded96aaed54301af8099d420b316de",
|
||||
"fr": "d-e79eadd996c74d9c85a7cd6f6b313185",
|
||||
"it": "d-ee4e11583eee4e7087bbbf1331b6d13a",
|
||||
}
|
||||
|
||||
# VV - Lernbegleitung Einladung
|
||||
LEARNING_MENTOR_INVITATION = {
|
||||
"de": "d-8c862afde62748b6b8410887eeee89d8",
|
||||
|
|
|
|||
|
|
@ -6,8 +6,9 @@ import structlog
|
|||
from django.conf import settings
|
||||
|
||||
from vbv_lernwelt.core.admin import User
|
||||
from vbv_lernwelt.notify.email.email_services import EmailTemplate
|
||||
from vbv_lernwelt.shop.datatrans.datatrans_api_client import DatatransApiClient
|
||||
from vbv_lernwelt.shop.models import CheckoutState
|
||||
from vbv_lernwelt.shop.models import CheckoutInformation, CheckoutState
|
||||
|
||||
logger = structlog.get_logger(__name__)
|
||||
|
||||
|
|
@ -169,3 +170,10 @@ def datatrans_state_to_checkout_state(datatrans_transaction_state) -> CheckoutSt
|
|||
# An intermediate state such as "initialized", "challenge_ongoing", etc.
|
||||
# -> we don't care about those states, we only care about final states here.
|
||||
return CheckoutState.ONGOING
|
||||
|
||||
|
||||
def get_vv_payment_email_template(checkout_info: CheckoutInformation):
|
||||
if checkout_info.cembra_byjuno_invoice:
|
||||
return EmailTemplate.WELCOME_MAIL_VV_INVOICE
|
||||
else:
|
||||
return EmailTemplate.WELCOME_MAIL_VV_CC
|
||||
|
|
|
|||
|
|
@ -84,10 +84,8 @@ class DatatransWebhookTestCase(APITestCase):
|
|||
{"status": "invalid signature"},
|
||||
)
|
||||
|
||||
@patch("vbv_lernwelt.shop.views.is_signature_valid")
|
||||
@patch("vbv_lernwelt.shop.views.send_email")
|
||||
def test_webhook_settled_transmitted_paid(
|
||||
self, mock_send_mail, mock_is_signature_valid
|
||||
def _test_webhook_settled_transmitted_paid_with(
|
||||
self, invoice, template, mock_send_mail, mock_is_signature_valid
|
||||
):
|
||||
# GIVEN
|
||||
transaction_id = "1234567890"
|
||||
|
|
@ -112,6 +110,7 @@ class DatatransWebhookTestCase(APITestCase):
|
|||
checkout_info.organisation_postal_code = "5678"
|
||||
checkout_info.organisation_city = "Firmastadt"
|
||||
checkout_info.organisation_country_id = "CH"
|
||||
checkout_info.cembra_byjuno_invoice = invoice
|
||||
checkout_info.save()
|
||||
|
||||
mock_is_signature_valid.return_value = True
|
||||
|
|
@ -177,7 +176,7 @@ class DatatransWebhookTestCase(APITestCase):
|
|||
)
|
||||
|
||||
mock_send_mail.assert_called_once_with(
|
||||
template=EmailTemplate.WELCOME_MAIL_VV,
|
||||
template=template,
|
||||
recipient_email=self.user.email,
|
||||
template_data={
|
||||
"course": "Versicherungsvermittler/-in VBV (Deutsch)",
|
||||
|
|
@ -193,6 +192,30 @@ class DatatransWebhookTestCase(APITestCase):
|
|||
fail_silently=ANY,
|
||||
)
|
||||
|
||||
@patch("vbv_lernwelt.shop.views.is_signature_valid")
|
||||
@patch("vbv_lernwelt.shop.views.send_email")
|
||||
def test_webhook_settled_transmitted_paid_with_cc(
|
||||
self, mock_send_mail, mock_is_signature_valid
|
||||
):
|
||||
self._test_webhook_settled_transmitted_paid_with(
|
||||
False,
|
||||
EmailTemplate.WELCOME_MAIL_VV_CC,
|
||||
mock_send_mail,
|
||||
mock_is_signature_valid,
|
||||
)
|
||||
|
||||
@patch("vbv_lernwelt.shop.views.is_signature_valid")
|
||||
@patch("vbv_lernwelt.shop.views.send_email")
|
||||
def test_webhook_settled_transmitted_paid_with_invoice(
|
||||
self, mock_send_mail, mock_is_signature_valid
|
||||
):
|
||||
self._test_webhook_settled_transmitted_paid_with(
|
||||
True,
|
||||
EmailTemplate.WELCOME_MAIL_VV_INVOICE,
|
||||
mock_send_mail,
|
||||
mock_is_signature_valid,
|
||||
)
|
||||
|
||||
@patch("vbv_lernwelt.shop.views.is_signature_valid")
|
||||
def test_webhook_updates_webhook_history(self, mock_is_signature_valid):
|
||||
# GIVEN
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ from sentry_sdk import capture_exception
|
|||
from vbv_lernwelt.course.models import CourseSession, CourseSessionUser
|
||||
from vbv_lernwelt.learnpath.consts import COURSE_PROFILE_ALL_ID
|
||||
from vbv_lernwelt.learnpath.models import CourseProfile
|
||||
from vbv_lernwelt.notify.email.email_services import EmailTemplate, send_email
|
||||
from vbv_lernwelt.notify.email.email_services import send_email
|
||||
from vbv_lernwelt.shop.const import (
|
||||
VV_DE_PRODUCT_SKU,
|
||||
VV_FR_PRODUCT_SKU,
|
||||
|
|
@ -22,6 +22,7 @@ from vbv_lernwelt.shop.services import (
|
|||
create_context_data_log,
|
||||
datatrans_state_to_checkout_state,
|
||||
get_payment_url,
|
||||
get_vv_payment_email_template,
|
||||
init_datatrans_transaction,
|
||||
InitTransactionException,
|
||||
is_signature_valid,
|
||||
|
|
@ -244,7 +245,7 @@ def send_vv_welcome_email(checkout_info: CheckoutInformation):
|
|||
|
||||
send_email(
|
||||
recipient_email=checkout_info.user.email,
|
||||
template=EmailTemplate.WELCOME_MAIL_VV,
|
||||
template=get_vv_payment_email_template(checkout_info),
|
||||
template_data={
|
||||
"course": course_names[checkout_info.product_sku],
|
||||
"target_url": "https://my.vbv-afa.ch/",
|
||||
|
|
|
|||
Loading…
Reference in New Issue