Exemplo n.º 1
0
 def redirect_to_express(self):
     """
     First step of ExpressCheckout. Redirect the request to PayPal using the 
     data returned from setExpressCheckout.
     """
     wpp = PayPalWPP(self.request)
     nvp_obj = wpp.setExpressCheckout(self.item)
     if not nvp_obj.flag:
         pp_params = dict(token=nvp_obj.token, AMT=self.item['amt'], 
                          RETURNURL=self.item['returnurl'], 
                          CANCELURL=self.item['cancelurl'])
         pp_url = self.get_endpoint() % urlencode(pp_params)
         return HttpResponseRedirect(pp_url)
     else:
         self.context['errors'] = self.errors['paypal']
         return self.render_payment_form()
Exemplo n.º 2
0
 def redirect_to_express(self):
     """
     First step of ExpressCheckout. Redirect the request to PayPal using the 
     data returned from setExpressCheckout.
     """
     wpp = PayPalWPP(self.request)
     nvp_obj = wpp.setExpressCheckout(self.item)
     if not nvp_obj.flag:
         pp_params = dict(token=nvp_obj.token,
                          AMT=self.item['amt'],
                          RETURNURL=self.item['returnurl'],
                          CANCELURL=self.item['cancelurl'])
         pp_url = self.get_endpoint() % urlencode(pp_params)
         return HttpResponseRedirect(pp_url)
     else:
         self.context['errors'] = self.errors['paypal']
         return self.render_payment_form()
Exemplo n.º 3
0
    def process(self, request, item):
        """Do a direct payment."""
        from vendor.paypal.pro.helpers import PayPalWPP
        wpp = PayPalWPP(request)

        # Change the model information into a dict that PayPal can understand.
        params = model_to_dict(self, exclude=self.ADMIN_FIELDS)
        params['acct'] = self.acct
        params['creditcardtype'] = self.creditcardtype
        params['expdate'] = self.expdate
        params['cvv2'] = self.cvv2
        params.update(item)

        # Create recurring payment:
        if 'billingperiod' in params:
            return wpp.createRecurringPaymentsProfile(params, direct=True)
        # Create single payment:
        else:
            return wpp.doDirectPayment(params)
Exemplo n.º 4
0
    def process(self, request, item):
        """Do a direct payment."""
        from vendor.paypal.pro.helpers import PayPalWPP
        wpp = PayPalWPP(request)

        # Change the model information into a dict that PayPal can understand.        
        params = model_to_dict(self, exclude=self.ADMIN_FIELDS)
        params['acct'] = self.acct
        params['creditcardtype'] = self.creditcardtype
        params['expdate'] = self.expdate
        params['cvv2'] = self.cvv2
        params.update(item)      

        # Create recurring payment:
        if 'billingperiod' in params:
            return wpp.createRecurringPaymentsProfile(params, direct=True)
        # Create single payment:
        else:
            return wpp.doDirectPayment(params)
Exemplo n.º 5
0
    def process(self, request, item):
        """Process a PayPal direct payment."""
        from vendor.paypal.pro.helpers import PayPalWPP
        wpp = PayPalWPP(request) 
        params = self.cleaned_data
        params['creditcardtype'] = self.fields['acct'].card_type
        params['expdate'] = self.cleaned_data['expdate'].strftime("%m%Y")
        params['ipaddress'] = request.META.get("REMOTE_ADDR", "")
        params.update(item)
 
        # Create single payment:
        if 'billingperiod' not in params:
            response = wpp.doDirectPayment(params)

        # Create recurring payment:
        else:
            response = wpp.createRecurringPaymentsProfile(params, direct=True)
 
        return response
Exemplo n.º 6
0
    def process(self, request, item):
        """Process a PayPal direct payment."""
        from vendor.paypal.pro.helpers import PayPalWPP
        wpp = PayPalWPP(request)
        params = self.cleaned_data
        params['creditcardtype'] = self.fields['acct'].card_type
        params['expdate'] = self.cleaned_data['expdate'].strftime("%m%Y")
        params['ipaddress'] = request.META.get("REMOTE_ADDR", "")
        params.update(item)

        # Create single payment:
        if 'billingperiod' not in params:
            response = wpp.doDirectPayment(params)

        # Create recurring payment:
        else:
            response = wpp.createRecurringPaymentsProfile(params, direct=True)

        return response
Exemplo n.º 7
0
    def validate_confirm_form(self):
        """
        Third and final step of ExpressCheckout. Request has pressed the confirmation but
        and we can send the final confirmation to PayPal using the data from the POST'ed form.
        """
        wpp = PayPalWPP(self.request)
        pp_data = dict(token=self.request.POST['token'], payerid=self.request.POST['PayerID'])
        self.item.update(pp_data)
        
        # @@@ This check and call could be moved into PayPalWPP.
        if self.is_recurring():
            success = wpp.createRecurringPaymentsProfile(self.item)
        else:
            success = wpp.doExpressCheckoutPayment(self.item)

        if success:
            payment_was_successful.send(sender=self.item)
            return HttpResponseRedirect(self.success_url)
        else:
            self.context['errors'] = self.errors['processing']
            return self.render_payment_form()
Exemplo n.º 8
0
    def validate_confirm_form(self):
        """
        Third and final step of ExpressCheckout. Request has pressed the confirmation but
        and we can send the final confirmation to PayPal using the data from the POST'ed form.
        """
        wpp = PayPalWPP(self.request)
        pp_data = dict(token=self.request.POST['token'],
                       payerid=self.request.POST['PayerID'])
        self.item.update(pp_data)

        # @@@ This check and call could be moved into PayPalWPP.
        if self.is_recurring():
            success = wpp.createRecurringPaymentsProfile(self.item)
        else:
            success = wpp.doExpressCheckoutPayment(self.item)

        if success:
            payment_was_successful.send(sender=self.item)
            return HttpResponseRedirect(self.success_url)
        else:
            self.context['errors'] = self.errors['processing']
            return self.render_payment_form()