def post(self, request, *args, **kwargs): # Posting to payment-details isn't the right thing to do. Form # submissions should use the preview URL. if not self.preview: return http.HttpBadRequest() if request.POST.get('action', '') == 'place_order': return self.handle_place_order_submission(request) else: return http.HttpBadRequest()
def handle_place_order_submission(self, request): self.reference_id = self.request.GET.get('reference_id') if not self.reference_id: return http.HttpBadRequest() self.facade = Facade(self.reference_id) confirm_order_response = self.facade.confirm_order_details() return self.facade.fulfill_transaction( self.request.basket.total_incl_tax, settings.AMAZON_PAYMENTS_CURRENCY)
def get(self, *args, **kwargs): self.reference_id = self.request.GET.get('reference_id') if not self.reference_id: return http.HttpBadRequest() self.facade = Facade(self.reference_id) if not self.preview: order_details_response = self.facade.set_order_details( str(self.request.basket.total_incl_tax)) return super(PaymentDetailsView, self).get(*args, **kwargs)
def post(self, request, *args, **kwargs): # Posting to payment-details isn't the right thing to do. Form # submissions should use the preview URL. if not self.preview: return http.HttpBadRequest() # We use a custom parameter to indicate if this is an attempt to place # an order (normally from the preview page). Without this, we assume a # payment form is being submitted from the payment details view. In # this case, the form needs validating and the order preview shown. if request.POST.get('action', '') == 'place_order': return self.handle_place_order_submission(request) return self.handle_payment_details_submission(request)
def post(self, request, *args, **kwargs): orig_txn = self.get_object() if not getattr(settings, 'PAYPAL_PAYFLOW_DASHBOARD_FORMS', False): messages.error(self.request, _("Dashboard actions not permitted")) return http.HttpResponseRedirect( reverse('paypal-payflow-detail', kwargs={'pk': orig_txn.id})) dispatch_map = { 'credit': self.credit, 'void': self.void, 'capture': self.capture, } action = request.POST.get('action', None) if action in dispatch_map: return dispatch_map[action](orig_txn) return http.HttpBadRequest("Unrecognised action")