Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Purchasing from Hong Kong #100

Closed
st8st8 opened this issue Jun 5, 2015 · 2 comments
Closed

Purchasing from Hong Kong #100

st8st8 opened this issue Jun 5, 2015 · 2 comments
Labels

Comments

@st8st8
Copy link

st8st8 commented Jun 5, 2015

Hong Kong has no postal codes, so when Django Oscar Paypal calls back into Oscar from a purchase made by a Hong Kong user, I get this error.

Internal Server Error: /checkout/paypal/place-order/490/
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 111, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py", line 69, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/oscar/apps/checkout/session.py", line 68, in dispatch
    request, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py", line 87, in dispatch
    return handler(request, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/paypal/express/views.py", line 281, in post
    return self.submit(**submission)
  File "/usr/local/lib/python2.7/dist-packages/oscar/apps/checkout/views.py", line 632, in submit
    shipping_charge, billing_address, order_total, **order_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/oscar/apps/checkout/mixins.py", line 113, in handle_order_placement
    billing_address=billing_address, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/oscar/apps/checkout/mixins.py", line 125, in place_order
    shipping_address = self.create_shipping_address(user, shipping_address)
  File "/usr/local/lib/python2.7/dist-packages/oscar/apps/checkout/mixins.py", line 161, in create_shipping_address
    shipping_address.save()
  File "/usr/local/lib/python2.7/dist-packages/oscar/apps/address/abstract_models.py", line 250, in save
    super(AbstractAddress, self).save(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 589, in save
    force_update=force_update, update_fields=update_fields)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 617, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 698, in _save_table
    result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 731, in _do_insert
    using=using, raw=raw)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 92, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 921, in _insert
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 920, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 134, in execute
    six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 129, in execute
    return self.cursor.execute(query, args)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
IntegrityError: (1048, "Column 'postcode' cannot be null")
@maiksprenger
Copy link
Member

Oscar has blank=True set for postcodes, so it doesn't require them. My best guess is that instead of the empty string, django-oscar-paypal passes None for the postcode.
Either way, this is a bug and I'd happily accept a pull request for it.

maiksprenger added a commit that referenced this issue Nov 8, 2015
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.
@maiksprenger
Copy link
Member

@st8st8 I got the chance to add a commit to #113 that, if my analysis is correct, should fix your issue. This will be merged and released next week.

So I'm closing the issue; please re-open if the issue still persists. Thanks again for reporting.

maiksprenger added a commit that referenced this issue Nov 8, 2015
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants