cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Pulling Data From Stripe to Databricks using the Webhook

190809
Contributor

I am doing some investigation in how to connect Databricks and Stripe. Stirpe has really good documentation and I have decided to set up a webhook in Django as per their recommendation. This function handles events as they occur in stripe:

----------------

import json

from django.http import HttpResponse

from django.views.decorators.csrf import csrf_exempt

# Using Django

@csrf_exempt

def my_webhook_view(request):

 payload = request.body

 event = None

 try:

   event = stripe.Event.construct_from(

     json.loads(payload), stripe.api_key

   )

 except ValueError as e:

   # Invalid payload

   return HttpResponse(status=400)

 # Handle the event

   if event['type'] == 'customer.created':

     customer = event['data']['object']

   elif event['type'] == 'customer.deleted':

     customer = event['data']['object']

   elif event['type'] == 'customer.source.created':

     source = event['data']['object']

   elif event['type'] == 'customer.subscription.created':

     subscription = event['data']['object']

   elif event['type'] == 'customer.subscription.updated':

     subscription = event['data']['object']

   # ... handle other event types

   else:

     print('Unhandled event type {}'.format(event['type']))

 return HttpResponse(status=200)

-------------------------

I now need to integrate some logic to make this work. I wanted to ask:

  • Is there an established approach for connecting stripe to databricks?
  • How can I set up my endpoint in databricks?

Thanks

0 REPLIES 0

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group