Ha, I had no idea that the library that was recommended to me by a NYer was written by one of our own Nashvillians. Patrick, the library is great and my problem is more about me being a newb than how it works. I've never incorporated a payment portal before so I'm a babe in the woods.
I had no problems following the installation docs. I needed to make a few changes since my project is on django 1.5 but they were minimal (I've changed direct_to_template references to TemplateView's and put quotes around templates using {% url 'name' %}). I've changed references from django.contrib.auth.models.User to my custom User object since I'm not using a username field. I don't know if any of those customizations could be causing my problems but I don't think so. I get further downstream.
After running 'python manage.py init_plans' and 'python manage.py init_customers', I think my data is ok. My plan appears on Stripe. I couldn't figure out how to make a subscription plan that wasn't a full integer dollar amount. Does it have to be an integer? I've been trying to make the plan $3.99. My first try at init_plans said that price needed to be a non-negative integer in cents. I tried 399 thinking that it'd be 399 cents but the plan was created for $399 a month. I'm sure I'm doing something dumb there so I'll figure it out. Lastly, running init_customers worked like a charm. My existing [test] customers had Customer records created for them.
When I go to localhost:8000/payments/subscribe/ , I see my plan in the drop down and that's all that is visible in the form. Your documentation says that
The included templates have been tested to work with Checkout.. Being new, I wasn't sure what I was supposed to do next. When I selected my plan and clicked Subscribe, I got some json back that contained an error string: "
Empty string given for card. You should supply either a token or full card details. To learn more about collecting payment information as a token, see: https://stripe.com/docs/tutorials/cards". Seeing that led me to understand that I needed to implement Checkout myself. I found the code to do so on
https://stripe.com/docs/tutorials/checkout.
Where I got more confused was on putting Checkout into the templates. I figured I'd just add the Checkout js inside the <form> element on _subscribe_form.js. I added it on the line below {{ form|as_bootstrap }}. Adding that gets me the blue Pay with Card button and form from Stripe. Selecting my plan and entering the test data that Stripe recommends submits and I get to the /payments/a/subscribe/ call. The json data on the screen shows "
Empty string given for card. You should supply either a token or full card details. To learn more about collecting payment information as a token, see: https://stripe.com/docs/tutorials/cards" still. Stripe's docs say "
a hidden input called stripeToken
will be appended to the form when a token is created" so I realized that your form already had that field in there.
I removed that field from your form since it was being added by Checkout separately. That gets me a little further. Now I get an
AttributeError at /payments/a/subscribe/
'NoneType' object has no attribute 'fingerprint'
error. In trying to track down that problem, I think the relevant traceback is:
File "/Users/donrosszx/mysite/payments/views.py" in subscribe
90. customer.update_card(request.POST.get("stripe_token"))
File "/Users/donrosszx/mysite/payments/models.py" in update_card
352. self.card_fingerprint = cu.active_card.fingerprint
In views.py, the request has a stripe token (I think): u'stripeToken': [u'tok_1Zk6AmQ1nh3uWj'] appears.
In models.py, update_card method, the Customer object being updated is the right user (me: donr...@gmail.com). Unfortunately, token is None and cu.active_card is null.
Now I'm not sure where to go from here. Sorry that this is so wordy and likely represents a newbie's inability to troubleshoot correctly. It took 20 mins to type, 5 mins for you guys to read but would probably only take me and a coach a few minutes to get to the bottom of it. That's why I'm looking to hire some help.
Any thoughts on where I'm going wrong?
DR