#jaunt - Checkout Coupons
1 messages · Page 1 of 1 (latest)
Hello! No minimum time, no. Can you give me the request ID showing the error? Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Thanks! Working on it. So far I've got the request id for the coupon creation. Now finding the one for the checkout session.
coupon create request id: req_FRnBUZrl6WVLCX
Here it is: req_z5DQkn0SQZqJfi
Looking...
Our system received the GET request to retrieve the coupon before the request to create it.
We received the GET request at 1641504909.169225 and the Coupon creation request at 1641504909.3661966
Wonder how that is possible.
It seems like you're running these requests in parallel instead of serially?
I"m using the go api...
Can you show me the code you're using?
Sure...
discounts := []*stripe.CheckoutSessionDiscountParams{}
if offerLevel != "" && offer != nil && percentOff != 0 {
couponID := cart.ApplyOffer + "_" + offerLevel + "_" + userKey.Name
useCoupon, err := coupon.Get(couponID, nil)
if err != nil {
var dm *int64
if duration != "once" {
dm = stripe.Int64(int64(durationInMonths))
}
params := &stripe.CouponParams{
Duration: stripe.String(duration),
DurationInMonths: dm,
PercentOff: stripe.Float64(float64(percentOff)),
ID: stripe.String(couponID),
}
useCoupon, err = coupon.New(params)
if err != nil {
Logger(c, logrus.Fields{}, ERROR, "createCheckoutSubscriptionSessionHandler could not create stripe coupon. Skipping. %v", err)
}
}
discounts = append(discounts, &stripe.CheckoutSessionDiscountParams{
Coupon: &useCoupon.ID,
})
}
var ap *bool
if len(discounts) == 0 {
ap = stripe.Bool(true)
discounts = nil
}
domain := os.Getenv("WEB_APP_ADDRESS") + "/confirming"
params := &stripe.CheckoutSessionParams{
Customer: stripe.String(stripeAccount.StripeID),
//SubmitType: stripe.String("pay"),
BillingAddressCollection: stripe.String("auto"),
PaymentMethodTypes: stripe.StringSlice([]string{
"card",
}),
LineItems: items,
Mode: stripe.String(string(stripe.CheckoutSessionModeSubscription)),
SuccessURL: stripe.String(domain + "?purchaseSuccess=true&session_id={CHECKOUT_SESSION_ID}"),
CancelURL: stripe.String(domain + "?purchaseCanceled=true&session_id={CHECKOUT_SESSION_ID}"),
AllowPromotionCodes: ap,
Discounts: discounts,
}
On this line: useCoupon, err := coupon.Get(couponID, nil) where is coupon coming from/created?
That's the global stripe object from this import:
So, yeah, you're fetching it there before you create it below.
Well checking to see if it exists
You don't create it until later, down here: useCoupon, err = coupon.New(params)
Right, that generates an API request and results in the 404 request you linked to earlier.
The creation of the coupon didn't create an error?
No, that worked just fine.
Sorry, maybe I'm misunderstanding your question, but the Coupon was created successfully here: https://dashboard.stripe.com/logs/req_FRnBUZrl6WVLCX
So you're saying the error came from the coupon.Get request.
But the checkout session failed to use the coupon, and the customer ended up without the coupon. This is the first time I've ever seen it happen.
Can you provide the request ID for creation of the Checkout Session where the coupon didn't work?
Trying to figure that out. There are a string of events
Looks like there were three calls to checkout/sessions in a row.. weird.
req_ZTMSx6g7nWI5V9
req_8FmukdwFzX1Bsy
req_6faGNB0RTPVDrx
The first two reference the coupon but the third doesn't for some reason.
Ah, well, at least that explains why the coupon was missing! 😅
Is there anything else I can do to help?
I guess not!
Hopefully using the request detail you can determine what's causing the issue!