#emnaruto07

1 messages ยท Page 1 of 1 (latest)

hasty shore
tame notch
#

Hey there ๐Ÿ‘‹

cosmic valve
#

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

tame notch
#

can you provide more details on your integration?

cosmic valve
#

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

tame notch
#

what specifically are you having trouble with?

cosmic valve
#

i can't understand how to call the create api after the payment is successful

tame notch
#

Looking into it

cosmic valve
#

dont close this thread please, I'll contact here in the morning.

#

ok

#

waiting

tame notch
#

what API are you using for making payments?

cosmic valve
#

checkout sessm

#

and for update custom

tame notch
#

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

cosmic valve
#

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?

tame notch
#

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

cosmic valve
#

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

tame notch
cosmic valve
#

yes

tame notch
#

what database are you using?

cosmic valve
#

postgres

tame notch
#

are you using an ORM?

cosmic valve
#

I'm actually using models from django framework

#

and yes

#

i'm using orm

tame notch
#

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

cosmic valve
#

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.

tame notch
#

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 ๐Ÿ™‚

cosmic valve
#

ohh, ok

#

i'll try in the morning. Thanks for the hint. Please don't close the thread.

tame notch
#

The thread will auto-archived by discord but you can ask Stripe Staff handling discord to re-open it for you ๐Ÿ™‚

cosmic valve
#

ok

#

thanks hanzo