Advertisements
I would like to get the product id for one-time payments, but I am unable find ANY webhook event that would give me the id of the product purchased.
I know that for subscriptions, invoice.paid
event provides the product id, but one-time payments do not produce invoice.
I have read some suggestions such as appending product id to metadata of checkout session and listening for checkout.session.completed
, but I am not sure whether that is a reliable source for the confirmation of the payment.
>Solution :
If you use Checkout for one-time payment, then yes checkout.session.completed
is the event you want. However you will need to Retrieve and expand the Checkout Session using its Id. You can expand its line_items.data.price.product.