#Khalid Al-Awady

1 messages · Page 1 of 1 (latest)

brave voidBOT
upper robin
#

Hey there

#

When you say "fails to process the transaction" you mean how do you handle an async failure?

zealous wigeon
#

not exactly, though if that is the proper way to do it I am open ears. The main issue I have is something similar to the following serverside

func (c *client) UpdateSubscription(
    subscriptionID string,
    subItemsParams []*stripe.SubscriptionItemsParams,
    alwaysInvoice bool,
    endTrial bool,
) (*stripe.Subscription, error) {
    params := &stripe.SubscriptionParams{Items: subItemsParams}
    params.ProrationBehavior = stripe.String(string(stripe.SubscriptionSchedulePhaseProrationBehaviorNone))
    if alwaysInvoice {
        params.ProrationBehavior = stripe.String(string(stripe.SubscriptionSchedulePhaseProrationBehaviorAlwaysInvoice))
    }
    if endTrial {
        params.TrialEndNow = stripe.Bool(true)
    }

    callTimer := c.metrics.CreateStripeCallTimer(SubscriptionUpdate)
    sub, err := subscription.Update(subscriptionID, params)
    callTimer.StopTimerAndSend()
    if err != nil {
        return nil, fudge.Wrap(err)
    }
    return sub, nil
}
#

the main issue here is the subscription.Update(subscriptionID, params)

#

because the returned object may not always return a status that isn't active causing the I have to return 200s for failed account transactions

#

if the proper way to handle it is client-side using async payment intent requests I can do that

upper robin
#

Let's back up.

#

What is the exact scenario you are trying to handle?

zealous wigeon
#

lets say I want to update a subscription be it regular or a trial using a us bank account. The account obviously fails for whatever reason, I want to be able to handle this such that on failed transaction I don't return a 200

upper robin
#

Yeah that's not how it works though. Bank Debits are async, so you won't get an immediate failure.

#

You want to use webhooks in this case to listen for something like invoice.payment_failed

#

And then handle from there

zealous wigeon
#

oh boy

#

thank you, I now know what to do