Stripe is creating customers when charge declined
<p>For some reason when some one charges to sign up to the subscription plan if their card is declined stripe is still creating the customer.</p>

<p>I'm not particularly sure why this is happening since I am creating the customer with the charge, how do I make it so if some one signs up but their card does not go through stripe doesn't make them a customer?</p>

<p>Here is my code</p>

<pre><code>import stripe


@app.route('/stripe/charge', methods=['POST'])
def stripe_charge():
    data = json.loads(request.data)
    user = data['user']
    source = data['stripeToken'] # obtained from Stripe.js
    try:
        customer = stripe.Customer.create(
            source=source,
            plan="gold5",
            email=email,
        )
    except stripe.CardError, e:
        return jsonify(error="%s" % e)
    return jsonify(customer)
</code></pre>

<p>Are you sure its a <code>CardError</code> that would be thrown?  Try doing a general <code>Exception</code>, see what error gets thrown when the card is bad.  Also their API docs don't actually say an error will be thrown if the card is declined:</p>

<blockquote>
  <p>If an invoice payment is due and a source is not provided, the call will raise an error. If a non-existent plan or a non-existent or expired coupon is provided, the call will raise an error.</p>
</blockquote>

<p><a href="https://stripe.com/docs/api?lang=python#create_customer" rel="nofollow">https://stripe.com/docs/api?lang=python#create_customer</a></p>

python flask stripe-payments