#smokey_subscription-collectionmethod
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/1216890755210154064
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
You need to expand the latest invoice
sub = stripe.Subscription.create(
customer=customer_id,
items=[
{
'price': price_id
}
],
payment_behavior='allow_incomplete' if is_setup else 'default_incomplete',
payment_settings={'save_default_payment_method': 'on_subscription'},
expand=['latest_invoice.payment_intent', 'pending_setup_intent'],
collection_method='charge_automatically' if is_setup else 'send_invoice',
days_until_due=0
)
Here is better formatted., Latest invoice is expanded
Okay, that still works for me and I'm using stripe-python
Is it OK to paste the return object here?
This code worked perfectly about 2 months ago, I came back to the propject today and it's not working..
And yeah sure
I can look it up and it won't clutter things
sub_1OtIB0B8l4UplgS6kO8eB7hQ
Thanks, taking a look
Thanks! Appreciate it
Okay, I'm taking a look at the request this created: https://dashboard.stripe.com/test/logs/req_OrYSbw1hlcjUHL and I see the latest_invoice has a full object instead of just an ID
Did your version of stripe-python change?
It looks like you're on 7.11.0 in this request
I don't think so, I reinstalled from my requirements created the last time I was on this project
what v of stripe-python are you using?
I have multiple. Some integrations are on 8.0.0, a few are on 5.4.0
Actually it turns out that latest_invoice is indeed returning an object, my parser was just messing up when I was viewing it, but latest_invoice.payment_intent is null
previously it would contain a client secret
Ah, yeah payment_intent: null,
Did something change with Stripe recently?
Because I didn't require to use days_until_due either, but now I do
Were you always using collection_method: "send_invoice"?
Yep
Basically IIRC, collection_method is set to send_invoice if the customers stripe account hasn't been fully setup with a card linked. So I create the invoice, and the client adds their card and then charges for the invoice
The default API version for this account is 2022-11-15 but the API version on this request is 2023-10-16
The Customer doesn't have a Stripe account. Unless this is a Connected Account.
But I think you mean the Customer hasn't set up a default payment method
My bad, I mean a customer object
Okay, cool. Just want to make sure we're on the same page
Okay yes I confirmed my integration does the same thing ( using stripe-python v 5.4.0 and API version 2020-08-27)
collection_method: "send_invoice" returns a null as a Payment Intent.
The Hosted Invoice Page doesn't create a Payment Intent until the user confirms the payment intent.
hmm I need a client secret through to process the payment. Everything is self hosted on my site - no stripe invoice page
Ummm....no you don't?
How come you're getting the same result as me on older version of package & api?
Collecting payment yourself and using send_invoice are mutually exclusive
previously it would return a client secret
yeah but if the payment requires 3ds then it has to be done on the client which requires a secret
That has always been the case since I started at Stripe over 2 years ago
I think what would make more sense (based on how you described using the send_invoice option) woul be that you should try creating your Subscriptions with collection_method: "charge_automatically" and for those Customers who don't have a saved Payment method you should include payment_settings.save_default_payment_method:"on_subscription"
I'm confused as to why everything worked couple months back, but not now. And I've checked the changelog and see no mention of this
Do you have an example of the previous flow? The tought part is "a couple months" is past our retention time for API requests but I could look at some objects
But, for the flow I'm describing, you would set this property: https://docs.stripe.com/api/subscriptions/create#create_subscription-payment_settings-save_default_payment_method
I routinely nuke my test data so I'm not sure if it would still be visible?
And when the Customer succeeds in their first payment it will automatically save that paymemt method as their default
The flow is this:
Users signs up
Then goes to setup screen
They choose pay as you go, or monthly
If payg, their card details is attached to the customer object
if monthly, I create an invoice, and process the payment and save their card details to the customer object.
I had quite a bit of trouble with this last time and spent a fair amount of time with someone from Stripe going through this, and this turned out to be the best option
I routinely nuke my test data so I'm not sure if it would still be visible?
Without examples it's really hard to dig further into this
That makes sense but I don't see a need for send_invoice in any of that
I believe its because the customer object doesn't have a card attached. I think the sub is created, the secret is passed back to the client, and then the client processes the payment with the sub ID
still no reason to use send_invoice for any of that
smokey_subscription-collectionmethod
ok can you tell me where I'm going wrong in my logic?
Me and @mystic badger don't understand why you are using send_invoice. There's really no reason to do this at all. This is for when you want us to email the end customer to pay later, often via bank transfers, like for B2B
What you described above you can totally use charge_automatically
Yeah I guess you're right. using send_invoice was actually the recommendation of someone from this support group about 6 months ago. I remember coming here for support when i couldn't figure out how to achieve what I wanted...
I guess I'll have to try figure out how to get everything to work with charge_automatically
What you likely are missing is payment_behavior: 'default_incomplete' on Subscription creation. That will finalize the Invoice, give you a PaymentIntent and then you can use it to render PaymentElement client-side for example
well default_incomplete is already there on initial subscription creation
then no reason to use send_invoice at all in that case (you were explicitly saying you handle having a save card or not differently)
I think you're totally right. I've removed send_invoice and everything seems to be working as I'd expect.... I really have no idea why I was using send_invoice
yeah likely a misunderstanding!
Thanks a lot for the help, I really appreciate it. And you too @mystic badger. You spent the best part of 35 minutes helping me with this.