#apolloengineer_api

1 messages Β· Page 1 of 1 (latest)

steep estuaryBOT
#

πŸ‘‹ 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/1329216984512200735

πŸ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

shrewd sage
#

Hi, taking a look here

#

Hi, can you explain more here? Are you saying that when passing "payment_behavior: 'default_incomplete'" it shows '$120.00 off' and otherwise you see '$240 off'?

#

I think it's related to passing a proration_date on the first request. Can you look there?

wary lantern
#

If I create a new subscription, update to a $120 coupon, then update it to a $240, then do a preview at $360, I get the right proration behavior.

#

If I create a new subscription, etc... but I set payment_behavior: 'default_incomplete', and then pay off that invoice, then the coupon says $120 instead of $240.

#

let me look, it will take me a few minutes to set this up.

shrewd sage
#

Sure, take your time

wary lantern
#

should i not send a proration date?

shrewd sage
#

You can but that changes the amount that is prorated.

wary lantern
#

I was passing in the proration date prior when it was working

#

something i did change is i set the default behavior on the subscription to proration_behavior: 'none'

#

but that would be weird for that to effect the proration on which coupon

shrewd sage
#

Can you share an example where you passed the proration date and it was working as you described?

wary lantern
#

yeah just a moment

#

I'm trying to find a request to /upcoming on this customer and I'm having trouble finding it, but it worked. cus_RarQgq6mqAkB37

steep estuaryBOT
shrewd sage
#

I also noticed that the coupon code on the above requests were different. taking a look at that customer id now

#

Ah, they offer the same amount for the discount

wary lantern
#

I have a test run that recreates all the objects

#

Can you see the upcoming requests?

shrewd sage
#

It would be helpful if you could share the same request that worked as you expected so I can compare the two. Can you make new requests and pass the exact same params?

wary lantern
#

yes

#

I just want to give you the request ids but i can't find them in the event log

shrewd sage
wary lantern
#

is there a way to get it from the response

coarse flower
#

hi! taking over as pgskc has to run

#

catching up on the issue now, i may have a couple of clarifying questions

wary lantern
#

ok

#

My problem currently is that I want to show you the invoice upcoming request, but I can't find it on the customers logs.

#

I do have 2 previous requests I was able to find though

coarse flower
#

any chance you can make another request now? i can just see if i can find it in your account's API logs

wary lantern
#

ok no problem it will be test mode

#

ok I'm running the test suite where it works first

#

it just completed

coarse flower
#

yep, seeing the logs showing up now

wary lantern
#

I'm still not seeing logged calls to preview

coarse flower
#

yeah i'm not seeing any calls to the preview endpoint on my side either

#

are you sure you're calling it?

wary lantern
#

I have the responses

coarse flower
#

πŸ€”

wary lantern
#

ok this was working just last week 1 second

#

bad request: req_ISR1VhO1bHE315
good request: req_ImDyUpKSaQNDep

#

I also have the request url in the response

#

/v1/invoices/upcoming/lines?subscription_billing_cycle_anchor=unchanged&subscription=sub_0Qhg4p5QM0nABsUHAzZAIY9e&subscription_proration_date=1736984011&subscription_items%5B0%5D%5Bquantity%5D=3&subscription_items%5B0%5D%5Bplan%5D=professional_ec_y_yearly_1&subscription_items%5B0%5D%5Bmetadata%5D%5Bcategory%5D=seat&subscription_items%5B1%5D%5Bid%5D=si_RaroDAT0qIoVvB&subscription_items%5B1%5D%5Bdeleted%5D=true&coupon=2vHwIXb6&subscription_proration_behavior=create_prorations

#

responds with Unused time on 2 Γ— Professional Seat (with $240.00 off) after 15 Jan 2025

#

and heres the one where its wrong

#

/v1/invoices/upcoming/lines?subscription_billing_cycle_anchor=unchanged&subscription=sub_0QhgBd5QM0nABsUHgeFZwHjL&subscription_proration_date=1736984404&subscription_items%5B0%5D%5Bquantity%5D=2&subscription_items%5B0%5D%5Bplan%5D=professional_ec_y_yearly_1&subscription_items%5B0%5D%5Bmetadata%5D%5Bcategory%5D=seat&subscription_items%5B1%5D%5Bid%5D=si_RarvC8OTvU8liT&subscription_items%5B1%5D%5Bdeleted%5D=true&coupon=hMPjnRbn&subscription_proration_behavior=create_prorations

#

"Unused time on 2 Γ— Professional Seat (with $120.00 off) after 15 Jan 2025"

coarse flower
#

ok, let me see if i can find the request IDs in question...

#

it looks like you're using the /v1/invoices/upcoming API which is different than the /v1/invoices/create_preview API, which could be why i wasn't finding them earlier

wary lantern
#

We have an older stripe gem

coarse flower
#

can you just confirm that for me real quick?

#

and then if you can generate another one that isn't working we can have a recent example on the same API to compare it with

wary lantern
#

it should be a request for 3 seats?

#

can you find the one after that?

coarse flower
#

looking now, 1 sec

#

there are a lot of duplicate requests so it's taking me a bit

wary lantern
#

correct

#

ok this is for a request that is working I'll now help you find a failing request and we can compare

coarse flower
#

πŸ‘

#

if you're still having trouble finding them on your side then giving me a timestamp of when you see the weird behavior will help me find the failing request much faster

wary lantern
#

cus_RasECUN23Q9Mne sub_0QhgUL5QM0nABsUHRcbSkajY 2025-01-15 15:59:24.78483 -0800

coarse flower
wary lantern
#

needs to be for quantity 3

#

it should match these parameters /v1/invoices/upcoming/lines?subscription_billing_cycle_anchor=unchanged&subscription=sub_0QhgUL5QM0nABsUHRcbSkajY&subscription_proration_date=1736985583&subscription_items%5B0%5D%5Bquantity%5D=3&subscription_items%5B0%5D%5Bplan%5D=professional_ec_y_yearly_1&subscription_items%5B0%5D%5Bmetadata%5D%5Bcategory%5D=seat&subscription_items%5B1%5D%5Bid%5D=si_RasF7pq7LqoRAQ&subscription_items%5B1%5D%5Bdeleted%5D=true&coupon=yfIIS6uC&subscription_proration_behavior=create_prorations

coarse flower
#

hmm yeah i'm having trouble finding it... still looking

#

that one has quantity 3

#

does that look right?

wary lantern
#

you got it

coarse flower
#

ok cool, let's compare

wary lantern
#

thats the one that returns incorrectly that it currently has a $120 coupon instead of a $240 coupon.

#

thanks so much for your help!

#

on the links you sent, can we also see the response?

coarse flower
#

it's been a bit since i've looked at this from the dashboard, but i can't see the response on my end so i wouldn't be surprised if you can't see it either unfortunately

#

saving all GET responses would get expensive quickly

wary lantern
#

I can give you responses from my side if that helps

coarse flower
#

those appear to be the only differences. so different code, different quantity, and then date (which it looks like you're just setting to the current timestamp)

wary lantern
#

you grabbed the wrong one for the working one

coarse flower
#

oops good catch

wary lantern
#

req_ETH1tbkqf6Dq5F

coarse flower
#

updated

#

so it does look like they're using different coupon codes and subscription_proration_date timestamps but otherwise identical

wary lantern
#

ok the problem is that the proration is picking up the wrong coupon currently on the subscription.

#

can you help me with that?

coarse flower
#

looking up details of the coupons now, which is a little difficult from my end since this is just an upcoming invoice...

#

any chance you have the request IDs where you created those?

wary lantern
#

the coupons?

coarse flower
#

yep!

wary lantern
#

req_tDS3fsZhZxov7k

#

req_LJ0k62BRLbWsBZ

#

these coupons are the ones used to preview with.

coarse flower
#

hmm, yep, everything looks pretty much identical.

#

is there any chance you still have the response bodies and can share those too? i know you offered earlier

#

i think you should have permissions to send it as a file to keep the chat cleaner

wary lantern
#

ok i'll send a file for the one that doesn't work

#

the one that does work I have to regenerate

#

ok good one will have different subscription, coupons, etc..

#

the difference between that first line on proration is what matters its $120 different.

coarse flower
#

ok yep, i see that

#

thanks for providing so much info so far and for your patience πŸ™

#

looking into the discrepancy now

steep estuaryBOT
fiery cypress
#

Hi @wary lantern This is Jack and I'm also an engineer from Stripe. I'll take over your thread.

#

The $120.00 off that you see from the proration line item "Unused time on 2 Γ— Professional Seat (with $120.00 off) after 04 Jan 2025" is coming from the discount that was already applied to the previous invoice (i.e., in_0QdL9N5QM0nABsUHW8ycuP93) that the subscription created before.

wary lantern
fiery cypress
#

No, discoounts won't be applied to credit proration line items.

#

if you check the line item's discountable , it's false

wary lantern
#

ok can you tell me why it works on the file marked good-one.json?

wary lantern
#

can you confirm you are looking into the good one?

fiery cypress
#

Yes I'm checking on it. Please give me some time.

wary lantern
#

thank you

fiery cypress
#

So this is the previous invoice in_0QdObF5QM0nABsUHm5whDXEU and it has a discount of $120. I don't think it's correct to show $240 discount on the proration line item.

#

Can I suggest you to reach out to Stripe support and share them the reqeust ID? we'll escalate it to the relevant team and investigate further.

steep estuaryBOT
#

Hello @wary lantern, we have sent you a direct message, please check it at https://discord.com/channels/@me/1329261710036697119

  • πŸ”—The message has instructions on how to open a direct support case with our Developer Support team, in order to help you more effectively.
wary lantern
#

stripe support just leaves me hanging for weeks and nothing happens 😦

#

Is there anyway you think I can work around this?

fiery cypress
#

Can you perform a subscriptoin update with the same params that you set on the preview, and share with me the ID of the resulting invoice?

wary lantern
#

ok

#

bad or good one?

fiery cypress
#

The good one (i.e., the one that shows $240 discount on the proration line item)

wary lantern
#

in_0QhhAf5QM0nABsUHHhcKDvWP

#
  amount_off: 36000,
  currency: 'usd',
  duration: 'forever',
  name: 'test coupon',
  metadata: { category: 'seat_discount' }
})

Stripe::Subscription.update(
  'sub_0QhhAe5QM0nABsUHRnWFSk6i',
  {
    coupon: coupon.id,
    items: [
      {
        quantity: 3,
        plan: 'professional_ec_y_yearly_1',
        metadata: { category: 'seat' }
      },
      {
        id: 'si_RasxXolo8s2RVd',
        deleted: true
      }
    ],
    prorate: true,
    proration_date: 1736988207
  }
)
#

See sub_0QhhAe5QM0nABsUHRnWFSk6i

#

looks like it produced what I would expect

#

its rebating the $240

#

This is desired behavior, if I can mimick it I would like to

fiery cypress
#

Can you advance the test clock (if there's one) and share with me the ID of the finalized upcoming invoice?

wary lantern
#

there is not a test clock on this one

#

but the upcoming invoice should be that one right?

fiery cypress
#

Can you try again with a test clock?

wary lantern
#

yes

#

working on attaching

#

ok i have the clock setup

#

changing the subscription

#

@fiery cypress finally: in_0Qhj6o5QM0nABsUHC4SBptss

#

I haven't setup a clock in a while

fiery cypress
#

Thanks, let me take a look

wary lantern
#

yes

#

start with a 120 coupon, upgrade to 240 coupon, finish with a 360 coupon.

fiery cypress
#

Interesting, then that may explain the ($240 off) description in the proration line item.

wary lantern
#

$240 is correct, but I'm making an upgrade to our system where i do almost the same thing and its $120 instead.

fiery cypress
#

And that's why the proration line item shows ($120 off).

wary lantern
#

thats because my test fails cause the preview is wrong before the 2nd update

#

so its starts at $120, I upgrade to $240, and preview. on that preview the good subscription is correct ($240) and proceeds with the $360. The bad subscription gets back ($120) and I don't complete the upgrade

fiery cypress
#

Can you should me the ID of preview request that you made after applying $240 discount?

wary lantern
fiery cypress
#

To confirm. Is it req_ETH1tbkqf6Dq5F?

wary lantern
#

yes

fiery cypress
#

It's a GET request so I can't view the response. Can you share with me the content of the response?

wary lantern
#

yes when we first connected today it was the file called bad-one.json

#

notice the coupon proration says its for 2 x seats (correct) but then has the wrong amount on it ($120).

fiery cypress
#

Ok, what's the ID of request that resulted in the "good-one" ? Sorry it's a long thread, so need your help to extract the info.

wary lantern
#

req_gBZFZZh6c22e9c

fiery cypress
#

You called the preview API (req_ETH1tbkqf6Dq5F at 11:33:26 PMJan 15, 2025) before updating the subscription (req_KFMt7vEsA9dmdq at 11:33:40 PM Jan 15, 2025

#

Can you try again by calling the preview after the update?

wary lantern
#

I'll have to pick this up tomorrow. Can I continue on this thread?

fiery cypress
#

The thread will be closed after some time. Feel free to use the button in #help channel to create a new one

wary lantern
#

Just one more thing. My workflow calls preview, update, preview. So just make sure thats the right one. Thank you.