diff --git a/docs/reference/actions.md b/docs/reference/actions.md index 82237533d..ad1dd8139 100644 --- a/docs/reference/actions.md +++ b/docs/reference/actions.md @@ -348,6 +348,7 @@ Args: source for the customer, otherwise the current default source will be used - coupon: if provided, a coupon to apply towards the subscription +- tax_percent: if provided, add percentage as tax Returns: the `pinax.stripe.models.Subscription` object that was created @@ -462,4 +463,4 @@ Updates the status of a `pinax.stripe.models.Transfer` object from Stripe API Args: -- transfer: a `pinax.stripe.models.Transfer` object to update \ No newline at end of file +- transfer: a `pinax.stripe.models.Transfer` object to update diff --git a/docs/user-guide/settings.md b/docs/user-guide/settings.md index dc12419b2..acaa9bb05 100644 --- a/docs/user-guide/settings.md +++ b/docs/user-guide/settings.md @@ -72,6 +72,15 @@ active subscription if the `pinax.stripe.middleware.ActiveSubscriptionMiddleware is installed. +### PINAX_STRIPE_SUBSCRIPTION_TAX_PERCENT + +Defaults to `None` + +If you wish to charge tax on a subscription, set this value to an integer +specifying the percentage of tax required (i.e. 10% would be '10'). This is +used by `pinax.stripe.views.SubscriptionCreateView` + + ## Stripe Account Settings Panel ![](images/stripe-account-panel.png) diff --git a/pinax/stripe/actions/subscriptions.py b/pinax/stripe/actions/subscriptions.py index c36a6895b..271de2a3c 100644 --- a/pinax/stripe/actions/subscriptions.py +++ b/pinax/stripe/actions/subscriptions.py @@ -23,7 +23,7 @@ def cancel(subscription, at_period_end=True): sync_subscription_from_stripe_data(subscription.customer, sub) -def create(customer, plan, quantity=None, trial_days=None, token=None, coupon=None): +def create(customer, plan, quantity=None, trial_days=None, token=None, coupon=None, tax_percent=None): """ Creates a subscription for the given customer @@ -37,6 +37,7 @@ def create(customer, plan, quantity=None, trial_days=None, token=None, coupon=No source for the customer, otherwise the current default source will be used coupon: if provided, a coupon to apply towards the subscription + tax_percent: if provided, add percentage as tax Returns: the data representing the subscription object that was created @@ -53,6 +54,7 @@ def create(customer, plan, quantity=None, trial_days=None, token=None, coupon=No subscription_params["plan"] = plan subscription_params["quantity"] = quantity subscription_params["coupon"] = coupon + subscription_params["tax_percent"] = tax_percent resp = cu.subscriptions.create(**subscription_params) return sync_subscription_from_stripe_data(customer, resp) diff --git a/pinax/stripe/conf.py b/pinax/stripe/conf.py index 5ecb8faed..b2f0c7b26 100644 --- a/pinax/stripe/conf.py +++ b/pinax/stripe/conf.py @@ -37,6 +37,7 @@ class PinaxStripeAppConf(AppConf): SEND_EMAIL_RECEIPTS = True SUBSCRIPTION_REQUIRED_EXCEPTION_URLS = [] SUBSCRIPTION_REQUIRED_REDIRECT = None + SUBSCRIPTION_TAX_PERCENT = None class Meta: prefix = "pinax_stripe" diff --git a/pinax/stripe/views.py b/pinax/stripe/views.py index 537e09410..a70390188 100644 --- a/pinax/stripe/views.py +++ b/pinax/stripe/views.py @@ -11,6 +11,7 @@ import stripe from .actions import events, exceptions, customers, subscriptions, sources +from .conf import settings from .forms import PlanForm, PaymentMethodForm from .mixins import LoginRequiredMixin, CustomerMixin, PaymentsContextMixin from .models import Invoice, Card, Subscription @@ -102,12 +103,16 @@ class SubscriptionCreateView(LoginRequiredMixin, PaymentsContextMixin, CustomerM template_name = "pinax/stripe/subscription_create.html" form_class = PlanForm + @property + def tax_percent(self): + return settings.PINAX_STRIPE_SUBSCRIPTION_TAX_PERCENT + def set_customer(self): if self.customer is None: self._customer = customers.create(self.request.user) def subscribe(self, customer, plan, token): - subscriptions.create(customer, plan, token=token) + subscriptions.create(customer, plan, token=token, tax_percent=self.tax_percent) def form_valid(self, form): self.set_customer()