cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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
Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.