diff --git a/src/storefront/payments.py b/src/storefront/payments.py index 46365fb..1d806ae 100644 --- a/src/storefront/payments.py +++ b/src/storefront/payments.py @@ -3,7 +3,9 @@ import sys import json import logging -from paypalcheckoutsdk.core import PayPalHttpClient, SandboxEnvironment, LiveEnvironment +from paypalcheckoutsdk.core import ( + PayPalHttpClient, SandboxEnvironment, LiveEnvironment +) from paypalcheckoutsdk.orders import OrdersCreateRequest, OrdersCaptureRequest from paypalhttp.serializers.json_serializer import Json @@ -91,19 +93,14 @@ class CreateOrder(PayPalClient): processed_items = [ { # Shows within upper-right dropdown during payment approval - "name": f'{item["product"]}: ' - ", ".join( - [ - next( - ( - f"{value['quantity']} x {v[1]}" - for i, v in enumerate(CoffeeGrind.GRIND_CHOICES) - if v[0] == key - ), - None, - ) - for key, value in item["variations"].items() - ] + "name": f'{item["product"]}: ' + ', '.join([ + next(( + f"{value['quantity']} x {v[1]}" + for i, v in enumerate(CoffeeGrind.GRIND_CHOICES) + if v[0] == key + ), + None, + ) for key, value in item["variations"].items()] )[:100], # Item details will also be in the completed paypal.com # transaction view diff --git a/src/storefront/tests/__init__.py b/src/storefront/tests/__init__.py index 3a9ddea..6f5eb66 100644 --- a/src/storefront/tests/__init__.py +++ b/src/storefront/tests/__init__.py @@ -21,8 +21,8 @@ class RequestFaker: }, 'items': [ { - 'name': 'Decaf', - 'description': '1 x Whole Beans, 2 x Percolator', + 'name': 'Decaf: 1 x Whole Beans, 2 x Percolator', + 'description': '', 'unit_amount': {'currency_code': 'USD', 'value': '13.40'}, 'quantity': '3', } diff --git a/src/storefront/tests/test_payments.py b/src/storefront/tests/test_payments.py index 1f4d059..d0f396a 100644 --- a/src/storefront/tests/test_payments.py +++ b/src/storefront/tests/test_payments.py @@ -20,6 +20,7 @@ from . import RequestFaker logger = logging.getLogger(__name__) + class CreateOrderTest(TestCase): @classmethod def setUpTestData(cls): @@ -35,7 +36,6 @@ class CreateOrderTest(TestCase): def setUp(self): self.client = Client() - def test_build_request_body(self): product_list_url = reverse('storefront:product-list') response = self.client.get(product_list_url, follow=True)