title: Recurring payments using Stripe and Django
body: <p>I'm still pretty new to Django and am trying to set up recurring payments via Stripe. I'm using Django 2.0 and have successfully set up a single charge test case. However, I'm unfamiliar with how to create recurring payments, and require it for the project I'm working on.</p>
  
  <p>For the single payment, I have the following:</p>
  
  <p><b> Views </b></p>
  
  <pre><code>stripe.api_key = settings.STRIPE_SECRET_KEY
  
  def checkout(request):
      """Stripe check out"""
  
      new_tier = models.PaymentTier(
          level = "Tier 3",
          year = 2018
      )
  
      if request.method == "POST":
          token = request.POST.get("stripeToken")
      try:
          charge = stripe.Charge.create(
              amount = 2000,
              currency = "usd",
              source = token,
              description = "Tier 3 subscription for Elite Fitness"
          )
  
          new_tier.charge_id = charge.id
  
      except stripe.error.CardError as ce:
          return False, ce
  
      else:
          new_tier.save()
          return redirect("thank_you_page")
  
  
  
  def payment_form(request):
      """Render stripe payment form template"""
  
      context = {"stripe_key": settings.STRIPE_PUBLIC_KEY}
      return render(request, "stripe-template.html", context)
  
  
  
  
  def thank_you_page(request):
      """Successful payment processed"""
  
      return render(request,'thank_you_page.html')
  </code></pre>
  
  <p><b> stripe-template.html </b></p>
  
  <pre><code>&lt;form action="checkout/" method="POST"&gt; {% csrf_token %}
      &lt;script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
          data-key={{stripe_key}} # Make sure to wrap the variable name with double {}
          data-amount="2000"
          data-name="company name here"
          data-description="Elite Fitness Subscription"
          data-image="picture.png"
          data-currency="usd"&gt;
      &lt;/script&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I've had a difficult time finding anything online which covers recurring payments specifically. If anybody knows how to set them up (even through <code>dj-stripe</code> or <code>pinax</code>) any help will be very greatly appreciated.</p>