{ "info": { "author": "Steven Skoczen", "author_email": "steven@agoodcloud.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Overview\n========\n\nZebra is a library that makes using Stripe with Django even easier.\n\nIt's made of:\n\n* `zebra`, the core library, with forms, webhook handlers, abstract models, mixins, signals, and templatetags that cover most stripe implementations.\n* `marty`, an example app for how to integrate zebra, that also serves as its test suite.\n\nPull requests are quite welcome!\n\n\nUsage\n=====\n\n## Installation ##\n\n1. `pip install django-zebra`\n\n2. Edit your `settings.py:`\n\n\t```\n\tINSTALLED_APPS += (\"zebra\",)\n\tSTRIPE_SECRET = \"YOUR-SECRET-API-KEY\"\n\tSTRIPE_PUBLISHABLE = \"YOUR-PUBLISHABLE-API-KEY\"\n # Set any optional settings (below)\n ```\n\n3. (optional) `./manage.py syncdb` if you have `ZEBRA_ENABLE_APP = True`\n\n4. (optional) Add in the webhook urls:\n\n\t```\n\turlpatterns += patterns('', \n\t\turl(r'zebra/', include('zebra.urls', namespace=\"zebra\", app_name='zebra') ),\n\t)\n\t```\n\n5. Enjoy easy billing.\n\n\n### Optional Settings:\n\n* `ZEBRA_ENABLE_APP` \n\tDefaults to `False`. Enables Customer, Plan, and Subscription django models, as a part of zebra.\n* `ZEBRA_CUSTOMER_MODEL` \n\tThe app+model string for the model that implements the StripeCustomerMixin. ie `\"myapp.MyCustomer\"`. If `ZEBRA_ENABLE_APP` is true, defaults to `\"zebra.Customer\"`. \n* `ZEBRA_AUTO_CREATE_STRIPE_CUSTOMERS` \n\tDefaults to `True`. Automatically creates a stripe customer object on stripe_customer access, if one doesn't exist.\n\n\n## Webhooks ##\n\nZebra handles all the webhooks that stripe sends back and calls a set of signals that you can plug your app into. To use the webhooks:\n\n* Include the zebra urls\n* Update your stripe account to point to your webhook URL (aka https://www.mysite.com/zebra/webhooks)\n* Plug into any webhook signals you care about. \n\n**Note: The initial Stripe webhook system is being deprecated. See below for a description of Zebra's support for the new system.**\n\nZebra provides:\n\n* `zebra_webhook_recurring_payment_failed`\n* `zebra_webhook_invoice_ready`\n* `zebra_webhook_recurring_payment_succeeded`\n* `zebra_webhook_subscription_trial_ending`\n* `zebra_webhook_subscription_final_payment_attempt_failed`\n\nAll of the webhooks provide the same arguments:\n\n* `customer` - if `ZEBRA_CUSTOMER_MODEL` is set, returns an instance that matches the `stripe_customer_id`, or `None`. If `ZEBRA_CUSTOMER_MODEL` is not set, returns `None`.\n* `full_json` - the full json response, parsed with simplejson.\n\n\nSo, for example, to update the customer's new billing date after a successful payment, you could:\n\n(assuming you've set `ZEBRA_CUSTOMER_MODEL` or are using `ZEBRA_ENABLE_APP`):\n\n```\nfrom zebra.signals import zebra_webhook_recurring_payment_succeeded\n\ndef update_last_invoice_date(sender, **kwargs):\n\tcustomer = kwargs.pop(\"customer\", None)\n\tfull_json = kwargs.pop(\"full_json\", None)\n\tcustomer.billing_date = full_json.date\n\tcustomer.save()\n\nzebra_webhook_recurring_payment_succeeded.connect(update_last_invoice_date)\n```\n\n### Webhooks Update ###\n\nStripe recently updated their webhook implementation (see https://stripe.com/blog/webhooks). Zebra includes an implementation of the new system.\n\n* Include the zebra urls\n* Update your stripe account to point to your webhook URL (aka https://www.mysite.com/zebra/webhooks/v2/)\n* Plug into any webhook signals you care about. \n\nZebra provides:\n\n* `zebra_webhook_charge_succeeded`\n* `zebra_webhook_charge_failed`\n* `zebra_webhook_charge_refunded`\n* `zebra_webhook_charge_disputed`\n* `zebra_webhook_customer_created`\n* `zebra_webhook_customer_updated`\n* `zebra_webhook_customer_deleted`\n* `zebra_webhook_customer_subscription_created`\n* `zebra_webhook_customer_subscription_updated`\n* `zebra_webhook_customer_subscription_deleted`\n* `zebra_webhook_customer_subscription_trial_will_end`\n* `zebra_webhook_customer_discount_created`\n* `zebra_webhook_customer_discount_updated`\n* `zebra_webhook_customer_discount_deleted`\n* `zebra_webhook_invoice_created`\n* `zebra_webhook_invoice_updated`\n* `zebra_webhook_invoice_payment_succeeded`\n* `zebra_webhook_invoice_payment_failed`\n* `zebra_webhook_invoiceitem_created`\n* `zebra_webhook_invoiceitem_updated`\n* `zebra_webhook_invoiceitem_deleted`\n* `zebra_webhook_plan_created`\n* `zebra_webhook_plan_updated`\n* `zebra_webhook_plan_deleted`\n* `zebra_webhook_coupon_created`\n* `zebra_webhook_coupon_updated`\n* `zebra_webhook_coupon_deleted`\n* `zebra_webhook_transfer_created`\n* `zebra_webhook_transfer_failed`\n* `zebra_webhook_ping`\n\nZebra also provides an easy map of all the signals as `zebra.signals.WEBHOOK_MAP`, which maps events (`charge_succeeded`) to the Zebra signal (`zebra_webhook_charge_succeeded`). To assign a handler to all the signals that zebra sends, for example, loop over the items in the map:\n\n for event_key, webhook_signal in WEBHOOK_MAP.iteritems():\n webhook_signal.connect(webhook_logger)\n\n\n## Forms ##\n\nThe StripePaymentForm sets up a form with fields like [the official stripe example](https://gist.github.com/1204718#file_stripe_tutorial_page.html).\n\nIn particular, the form is stripped of the name attribute for any of the credit card fields, to prevent accidental submission. Media is also provided to set up stripe.js (it assumes you have jQuery).\n\nUse it in a view like so:\n\n```\nif request.method == 'POST':\n zebra_form = StripePaymentForm(request.POST)\n if zebra_form.is_valid():\n \tmy_profile = request.user.get_profile()\n stripe_customer = stripe.Customer.retrieve(my_profile.stripe_customer_id)\n stripe_customer.card = zebra_form.cleaned_data['stripe_token']\n stripe_customer.save()\n\n my_profile.last_4_digits = zebra_form.cleaned_data['last_4_digits']\n my_profile.stripe_customer_id = stripe_customer.id\n my_profile.save()\n\n # Do something kind for the user\n\nelse:\n zebra_form = StripePaymentForm()\n```\n\n## Template Tags ##\n\nThere are a couple of template tags that take care of setting up the stripe env, and rendering a basic cc update form. Note that it's expected your `StripePaymentForm` is called either `zebra_form` or `form`.\n\nTo use in a template:\n\n```\n{% extends \"base.html\" %}{% load zebra_tags %}\n\n{% block head %}{{block.super}}\n\t{% zebra_head_and_stripe_key %}\n{% endblock %}\n\n{% block content %}\n\t{% zebra_card_form %}\n{% endblock %}\n\n```\n\nThat's it - all the stripe tokeny goodness happens, and errors are displayed to your users.\n\n## Models and Mixins ##\n\nModel and Mixin docs coming. For now, the code is pretty self-explanatory, and decently documented inline.\n\n\n## Other Useful Bits ##\n\nZebra comes with a manage.py command to clear out all the test customers from your account. To use it, run:\n\n```\n./manage.py clear_stripe_test_customers\n```\n\nIt responds to `--verbosity=[0-3]`.\n\n\nCredits\n=======\n\nI did not write any of stripe. It just makes me happy to use, and inspired to make better APIs for my users. For Stripe info, ask them: [stripe.com](http://stripe.com)\n\nCode credits are in the AUTHORS file. Pull requests welcome!\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/GoodCloud/django-zebra", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "django-zebra", "package_url": "https://pypi.org/project/django-zebra/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-zebra/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/GoodCloud/django-zebra" }, "release_url": "https://pypi.org/project/django-zebra/0.4.5/", "requires_dist": null, "requires_python": null, "summary": "Library for Django and Stripe", "version": "0.4.5" }, "last_serial": 1135134, "releases": { "0.4": [ { "comment_text": "", "digests": { "md5": "ff550a95a633a2e3d740ae502e924278", "sha256": "7ad11e03b0bef947f0c92f75bf403ca38aeec490f63b15aa5e23465689717ea9" }, "downloads": -1, "filename": "django-zebra-0.4.macosx-10.4-x86_64.exe", "has_sig": false, "md5_digest": "ff550a95a633a2e3d740ae502e924278", "packagetype": "bdist_wininst", "python_version": "any", "requires_python": null, "size": 77515, "upload_time": "2011-09-26T05:23:41", "url": "https://files.pythonhosted.org/packages/1f/51/2b737e956f4ad0b07cacbd3b7e933ed4ece2138104d29f01d91a04f61bcd/django-zebra-0.4.macosx-10.4-x86_64.exe" }, { "comment_text": "", "digests": { "md5": "a72d3f4724213549eb0db59dd7d7c585", "sha256": "e5996bc791aba852b25a9afe0151516c50ec6a3d88cb1e65b16d4703be678426" }, "downloads": -1, "filename": "django-zebra-0.4.tar.gz", "has_sig": false, "md5_digest": "a72d3f4724213549eb0db59dd7d7c585", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9973, "upload_time": "2011-09-26T04:50:53", "url": "https://files.pythonhosted.org/packages/5b/97/a2f1674d33ae1367f9e51b918dbc5fbf9f8d5fa8972ed2ceef09a2ef9c08/django-zebra-0.4.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "769bdaf127271355f3f09f9c14faa050", "sha256": "a2abee9a05ec07b70400cd639efd5bb506e6b9d75529697a22e1ec7aac415f38" }, "downloads": -1, "filename": "django-zebra-0.4.1.tar.gz", "has_sig": false, "md5_digest": "769bdaf127271355f3f09f9c14faa050", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14694, "upload_time": "2011-09-26T05:25:30", "url": "https://files.pythonhosted.org/packages/ce/0f/cca673a7d0bf356bf6d019c8a1571c57ab0738109d963fa2c9b94d9d59fc/django-zebra-0.4.1.tar.gz" } ], "0.4.2": [ { "comment_text": "", "digests": { "md5": "c73af919d9cf4d4f9652ecc46f328a79", "sha256": "8c32ed43fb5e06f0c3a6f783ab166b7a4e380fd0ace5a7156055f7cb85f8dd2b" }, "downloads": -1, "filename": "django-zebra-0.4.2.tar.gz", "has_sig": false, "md5_digest": "c73af919d9cf4d4f9652ecc46f328a79", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13918, "upload_time": "2011-09-26T05:47:26", "url": "https://files.pythonhosted.org/packages/25/77/de5712e4a45bab55afe81139707252d1f3dd5f003554a9f5944f7cc372b7/django-zebra-0.4.2.tar.gz" } ], "0.4.3": [ { "comment_text": "", "digests": { "md5": "3dce2b436b3e20e345b0d8abd9774c43", "sha256": "57f89ce3823b09918b5076d1d7b7f9934dbe99075a1e6abff2c758c87fb95db7" }, "downloads": -1, "filename": "django-zebra-0.4.3.tar.gz", "has_sig": false, "md5_digest": "3dce2b436b3e20e345b0d8abd9774c43", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15440, "upload_time": "2012-03-05T03:12:02", "url": "https://files.pythonhosted.org/packages/6a/cb/3dc83ff808aa41f2991a6fee9890638c37ed08b0a2b88d08fa0c701f491e/django-zebra-0.4.3.tar.gz" } ], "0.4.4": [ { "comment_text": "", "digests": { "md5": "4d71118111aeb421a21da1496942c8ed", "sha256": "310c1cf38b887c6a39c5af583487f4355d6c4933324ed310bd90cc1c33a3b137" }, "downloads": -1, "filename": "django-zebra-0.4.4.tar.gz", "has_sig": false, "md5_digest": "4d71118111aeb421a21da1496942c8ed", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15522, "upload_time": "2013-11-17T23:17:52", "url": "https://files.pythonhosted.org/packages/69/8c/edaf6c88b3e0cd602dae4cfa0e9e2d04c45eee5b002a3447330db35d9dca/django-zebra-0.4.4.tar.gz" } ], "0.4.5": [ { "comment_text": "", "digests": { "md5": "34aaa0998bdbbfeb7dba40f8429dc379", "sha256": "e26bbe50c9f87efc6349fe5ed6740189c8d45d8dc89d4987901737f5d1bcd1b3" }, "downloads": -1, "filename": "django-zebra-0.4.5.tar.gz", "has_sig": false, "md5_digest": "34aaa0998bdbbfeb7dba40f8429dc379", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15265, "upload_time": "2014-06-23T22:07:58", "url": "https://files.pythonhosted.org/packages/cd/85/a8b4ca3aba4a87bbe3e713592e45afac704dda83d96ed18689f30300d418/django-zebra-0.4.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "34aaa0998bdbbfeb7dba40f8429dc379", "sha256": "e26bbe50c9f87efc6349fe5ed6740189c8d45d8dc89d4987901737f5d1bcd1b3" }, "downloads": -1, "filename": "django-zebra-0.4.5.tar.gz", "has_sig": false, "md5_digest": "34aaa0998bdbbfeb7dba40f8429dc379", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15265, "upload_time": "2014-06-23T22:07:58", "url": "https://files.pythonhosted.org/packages/cd/85/a8b4ca3aba4a87bbe3e713592e45afac704dda83d96ed18689f30300d418/django-zebra-0.4.5.tar.gz" } ] }