Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add billing_company_name to payments
Pacu2eb452c3d3901
diff --git a/saleor/graphql/payment/mutations.py b/saleor/graphql/payment/mutations.pyindex 5c0e05d9e8..a14b0f3437 100644--- a/saleor/graphql/payment/mutations.py+++ b/saleor/graphql/payment/mutations.py@@ -79,6 +79,7 @@ class CheckoutPaymentMethodCreate(BaseMutation, I18nMixin):billing_data = {'billing_first_name': billing_address.first_name,'billing_last_name': billing_address.last_name,+ 'billing_company_name': billing_address.company_name,'billing_address_1': billing_address.street_address_1,'billing_address_2': billing_address.street_address_2,'billing_city': billing_address.city,diff --git a/saleor/order/views.py b/saleor/order/views.pyindex 5ba923fda8..121f149d5d 100644--- a/saleor/order/views.py+++ b/saleor/order/views.py@@ -18,6 +18,7 @@ from ..core.utils import get_client_ipfrom ..payment import ChargeStatusfrom ..payment.forms import PaymentMethodFormfrom ..payment.models import PaymentMethod+from ..payment.utils import get_billing_datafrom .forms import (CustomerNoteForm, PasswordForm, PaymentDeleteForm, PaymentMethodsForm)from .models import Order@@ -86,20 +87,11 @@ def payment(request, token):@check_order_statusdef start_payment(request, order, variant):- billing = order.billing_addresstotal = order.totaldefaults = {'total': total,- 'billing_first_name': billing.first_name,- 'billing_last_name': billing.last_name,- 'billing_address_1': billing.street_address_1,- 'billing_address_2': billing.street_address_2,- 'billing_city': billing.city,- 'billing_postal_code': billing.postal_code,- 'billing_country_code': billing.country.code,- 'billing_email': order.user_email,- 'billing_country_area': billing.country_area,- 'customer_ip_address': get_client_ip(request)}+ 'customer_ip_address': get_client_ip(request),+ **get_billing_data(order)}variant_choices = settings.CHECKOUT_PAYMENT_CHOICESif variant not in [code for code, dummy_name in variant_choices]:raise Http404('%r is not a valid payment variant' % (variant,))diff --git a/saleor/payment/migrations/0001_initial.py b/saleor/payment/migrations/0001_initial.pyindex 1d4baaf174..1fd5e5e263 100644--- a/saleor/payment/migrations/0001_initial.py+++ b/saleor/payment/migrations/0001_initial.py@@ -28,6 +28,7 @@ class Migration(migrations.Migration):('charge_status', models.CharField(choices=[('charged', 'Charged'), ('not-charged', 'Not charged'), ('fully-refunded', 'Fully refunded')], default='not-charged', max_length=15)),('billing_first_name', models.CharField(blank=True, max_length=256)),('billing_last_name', models.CharField(blank=True, max_length=256)),+ ('billing_company_name', models.CharField(blank=True, max_length=256)),('billing_address_1', models.CharField(blank=True, max_length=256)),('billing_address_2', models.CharField(blank=True, max_length=256)),('billing_city', models.CharField(blank=True, max_length=256)),diff --git a/saleor/payment/models.py b/saleor/payment/models.pyindex 87f0635290..e2c751b310 100644--- a/saleor/payment/models.py+++ b/saleor/payment/models.py@@ -35,9 +35,10 @@ class PaymentMethod(models.Model):choices=ChargeStatus.CHOICES,default=ChargeStatus.NOT_CHARGED)- # FIXME assign it as a separate Address instance?+ # FIXME maybe assign it as a separate Address instance?billing_first_name = models.CharField(max_length=256, blank=True)billing_last_name = models.CharField(max_length=256, blank=True)+ billing_company_name = models.CharField(max_length=256, blank=True)billing_address_1 = models.CharField(max_length=256, blank=True)billing_address_2 = models.CharField(max_length=256, blank=True)billing_city = models.CharField(max_length=256, blank=True)diff --git a/saleor/payment/providers/braintree/__init__.py b/saleor/payment/providers/braintree/__init__.pyindex 958e28baac..8d9091f433 100644--- a/saleor/payment/providers/braintree/__init__.py+++ b/saleor/payment/providers/braintree/__init__.py@@ -20,6 +20,7 @@ def get_customer_data(payment):'billing': {'first_name': payment.billing_first_name,'last_name': payment.billing_last_name,+ 'company': payment.billing_company_name,'postal_code': payment.billing_postal_code,'street_address': payment.billing_address_1[:255],'extended_address': payment.billing_address_2[:255],diff --git a/saleor/payment/utils.py b/saleor/payment/utils.pyindex b43554e98d..a93921b372 100644--- a/saleor/payment/utils.py+++ b/saleor/payment/utils.py@@ -22,11 +22,13 @@ def get_billing_data(order):data = {'billing_first_name': order.billing_address.first_name,'billing_last_name': order.billing_address.last_name,+ 'billing_company_name': order.billing_address.company_name,'billing_address_1': order.billing_address.street_address_1,'billing_address_2': order.billing_address.street_address_2,'billing_city': order.billing_address.city,'billing_postal_code': order.billing_address.postal_code,'billing_country_code': order.billing_address.country,+ 'billing_email': order.user_email,'billing_country_area': order.billing_address.country_area}return datadiff --git a/saleor/settings.py b/saleor/settings.pyindex d99430f3c6..b02bd1336d 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -182,7 +182,7 @@ MIDDLEWARE = ['saleor.core.middleware.taxes','social_django.middleware.SocialAuthExceptionMiddleware','impersonate.middleware.ImpersonateMiddleware',- # 'saleor.graphql.middleware.jwt_middleware'+ 'saleor.graphql.middleware.jwt_middleware']INSTALLED_APPS = [diff --git a/tests/conftest.py b/tests/conftest.pyindex a7be0eb6b7..8cd179470a 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -736,6 +736,7 @@ def payment_method_dummy(db, order_with_lines):total=order_with_lines.total,billing_first_name=order_with_lines.billing_address.first_name,billing_last_name=order_with_lines.billing_address.last_name,+ billing_company_name=order_with_lines.billing_address.company_name,billing_address_1=order_with_lines.billing_address.street_address_1,billing_address_2=order_with_lines.billing_address.street_address_2,billing_city=order_with_lines.billing_address.city,