Fix payment name params in PayPal

This commit is contained in:
Nathan Chapman 2022-05-20 17:17:03 -06:00
parent 05506503bf
commit dd656a7dcf
3 changed files with 14 additions and 17 deletions

View File

@ -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

View File

@ -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',
}

View File

@ -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)