diff --git a/facturier/views.py b/facturier/views.py index 404d0bd..926dc6a 100644 --- a/facturier/views.py +++ b/facturier/views.py @@ -134,9 +134,13 @@ class TransactionView(DetailView): return context - def invoice_rest_request(self, data_source_url, context): - data = Data(data_source_url, RequestContext(self.request, context), - limit=None, refresh=None) + def invoice_rest_request(self, url_func, context): + data = Data(self.object.slug, {'limit': None, 'refresh': None}, + {'url': url_func(RequestContext(self.request, context)), + 'content_type': 'application/json', + 'parser_type': 'json', + 'slug': 'invoice'}, + context) return data.update_content().get('data').get('invoice') def get_context_data(self, **kwargs): @@ -159,7 +163,8 @@ class TransactionView(DetailView): 'invoice_hash': invoice_hash, 'slug': slug, 'paid': False,}) - invoice_data = self.invoice_rest_request(self.object.get_url, context) + invoice_data = self.invoice_rest_request(self.object.get_invoice_url, + context) invoice.update(invoice_data) # invoice can be overriden by request.GET parameters @@ -243,10 +248,9 @@ class TransactionView(DetailView): logger.debug('payment response: close transaction %s' % event.transaction_id) self.create_event(event.transaction_id, invoice_id, status, response=True, message='response', details=response.__dict__) - update_url = self.object.get_invoice_update_url(context) logger.debug('payment response: update invoice PAID %s -- context %s' % (update_url, context)) - self.invoice_rest_request(update_url, context) + self.invoice_rest_request(self.object.get_invoice_update_url, context) # ok ! logger.debug('payment response: OK invoice %s', invoice_id)