#DaanVDH
1 messages ยท Page 1 of 1 (latest)
This function adds the refundId as MetaData to the paymentIntent and then creates a refund for the same paymentIntent in that order
but the problem is the refund goes trough before the paymentIntent is updated
so when my webhook tries to get the refundId from the MetaData it's not there yet
and the webhook fails
why not add the metadata to the refund itself
and in your webhook you get the metadata and update the PI if it's really necessary for you
Ahh, yeah that might be a good solution.
Let me try it for a second
yes sure
So this would be the way to get the last refund from the pi right: go refundId, err := uuid.Parse(pi.LatestCharge.Refunds.Data[0].Metadata["refundId"])
and parsing it in my case
๐ stepping in
Hi
This is the whole func:
func (s service) GetRefundIdForPaymentIntent(pid string, accountId string) (uuid.UUID, error) {
params := &stripe.PaymentIntentParams{}
params.AddExpand("latest_charge.balance_transaction")
params.SetStripeAccount(accountId)
pi, err := paymentintent.Get(pid, params)
if err != nil {
return uuid.Nil, nil
}
refundId, err := uuid.Parse(pi.LatestCharge.Refunds.Data[0].Metadata["refundId"])
if err != nil {
return uuid.Nil, nil
}
return refundId, nil
}
Ohh i think i need to change it to: latest_charge.refunds right?
Yeah looks like you are just expanding latest_charge.balance_transaction so you want to also expand latest_charge.refunds
You can either change it or expand both
Depends if you are going to want the balance transaction info
No, refunds is all i need for this function