#emnaruto07
1 messages ยท Page 1 of 1 (latest)
Hey there ๐
Hi Hanzo
I'm currently using this as a normal class. Means anyone can call this api link and if they post the data my db will save it ```class JobCreateView(CreateAPIView):
permission_classes = [IsAuthenticated]
serializer_class = JobListSerializer
def perform_create(self, serializer):
serializer.save(user=self.request.user)```
now i want to add webhook around this method
can you provide more details on your integration?
i want users to pay me first and then create the api call, to save the data inside my database.
i'm using react.js and django
what specifically are you having trouble with?
i can't understand how to call the create api after the payment is successful
Looking into it
what API are you using for making payments?
Thank you for waiting patiently
So in this case you'd want to listen for payment_intent.succeeded event which would let you know when a payment succeeded. After that you can make a request to your server to persist the information on your database
can you give me one example?
how to make request?
should i call like request.post(myserver.com) after the payment_intent.succeeded is successfull?
request.post(http://localhost:8000/create-job/)
print("Creating order")```
like this?
i think there's some confusion here regarding what webhooks are used for.
A webhook is essentially a method on your server that stripe calls whenever an event occurs. such as payment intent succeeding and many more.
what you want is for your server to have a method that is called whenever you receive payment_intent.succeeded which will then run the task for you. i.e. saving information to db
I know, but i'm little confused like how to run a query after the payment_intent is success.
thats why i need example
or any resources will work
have you looked at this already? https://stripe.com/docs/webhooks/quickstart
yes
what database are you using?
postgres
are you using an ORM?
Great! what you want is to use your ORM methods after you receive the webhook event
such as let's say you have a Customer Model
and you have a customer who made a payment, you'll receive an event from stripe with the payment info.
what you need is to then update that customer with the information you received.
I'm not very fluent with Python but your ORM should have methods such as .create, .update etc.
Unfortunately, we don't have any examples in our docs that would show integration with an ORM
ok
So, suppose i have a job model. How can i call this job model? after the payment is successful? means i understand that i can use the data and store directly into my database. But what about the data which i need from the frontend form? How can i call that data after the payment?
because customer data will be provided by stripe
so its easy to save directly.
so for example: I have name, age and address. I want to save this data from the frontend after the payment went through.
maybe wrong example.
suppose i have job title, salary, fulltime, location data. How can i save this data? this data is different from stripe api data.
In this case, You can save the information before the checkout session and then update it once the stripe webhook event comes in.
if the payment is successful, update the row in your table
if the payment fails, delete the record ๐
ohh, ok
i'll try in the morning. Thanks for the hint. Please don't close the thread.
The thread will auto-archived by discord but you can ask Stripe Staff handling discord to re-open it for you ๐