From d3b022cba2ef92e27fcb41bd524baeeab6350093 Mon Sep 17 00:00:00 2001 From: SalahAdDin Date: Sun, 21 May 2017 15:55:57 +0300 Subject: [PATCH] Fix to make shipping address from data passed from PayPal, per spec Implementing this fix: https://github.com/django-oscar/django-oscar-paypal/pull/153 --- paypal/express/views.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/paypal/express/views.py b/paypal/express/views.py index 67f19608..261614a2 100644 --- a/paypal/express/views.py +++ b/paypal/express/views.py @@ -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:]) @@ -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(