title: Adding extra parameters when sending request with django and stripe
body: <p>I've been trying to send extra parameters when submiting the stripe button, which is integrated in my Django application, but I cannot make it work.</p>
  
  <p>So far, I have this:</p>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>stripe.api_key = "XXXX"
  
  class StripeApi(View):
      @staticmethod
      def post(request):
          a = request.body
          event_json = json.dumps(a)
          print a
          return HttpResponse(
              event_json, content_type="application/x-javascript-config")
  </code></pre>
  
  <p><strong>urls.py</strong></p>
  
  <pre><code>urlpatterns = [
      url(r'^stripe/', ApiViews.StripeApi.as_view()),
  ]
  </code></pre>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>&lt;form action="" method="POST"&gt;
      &lt;input type="text" name="extraParam2" value="55555fghjkldfgdgfasdfghhjjj"&gt; &lt;!-- here, I tried to add extraParam2 --&gt;
      &lt;script
              src="https://checkout.stripe.com/checkout.js" class="stripe-button"
              data-key="XXXX"
              data-amount="2000"
              data-name="Demo Site"
              data-description="2 widgets ($20.00)"
              data-image="/128x128.png"
              data-locale="auto"&gt;
      &lt;/script&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Any hints on this, please ?</p>
  
  <hr>
  
  <p><strong>//EDIT:</strong></p>
  
  <p>I tried to integrate what Ywain gave me into my app and I get <code>"POST /stripe/ HTTP/1.1" 405 0</code> in console after completing and sending the form. What do I do wrong ?</p>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>class StripeApi(View):
      @staticmethod
      def index(request):
          return HttpResponse(request, 'index.html', {
                                       'stripe_pub_key': settings.STRIPE_PUBLISHABLE_KEY},
                              content_type="application/x-javascript-config")
  
      @staticmethod
      def charge(request):
          charge = stripe.Charge.create(
              amount=2000,
              currency='usd',
              source=request.POST['stripeToken'],
              description='Charge for {}'.format(request.POST['stripeEmail'])
          )
          return HttpResponse(request, 'stripe.html', {'charge_id': charge.id,
                                                       'extra_param': request.POST['extraParam2']},
                              content_type="application/x-javascript-config")
  </code></pre>
  
  <p><strong>settings.py:</strong></p>
  
  <pre><code>'''stripe'''
  
  STRIPE_SECRET_KEY = 'sk_test_secret',
  STRIPE_PUBLISHABLE_KEY = 'pk_test_secret'
  
  stripe.api_key = STRIPE_SECRET_KEY
  </code></pre>
  
  <p><strong>urls.py</strong></p>
  
  <pre><code>...
  url(r'^stripe/', ApiViews.StripeApi.as_view()),
  </code></pre>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>&lt;form action="/stripe/" method="POST"&gt;
      &lt;input type="text" name="extraParam2" value="Test extraParam"&gt;
      &lt;script
          src="https://checkout.stripe.com/checkout.js" class="stripe-button"
          data-key="pk_test_secret"
          data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
          data-name="Stripe.com"
          data-description="2 widgets"
          data-amount="2000"
          data-locale="auto"&gt;
    &lt;/script&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>stripe.html</strong></p>
  
  <pre><code>{% extends "base_site.html" %}
  
  {% block content %}
  &lt;pre&gt;
      Charge ID: {{ charge_id }}
      Extra param: {{ extra_param }}
  &lt;/pre&gt;
  {% endblock %}
  </code></pre>