Stripe, Webhooks and dj-stripe

Stripe is great for working with payments. Webhooks and dj-stripe make it even better, in this video learn how to use stripe webhooks with your application to get the most out of your stripe integration.

resources

subscribe.html

{% block content %}
<div class="row">
    {% if not user.customer.has_active_subscription %}
    ...
    {% else %}
    Can Charge: {{ user.customer.can_charge }}<br />
    Card Kind: {{ user.customer.card_kind }}<br />
    Card Last 4: {{ user.customer.card_last_4 }}
    {% endif %}
</div>
{% endblock %}
urls.py
from django.conf.urls import patterns, include, url
from django.contrib import admin

urlpatterns = patterns(
    '',
    url(r'^store/', include('store.urls')),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^stripe/', include('djstripe.urls', namespace='djstripe')),
)
views.py
from django.dispatch import receiver

from djstripe.signals import WEBHOOK_SIGNALS


@receiver(WEBHOOK_SIGNALS['customer.subscription.deleted'])
def subscription_deleted(sender, **kwargs):
    print 'canceled'
comments powered by Disqus