Skip to content

Commit

Permalink
Some improvements in documentation (dj-stripe#1070)
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloCastellano authored and therefromhere committed Dec 7, 2019
1 parent 0dd7925 commit 240a0a6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/usage/restricting_access.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ If you want to quickly constrain a single Class-Based View, the ``djstripe.decor
@method_decorator(login_required)
@method_decorator(subscription_payment_required)
def dispatch(self, *args, **kwargs):
return super(MyConstrainedView, self).dispatch(*args, **kwargs)
return super().dispatch(*args, **kwargs)
If you are unfamiliar with this technique please read the following documentation `here <https://docs.djangoproject.com/en/1.5/topics/class-based-views/intro/#decorating-the-class>`_.
Expand Down
13 changes: 13 additions & 0 deletions docs/usage/subscribing_customers.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
Subscribing a customer to a plan
================================

For your convenience, dj-stripe provides a ``Customer.subscribe()`` method that
will try to charge the customer immediately unless you specify ``charge_immediately=False``

.. code-block:: python
plan = Plan.objects.get(nickname="one_plan")
customer = Customer.objects.first()
customer.subscribe(plan)
However in some cases ``Customer.subscribe()`` might not support all the arguments
you need for your implementation. When this happens you can just call the
official ``stripe.Customer.subscribe()``.

See this example from ``tests.apps.example.views.PurchaseSubscriptionView.form_valid``

.. literalinclude:: ../../tests/apps/example/views.py
Expand Down

0 comments on commit 240a0a6

Please sign in to comment.