#paulc7053_api

1 messages ยท Page 1 of 1 (latest)

slow solarBOT
#

๐Ÿ‘‹ 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/1333461853455777813

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

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

royal oar
#

Hello!

#

The invoice is open, although auto_advance is set to true

nimble escarpBOT
sacred crown
#

Hi there ๐Ÿ‘‹ that's expected behavior. The Invoice will automatically attempt payment after about an hour, but if you want that to happen soon then you'll need to make a request to pay the Invoice:
https://docs.stripe.com/api/invoices/pay

royal oar
#

so as soon as I create it and add the items, make a request to pay it?

sacred crown
#

You might have to wait until it's finalized, but yeah that's the general idea.

royal oar
#

ah okay, 5 mins please, I'll try it right now

#

I just added stripe.invoices.pay(invoice.id), but now I get ' StripeInvalidRequestError: There is no default_payment_method set on this Customer or Invoice. Set a default on one of those objects, or specify the Payment Method you wish to use in the payment_method parameter.'

#

oh, I have to pass it when creating an incoice

#

invoice*

sacred crown
#

Yup

royal oar
#

now I'm looking up how to pass a default payment method to the customer

sacred crown
#

If you want to set that on the Customer object level, you'll update invoice_settings.default_payment_method.

#

We don't do code reviews. Is it behaving the way you're wanting it to in testmode?

royal oar
#

I just ended up getting the default payment method from the subscription

#

it does, but feels so hacky.

#

the functionality I'm looking for is not exactly rocket science, and this looks very confoluted

#

convoluted(*

sacred crown
#

Well it does feel a little weird that you're using proration_behavior: 'none' and then instead calculating proration amounts on your own. You could leave that to us if you wanted.

I also think you could set the subscription parameter when creating the Invoice, so the Invoice is associated with the Subscription:
https://docs.stripe.com/api/invoices/create#create_invoice-subscription
I think that will avoid you needing to pass a payment method specifically, if you're saving the default payment method at the Subscription level.

#

If you can help us understand what you don't like about the flow that you have, that's usually the best way for us to give suggestions on how to improve that.

royal oar
#

that's quite helpvul

#

in the docs it says (on the invoice creation -> subscription) " the created invoice will only include pending invoice items for that subscription"- is the pending invoice item in my case the difference amount between the two subscriptions?

#

About the proration, I can't prorate because it's a physical product, so I don't care about how many days the user has had another plan

sacred crown
#

If those are the only pending Invoice Items you create, then those are the only ones that will be included.

royal oar
#

does passing subscription to both the invoice and invoice item creation exempt me vrom passing payment_method: stripeSubscription.default_payment_method to invoices.pay ?

sacred crown
#

I believe so, which is why I said that earlier, is that what you see when you test it?

royal oar
#

haven't tried it yet, was just in the docs. will try right now

slow solarBOT
royal oar
#

yes , you're right!

#

thanks a lot!

#

have been trying to solve this for some time

#

@sacred crown thanks for your time & patience again!