I have a stripe pricing table on my front end to render the options available to customers. On my backend I am using Django to handle account creation if the payment was successful. As below this was created following a tutorial on TestDriven.io btw.
if event['type'] == 'checkout.session.completed':
session = event['data']['object']
print(session)
# # Fetch all the required data from session
client_reference_id = session.get('client_reference_id')
stripe_customer_id = session.get('customer')
stripe_subscription_id = session.get('subscription')
# Get the user and create a new StripeCustomer
user = CustomUser.objects.get(id=client_reference_id)
StripeCustomer.objects.create(
user=user,
stripeCustomerId=stripe_customer_id,
stripeSubscriptionId=stripe_subscription_id,
)
I am getting the following error
raise self.model.DoesNotExist(apps.authentication.models.CustomUser.DoesNotExist: CustomUser matching query does not exist
So after some digging I have found that Stripe is not returning the client_reference_id to my backend, below is a printout of the session variable
"client_reference_id": null,
I believe this is why the account is not being found by Django, but I can't seem to figure out why Stripe isn't sending this information over or how to attach it to the response to my Web hook?