Exemplo n.º 1
0
    def process(self, request, item):
        """Process a PayPal direct payment."""
        from 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)

        try:
            # Create single payment:
            if 'billingperiod' not in params:
                nvp_obj = wpp.doDirectPayment(params)
            # Create recurring payment:
            else:
                if 'profileid' in params:
                    # Updating a payment profile.
                    nvp_obj = wpp.updateRecurringPaymentsProfile(params, direct=True)
                else:
                    # Creating a payment profile.
                    nvp_obj = wpp.createRecurringPaymentsProfile(params, direct=True)
        except PayPalFailure:
            return False
        return True
Exemplo n.º 2
0
from paypal.pro.helpers import PayPalWPP
from paypal.pro.exceptions import PayPalFailure
from paypal.pro.models import PayPalNVP
from users.models import UsersProfile

wpp = PayPalWPP()

user_email = "*****@*****.**"
params = {'expdate': '012024', 'cvv2': u'123', 'acct': u'4032031179702831', 'creditcardtype': 'Visa'}

usr_obj = UsersProfile.objects.get(email=user_email)
paypal_obj = PayPalNVP.objects.filter(user=usr_obj).latest('updated_at')

params['profileid'] = paypal_obj.profileid

nvp_obj = wpp.updateRecurringPaymentsProfile(params)