title: InvalidRequestError: This customer has no attached payment source
body: <p>I've been following the Quickstart guides from Stripe.</p>
  
  <p><a href="https://stripe.com/docs/quickstart" rel="nofollow noreferrer">https://stripe.com/docs/quickstart</a></p>
  
  <p><a href="https://stripe.com/docs/subscriptions/quickstart" rel="nofollow noreferrer">https://stripe.com/docs/subscriptions/quickstart</a></p>
  
  <p>This is what my form looks like:</p>
  
  <pre><code>&lt;form id="register-form" method="post"&gt;
      {% csrf_token %}
      {% for field in registration_form %}
          &lt;p&gt;{{ field }}&lt;/p&gt;
          {% if field.errors %}
              &lt;p class="text-danger"&gt;{{ field.errors.as_text|cut:"* "|escape }}&lt;/p&gt;
          {% endif %} 
      {% endfor %}
      {% if registration_form.non_field_errors %}
          &lt;p class="text-danger"&gt;{{ registration_form.non_field_errors.as_text|cut:"* "|escape }}&lt;/p&gt;
      {% endif %}
      &lt;div id="stripe-wrapper"&gt;
          &lt;p id="card-element"&gt;&lt;/p&gt;
      &lt;/div&gt;                  
      &lt;p id="card-errors" role="alert"&gt;&lt;/p&gt;
      &lt;button id="register-btn" class="btn btn-primary" type="submit"&gt;Register&lt;/button&gt;
  
      &lt;script type="text/javascript"&gt;
          var displayError=   document.getElementById('card-errors');
          var stripe=         Stripe("pk_test_BjhejGz5DZNcSHUVaqoipMtF");
          var elements=       stripe.elements();
  
          var style=      {
              base: {
                  fontSize: "1.1875rem",
                  fontSmoothing: "always",
                  fontWeight: "600"
              }
          };
  
          var card=   elements.create("card",{style:style});
          card.mount("#card-element");
          card.addEventListener('change', function(event) {
  
              if (event.error) {
                  displayError.textContent = event.error.message;
              } else {
                  displayError.textContent = '';
              }
          });
  
          var formID= "register-form";
          var form=   document.getElementById(formID);
          form.addEventListener("submit",function(event){
              event.preventDefault();
  
              stripe.createToken(card).then(function(result){
                  if(result.error) {
                      displayError.textContent=   result.error.message;
                  } else {
                      stripeTokenHandler(result.token, formID);
                  }                               
              })
          });
          // tut https://stripe.com/docs/stripe-js/elements/quickstart#create-form
          function stripeTokenHandler(token, formID) {
              // Insert the token ID into the form so it gets submitted to the server
              var form = document.getElementById(formID);
              var hiddenInput = document.createElement('input');
              hiddenInput.setAttribute('type', 'hidden');
              hiddenInput.setAttribute('name', 'stripeToken');
              hiddenInput.setAttribute('value', token.id);
              form.appendChild(hiddenInput);
              // Submit the form
              form.submit();
          }
      &lt;/script&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Then my <code>views.py</code> has this:</p>
  
  <pre><code>if registration_form.is_valid():
      stripe.api_key= "sk_test_8rdFokhVsbsJJysHeKgyrMTc"
      stripeCustomer= stripe.Customer.create(
          email=request.POST["username"],
      )
      subscription=   stripe.Subscription.create(
          customer=stripeCustomer["id"],
          items=[{"plan":"plan_CLFfBrRAKl7TRt"}],
      )
  </code></pre>
  
  <p>This gives me an error:</p>
  
  <pre><code>Internal Server Error: /login-register/
  Traceback (most recent call last):
    File "/home/myUserName/myDjangoProjectWithStripe/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 42, in inner
      response = get_response(request)
    File "/home/myUserName/myDjangoProjectWithStripe/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
      response = self._get_response(request)
    File "/home/myUserName/myDjangoProjectWithStripe/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 178, in _get_response
      response = middleware_method(request, callback, callback_args, callback_kwargs)
    File "/home/myUserName/myDjangoProjectWithStripe/local/lib/python2.7/site-packages/mezzanine/pages/middleware.py", line 98, in process_view
      return view_func(request, *view_args, **view_kwargs)
    File "/home/myUserName/myDjangoProjectWithStripe/product_blog/theme/views.py", line 154, in login_register
      items=[{"plan":"plan_CLFfBrRAKl7TRt"}],
    File "/home/myUserName/myDjangoProjectWithStripe/local/lib/python2.7/site-packages/stripe/api_resources/subscription.py", line 33, in create
      return super(Subscription, cls).create(**params)
    File "/home/myUserName/myDjangoProjectWithStripe/local/lib/python2.7/site-packages/stripe/api_resources/abstract/createable_api_resource.py", line 17, in create
      response, api_key = requestor.request('post', url, params, headers)
    File "/home/myUserName/myDjangoProjectWithStripe/local/lib/python2.7/site-packages/stripe/api_requestor.py", line 153, in request
      resp = self.interpret_response(rbody, rcode, rheaders)
    File "/home/myUserName/myDjangoProjectWithStripe/local/lib/python2.7/site-packages/stripe/api_requestor.py", line 365, in interpret_response
      self.handle_error_response(rbody, rcode, resp.data, rheaders)
    File "/home/myUserName/myDjangoProjectWithStripe/local/lib/python2.7/site-packages/stripe/api_requestor.py", line 178, in handle_error_response
      raise err
  InvalidRequestError: Request req_o39ceLlhtpJmmr: This customer has no attached payment source
  </code></pre>
  
  <p>How do I attach a payment source to the customer? Since I'm testing, I use the testing credit card, which has the number <code>4242 4242 4242 4242</code>.</p>