Double model creation after payment in django website

I am currently working on Learning management course using Django and React .I am creating payment gateway using stripe . After the payment is successfully done , the courses should be called enrolled courses and a model of it created after payment . But for some issue , double course model gets created after payment for each course purchased. I don't know the issue in code. I have attached the code of payment and model created .enter image description here

enter image description here

enter image description here

I tried to pay using stripe and get the enrolled course created of that course. But duplicate (double) enrolled course created for some reason.

This is the drive link for all the client side code snippets

Back to Top