Skip to content

Commit

Permalink
Fix to make shipping address from data passed from PayPal, per spec
Browse files Browse the repository at this point in the history
Implementing this fix: django-oscar#153
  • Loading branch information
SalahAdDin committed May 21, 2017
1 parent 2c8ce63 commit d3b022c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions paypal/express/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ def get_shipping_address(self, basket):
parts = ship_to_name.split()
if len(parts) == 1:
last_name = ship_to_name
first_name = ''
elif len(parts) > 1:
first_name = parts[0]
last_name = " ".join(parts[1:])
Expand Down Expand Up @@ -408,18 +409,18 @@ def post(self, request, *args, **kwargs):

# Create a shipping address instance using the data passed back
country_code = self.request.POST.get(
'PAYMENTREQUEST_0_SHIPTOCOUNTRY', None)
'SHIPTOCOUNTRY', None)
try:
country = Country.objects.get(iso_3166_1_a2=country_code)
except Country.DoesNotExist:
country = Country()

shipping_address = ShippingAddress(
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', ''),
line1=self.request.POST.get('SHIPTOSTREET', ''),
line2=self.request.POST.get('SHIPTOSTREET2', ''),
line4=self.request.POST.get('SHIPTOCITY', ''),
state=self.request.POST.get('SHIPTOSTATE', ''),
postcode=self.request.POST.get('SHIPTOZIP', ''),
country=country
)
methods = Repository().get_shipping_methods(
Expand Down

0 comments on commit d3b022c

Please sign in to comment.