Skip to content

Commit

Permalink
Create ShippingAddresses with empty strings instead of None
Browse files Browse the repository at this point in the history
ShippingAddress fields don't allow setting None (null=False), so for
missing values we should set empty strings instead.

If my analysis is correct, this fixes #100. If it doesn't, it's still a
correct change.
  • Loading branch information
maiksprenger committed Nov 8, 2015
1 parent a9ece08 commit 9db7991
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ Changelog
* Display original Paypal error message instead of generic error message. `#101`_
* Bugfix: Hide form buttons as expected. `#94`_
* Bugfix: Correct signature for call to ``get_shipping_methods``. `#99`_
* Bugfix: Don't fail in countries without postcode. `#100`_

.. _`#94`: https://github.com/django-oscar/django-oscar-paypal/pull/94
.. _`#99`: https://github.com/django-oscar/django-oscar-paypal/issues/99
.. _`#100`: https://github.com/django-oscar/django-oscar-paypal/issues/100
.. _`#101`: https://github.com/django-oscar/django-oscar-paypal/pull/101
.. _`#107`: https://github.com/django-oscar/django-oscar-paypal/pull/107

Expand Down
12 changes: 6 additions & 6 deletions paypal/express/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def get_shipping_address(self, basket):
line2=self.txn.value('PAYMENTREQUEST_0_SHIPTOSTREET2', default=""),
line4=self.txn.value('PAYMENTREQUEST_0_SHIPTOCITY', default=""),
state=self.txn.value('PAYMENTREQUEST_0_SHIPTOSTATE', default=""),
postcode=self.txn.value('PAYMENTREQUEST_0_SHIPTOZIP'),
postcode=self.txn.value('PAYMENTREQUEST_0_SHIPTOZIP', default=""),
country=Country.objects.get(iso_3166_1_a2=self.txn.value('PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'))
)

Expand Down Expand Up @@ -415,11 +415,11 @@ def post(self, request, *args, **kwargs):
country = Country()

shipping_address = ShippingAddress(
line1=self.request.POST.get('PAYMENTREQUEST_0_SHIPTOSTREET', None),
line2=self.request.POST.get('PAYMENTREQUEST_0_SHIPTOSTREET2', None),
line4=self.request.POST.get('PAYMENTREQUEST_0_SHIPTOCITY', None),
state=self.request.POST.get('PAYMENTREQUEST_0_SHIPTOSTATE', None),
postcode=self.request.POST.get('PAYMENTREQUEST_0_SHIPTOZIP', None),
line1=self.request.POST.get('PAYMENTREQUEST_0_SHIPTOSTREET', ''),
line2=self.request.POST.get('PAYMENTREQUEST_0_SHIPTOSTREET2', ''),
line4=self.request.POST.get('PAYMENTREQUEST_0_SHIPTOCITY', ''),
state=self.request.POST.get('PAYMENTREQUEST_0_SHIPTOSTATE', ''),
postcode=self.request.POST.get('PAYMENTREQUEST_0_SHIPTOZIP', ''),
country=country
)
methods = Repository().get_shipping_methods(
Expand Down

0 comments on commit 9db7991

Please sign in to comment.