Reputation: 458
I have a webhook for checkout.session.completed
. There is no information about risk score in the object I receive. How can I get the risk evaluation information for my customers' payments?
I can see the risk score from Stripe dashboard, but I also need it in my database.
Upvotes: 0
Views: 112
Reputation: 1938
The risk_score
field is set on the Charge object associated with the payment. This object is not directly available on the Checkout Session object or events.
In order to retrieve these details, you'd need to make an additional API request in your webhook handler. My recommendation would be to retrieve the associated Payment Intent using the pi_xxx
ID from the payment_intent
field on your checkout.session.completed
event, and expand the latest_charge
field. The response will include the full Charge object, including the required outcome.risk_score
field.
This will look something like this using the stripe-node
library:
const paymentIntent = await stripe.paymentIntents.retrieve('pi_xxx', {
expand: ['latest_charge']
})
Upvotes: 1