How to get charge id after creating a subscription using Stripe?

后端 未结 6 2323
忘掉有多难
忘掉有多难 2021-02-13 21:36

I am using Stripe as a payment gateway. Now there\'s a big problem bothers me.

I used code below to create a subscription:



        
6条回答
  •  情歌与酒
    2021-02-13 22:17

    Another option you can use if you need the charge id right away and can't wait for a webhook is use the latest_invoice field on the returned subscription object.

    A python example:

    inv_id = subscription.latest_invoice
    inv = stripe.Invoice.retrieve(inv_id)
    charge_id = inv.charge
    

提交回复
热议问题