diff --git a/services/nginx/app/modules/email/templates/email_template_stripe_invoice.php b/services/nginx/app/modules/email/templates/email_template_stripe_invoice.php index 9c7e51ef..c66ce2ea 100644 --- a/services/nginx/app/modules/email/templates/email_template_stripe_invoice.php +++ b/services/nginx/app/modules/email/templates/email_template_stripe_invoice.php @@ -32,7 +32,7 @@ class email_template_stripe_invoice
Kære = $this->name ?>,
-Tak for din bestilling hos Truck Wash. Vi har sendt dig en faktura på Stripe. +
Tak for din bestilling hos Truck Wash. Vi har sendt dig et betalingslink til din faktura. Du kan betale fakturaen ved at klikke på linket nedenfor:
diff --git a/services/nginx/app/tests/Support/legacy_test_manifest.php b/services/nginx/app/tests/Support/legacy_test_manifest.php index a0779c73..99707797 100644 --- a/services/nginx/app/tests/Support/legacy_test_manifest.php +++ b/services/nginx/app/tests/Support/legacy_test_manifest.php @@ -6,6 +6,7 @@ return [ ['path' => 'tests/auth/PasskeyChallengeTest.php', 'classification' => 'unit', 'type' => 'script'], ['path' => 'tests/auth/PemToCoseConversionTest.php', 'classification' => 'unit', 'type' => 'script'], ['path' => 'tests/auth/RegisterCvrTest.php', 'classification' => 'unit', 'type' => 'script'], + ['path' => 'tests/auth/StripeInvoiceEmailTemplateTest.php', 'classification' => 'unit', 'type' => 'script'], ['path' => 'tests/auth/TwoFactorAuthTest.php', 'classification' => 'integration', 'type' => 'script'], ['path' => 'tests/auth/WebAuthnInstallTest.php', 'classification' => 'unit', 'type' => 'script'], ['path' => 'tests/bookingModule/BookingModuleTest.php', 'classification' => 'unit', 'type' => 'script'], diff --git a/services/nginx/app/tests/auth/StripeInvoiceEmailTemplateTest.php b/services/nginx/app/tests/auth/StripeInvoiceEmailTemplateTest.php new file mode 100644 index 00000000..bb51d3be --- /dev/null +++ b/services/nginx/app/tests/auth/StripeInvoiceEmailTemplateTest.php @@ -0,0 +1,73 @@ + $base_level) { + $output .= (string)ob_get_clean(); + } + + return $output; + } + + $base_level = ob_get_level(); + ob_start(); + + try { + $html = (new \email\templates\email_template_stripe_invoice( + 4242, + 'https://pay.example.com/invoice/abc', + 'Anders And' + ))->generate_html(); + $leaked_output = cleanup_buffers_to($base_level); + + assert_true($leaked_output === '', 'Template generation must not leak buffered HTML output.'); + + // TRU-71: user-facing wording must not mention the payment processor + // by name. The email body must describe the artefact in plain + // language instead. + assert_true( + stripos($html, 'stripe') === false, + 'Stripe-invoice email body must no longer expose the payment processor name "Stripe" to the customer.' + ); + + assert_true( + str_contains($html, 'betalingslink'), + 'Stripe-invoice email body must describe the artefact as a betalingslink (payment link).' + ); + + assert_true( + str_contains($html, 'Kære Anders And'), + 'Template must still greet the customer by name.' + ); + + assert_true( + str_contains($html, 'Betal faktura for ordre 4242'), + 'Template must still expose a pay-now action link for the order.' + ); + } catch (\Throwable $exception) { + $leaked_output = cleanup_buffers_to($base_level); + fwrite(STDERR, $leaked_output); + fwrite(STDERR, $exception->getMessage() . PHP_EOL); + exit(1); + } + + echo "\033[32m[PASS]\033[0m Stripe-invoice email template no longer mentions Stripe to the customer.\n"; + exit(0); +}