#paulc7053_api
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/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.
- paulc7053_api, 4 hours ago, 95 messages
Hello!
This is how I currently try to achieve the intended outcome
The invoice is open, although auto_advance is set to true
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
so as soon as I create it and add the items, make a request to pay it?
You might have to wait until it's finalized, but yeah that's the general idea.
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.'
I only see payment_method as a param to the invoices.pay https://docs.stripe.com/api/invoices/pay#pay_invoice-payment_method
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
oh, I have to pass it when creating an incoice
invoice*
Yup
now I'm looking up how to pass a default payment method to the customer
Would you say this is suitable for production usage?
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?
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(*
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.
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
Ah, good point! You'll also want to specify subscription when creating the Invoice Items:
https://docs.stripe.com/api/invoiceitems/create#create_invoiceitem-subscription
so that way everything is tied together.
If those are the only pending Invoice Items you create, then those are the only ones that will be included.
does passing subscription to both the invoice and invoice item creation exempt me vrom passing payment_method: stripeSubscription.default_payment_method to invoices.pay ?
I believe so, which is why I said that earlier, is that what you see when you test it?
haven't tried it yet, was just in the docs. will try right now