summaryrefslogtreecommitdiff
path: root/payments
diff options
context:
space:
mode:
authorAdam Bogdał <adam@bogdal.pl>2015-12-04 14:51:34 +0100
committerAdam Bogdał <adam@bogdal.pl>2015-12-04 14:51:34 +0100
commit3857129fa271e265338d7843dea580506b393883 (patch)
tree97941b5cc5040d66bc921e10408551c057431bb1 /payments
parent8e081ada1c4051b84c891a3de70e568023466832 (diff)
downloaddjango-payments-taler-3857129fa271e265338d7843dea580506b393883.tar.gz
django-payments-taler-3857129fa271e265338d7843dea580506b393883.tar.bz2
django-payments-taler-3857129fa271e265338d7843dea580506b393883.zip
Get links from the paypal card response
Diffstat (limited to 'payments')
-rw-r--r--payments/paypal/__init__.py12
-rw-r--r--payments/paypal/forms.py1
2 files changed, 7 insertions, 6 deletions
diff --git a/payments/paypal/__init__.py b/payments/paypal/__init__.py
index 8a0da22..228bc3a 100644
--- a/payments/paypal/__init__.py
+++ b/payments/paypal/__init__.py
@@ -81,7 +81,11 @@ class PaypalProvider(BasicProvider):
(link['rel'], link) for link in response['links'])
payment.extra_data = json.dumps(extra_data)
- def set_response_links(self, payment, links):
+ def set_response_links(self, payment, response):
+ transaction = response['transactions'][0]
+ related_resources = transaction['related_resources'][0]
+ resource_key = 'sale' if self._capture else 'authorization'
+ links = related_resources[resource_key]['links']
extra_data = json.loads(payment.extra_data or '{}')
extra_data['links'] = dict((link['rel'], link) for link in links)
payment.extra_data = json.dumps(extra_data)
@@ -222,11 +226,7 @@ class PaypalProvider(BasicProvider):
else:
return redirect(success_url)
executed_payment = self.execute_payment(payment, payer_id)
- transaction = executed_payment['transactions'][0]
- related_resources = transaction['related_resources'][0]
- resource_key = 'sale' if self._capture else 'authorization'
- authorization_links = related_resources[resource_key]['links']
- self.set_response_links(payment, authorization_links)
+ self.set_response_links(payment, executed_payment)
payment.attrs.payer_info = executed_payment['payer']['payer_info']
if self._capture:
payment.captured_amount = payment.total
diff --git a/payments/paypal/forms.py b/payments/paypal/forms.py
index 8cda756..0a77205 100644
--- a/payments/paypal/forms.py
+++ b/payments/paypal/forms.py
@@ -34,6 +34,7 @@ class PaymentForm(CreditCardPaymentFormWithName):
self.payment.change_status('error')
else:
self.payment.transaction_id = data['id']
+ self.provider.set_response_links(self.payment, data)
if self.provider._capture:
self.payment.captured_amount = self.payment.total
self.payment.change_status('confirmed')