Esempio n. 1
0
 def clean(self):
     
     cleaned = super(SubscriptionPaymentForm, self).clean()
     
     if not self.errors:
         number = self.cleaned_data["number"]
         exp_month = self.cleaned_data["expiration"].month
         exp_year = self.cleaned_data["expiration"].year
         cvc = self.cleaned_data["cvc"]
         sale = Sale()
         
         # let's subscribe a user to our Gold Plan for this particular item
         success, instance = sale.subscribe(number, exp_month, exp_year, cvc)
         
         if not success:
             raise forms.ValidationError("Error: %s" % instance.message)
         else:
             #instance.save()
             # we were successful! do whatever you will here... 
             # perhaps you'd like to send an email...
             pass
     
     return cleaned