Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: b5bebf2a9e
Fetching contributors…

Cannot retrieve contributors at this time

51 lines (39 sloc) 1.841 kb
import logging
from django import forms
from django.utils.translation import ugettext as _
from payment import signals
from payment.forms import SimplePayShipForm
from import Contact
from import Cart, Order, OrderPayment
from models import StripeToken
from signals_ahoy.signals import form_presave, form_postsave
log = logging.getLogger('payment.stripe.forms')
class StripePayShipForm(SimplePayShipForm):
stripe_token = forms.CharField(max_length=50, widget=forms.HiddenInput({"value":""}))
credit_number = forms.CharField(required=False)
def __init__(self, request, paymentmodule, *args, **kwargs):
super(StripePayShipForm, self).__init__(request, paymentmodule, *args, **kwargs)
self.tempCart = Cart.objects.from_request(request)
self.the_token = None
self.tempContact = Contact.objects.from_request(request)
except Contact.DoesNotExist:
self.tempContact = None
def clean_stripe_token(self):
if len(self.cleaned_data['stripe_token']) == 0:
raise forms.ValidationError(_('Invalid Stripe Token'))
return self.cleaned_data['stripe_token']
def save(self, request, cart, contact, payment_module, data=None):
form_presave.send(StripePayShipForm, form=self)
if data is None:
data = self.cleaned_data
super(StripePayShipForm, self).save(request, cart, contact, payment_module, data=data)
if self.orderpayment:
op = self.orderpayment.capture
token = StripeToken(
payment_token = data['stripe_token'],)
self.the_token = token
form_postsave.send(StripePayShipForm, form=self)
Jump to Line
Something went wrong with that request. Please try again.