Require a complete PCM return address before placing orders.
Deploy Beta / unit-tests (push) Successful in 14s
Deploy Beta / docker (push) Successful in 17s
Deploy Beta / deploy-beta (push) Successful in 1m40s

Empty PCM_RETURN_ADDRESS was sending SITE_NAME as firstName with blank street fields, which PCM rejects with 400; validate early and wire PCM env through compose.
This commit is contained in:
2026-08-11 05:52:39 -05:00
parent 7fb5317308
commit 2643ba7a96
5 changed files with 126 additions and 28 deletions
+28
View File
@@ -1079,6 +1079,34 @@ class PcmAuthTests(TestCase):
pcm_mod.login(force=True)
self.assertIn("PCM_API_SECRET", str(ctx.exception))
def test_return_address_requires_street_fields(self):
from messaging.providers.postcard import pcm as pcm_mod
with self.settings(
SITE_NAME="Monica Dhillon",
PCM_RETURN_ADDRESS="",
PCM_RETURN_LINE1="",
PCM_RETURN_CITY="",
PCM_RETURN_STATE="",
PCM_RETURN_ZIP="",
):
with self.assertRaises(pcm_mod.PcmApiError) as ctx:
pcm_mod.return_address_from_settings()
self.assertIn("PCM return address incomplete", str(ctx.exception))
def test_return_address_from_json(self):
from messaging.providers.postcard import pcm as pcm_mod
with self.settings(
PCM_RETURN_ADDRESS=(
'{"firstName":"Mo","lastName":"D","address":"1 Main",'
'"city":"Naperville","state":"IL","zipCode":"60540"}'
),
):
addr = pcm_mod.return_address_from_settings()
self.assertEqual(addr["address"], "1 Main")
self.assertEqual(addr["zipCode"], "60540")
class PostcardAddressDefaultConsentTests(TestCase):
def test_address_without_consent_is_postcard_eligible(self):