#roshe10_code
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1467809203354730572
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
â¨â¨`func (p *PaymentProvider) GetPaymentReferencesForPayoutID(ctx context.Context, payoutID domain.PaymentProviderPayoutID, orgAccID domain.PaymentProviderOrganisationAccountID) ([]string, error) {
params := &stripe.BalanceTransactionListParams{
Payout: stripe.String(string(payoutID)),
}
params.SetStripeAccount(string(orgAccID))
var paymentIntents []string
for bt, err := range p.sc.V1BalanceTransactions.List(ctx, params) {
if err != nil {
return nil, fmt.Errorf("error listing balance transactions for payout %s: %w", payoutID, err)
}
if bt.Source == nil || bt.Source.ID == "" || !isRelevantBTType(bt.Type) {
continue
}
intentID, err := p.getPaymentIntentFromChargePayment(ctx, bt.Source.ID, string(orgAccID))
if err != nil {
fmt.Printf("warn: %v\n", err)
continue
}
if intentID != "" {
paymentIntents = append(paymentIntents, intentID)
}
}
return paymentIntents, nil
}
func (p *PaymentProvider) getPaymentIntentFromChargePayment(ctx context.Context, chargeID, accountID string) (string, error) {
params := &stripe.ChargeRetrieveParams{}
params.SetStripeAccount(accountID)
params.AddExpand("balance_transaction")
chrg, err := p.sc.V1Charges.Retrieve(ctx, chargeID, params)
if err != nil {
return "", fmt.Errorf("failed to fetch charge (ID: %s): %w", chargeID, err)
}
if chrg.PaymentIntent != nil {
return chrg.PaymentIntent.ID, nil
}
return "", nil
}`âŠâŠ
// We only care about balance transactions of type 'charge' (from cards) or 'payment' (from wire transfers) in the list (those transactions are related to actual donations)
func isRelevantBTType(t stripe.BalanceTransactionType) bool {
return t == stripe.BalanceTransactionTypeCharge || t == stripe.BalanceTransactionTypePayment
}
going through loop receiving errors like:
Request failed with error: Get "https://api.stripe.com/v1/charges/ch_3SsXzoPeBLev00TB1hsWCKd1?expand[0]=balance_transaction": context canceled
Failing event: evt_1SwB8vPeBLev00TBSkempgIj
Same event with same handler , but different payout, with less charges, goes through without any problems: evt_1SwBRuPU6qwHdB7BWodJL9Te
not sure where can i find the request ID, I'm doing it through code when payout.created event is triggered
Firstly, in the event handler, you should respond quickly with 2xx then do your treatment async
I imagine you are doing something similar to this in order to get the payout's related payments:
https://docs.stripe.com/payouts/reconciliation
re quickly 2xx, if i do that, then I will not be able to repeat the event if it fails for some reason like it is failing now ?
yes, I'm doing similar, because after I received balance transactions, I need a way to get payment intent ID, and only way I found I could do it is through charge ID (which i get from source ID like in your link) (getPaymentIntentFromChargePayment)
re quickly 2xx, if i do that, then I will not be able to repeat the event if it fails for some reason like it is failing now ?
No, but you shouldn't rely oon stripe webhook for heavy processes
You just need to acknowldge the event quickly, then you need to implement internal retries in your integration for heavy batches
yes, I'm doing similar, because after I received balance transactions, I need a way to get payment intent ID, and only way I found I could do it is through charge ID (which i get from source ID like in your link) (getPaymentIntentFromChargePayment)
Yes correct
okay I see, so we can at least confirm this event failing was due to heavy process, and that's why we got error context cancelled ?
Yes that's the only reason I'm seeing for now.
Yes sure, what is it ?
payout : po_1Stdk6BSG0C5LgUOBGOVBxB3 was completed at 3am, however it included a transaction: pi_3SrlYiBSG0C5LgUO1WjwqYTW (wire transfer) which succeeded later at 7am same day . I was not expecting it in the payout because I consider payment finalised only after payment succeeded event happend
payout.paid evt_1Stg1YBSG0C5LgUOYnyXUTzC
pi_succeded: evt_3SrlYiBSG0C5LgUO1VIT36K2
Let me check this further...
sure
So that Payout was created on the 2026-01-26
The payment youw ere referring to was created on 2026-01-20
Which is way before the payout creation
correct, that's when the payment is created, but isn't payment finalized (money lands) only after its payment intent succeeded (or invoice paid) event happens, which came after payout
it was a wire transfer, so how can I now it will not fail - here we 'got lucky' so it succeeded eventually, but it could also fail right ?
Yeah agreed, but no worries if the capture was failed, you'll get regulated in the next payout
Stripe handles this automatically
đ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!
hmm, what does that exactly mean - 'get regulated'? Does it mean if stripe payed out extra $25 in first payout (included not-yet succeeded payment), then payment fails after the initial payout, so in the next payout I will get $25 less than expected which will appear as "fee" (in order to 'get regulated') or ?
you only get paid out the available balance which only includes succeeded payment that has been in your pending balance for more than the pending payout delay
you can learn more about your balance states here https://docs.stripe.com/payments/balances#balance-states
only get paid out the available balance which only includes succeeded payment
hmm, but that's the thing I don't understand, my payout included 'pending', not fully 'succeeded' payment - pi_3SrlYiBSG0C5LgUO1WjwqYTW
please contact https://support.stripe.com/?contact=true they will be able to better help you with this
Popular articles