From 9e6ed7808cb4c75dd5937a025ab83068a0ed63cd Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Wed, 10 Apr 2024 22:49:51 +0200 Subject: [PATCH 1/3] move customer_data field to metadata Ref https://github.com/jazzband/django-payments/issues/378 --- payments/stripe/providers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/payments/stripe/providers.py b/payments/stripe/providers.py index 8f37d18b3..0c69651b8 100644 --- a/payments/stripe/providers.py +++ b/payments/stripe/providers.py @@ -130,8 +130,8 @@ def create_session(self, payment): if payment.billing_first_name or payment.billing_last_name: session_data.update( { - "customer_data": { - "customer_name": f"{payment.billing_first_name} " + "metadata": { + "customer_name": f"{payment.billing_first_name} " f"{payment.billing_last_name}" } } From b791e82c8b56d2b66f37624d271bac12046ee14c Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Wed, 10 Apr 2024 23:03:19 +0200 Subject: [PATCH 2/3] Add a test --- payments/stripe/test_stripev3.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/payments/stripe/test_stripev3.py b/payments/stripe/test_stripev3.py index ea3c7a506..d219a6360 100644 --- a/payments/stripe/test_stripev3.py +++ b/payments/stripe/test_stripev3.py @@ -107,6 +107,12 @@ def test_provider_create_session_failure_with_transaction_id(self): with patch("stripe.checkout.Session.create"), self.assertRaises(PaymentError): provider.create_session(payment) + def test_provider_create_session_success_with_billing_name(self): + payment = Payment() + payment.billing_name = "Billy Ngname" + provider = StripeProviderV3(api_key=API_KEY) + provider.create_session(payment) + def test_provider_status(self): payment = Payment() provider = StripeProviderV3(api_key=API_KEY) From 3c6177cde1bcb78adf4bdb0c2b8c8279e9fd455a Mon Sep 17 00:00:00 2001 From: Fabien Le Frapper Date: Wed, 10 Apr 2024 23:15:05 +0200 Subject: [PATCH 3/3] lint --- payments/stripe/providers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/payments/stripe/providers.py b/payments/stripe/providers.py index 0c69651b8..330975fd7 100644 --- a/payments/stripe/providers.py +++ b/payments/stripe/providers.py @@ -131,7 +131,7 @@ def create_session(self, payment): session_data.update( { "metadata": { - "customer_name": f"{payment.billing_first_name} " + "customer_name": f"{payment.billing_first_name} " f"{payment.billing_last_name}" } }