#bugkiller.
1 messages ยท Page 1 of 1 (latest)
Hello! How are you currently setting clientSecret in your code? Where are you getting that value from?
Have you been following one of our guides? The idea here is that you'd create or retrieve a Payment/Setup Intent before this point and use the client_secret you get there
so even before this, need to create subscrption?
in our case, this is register page
so you entere the email, and click 'credit card' button
we can only create user in our end when you click card button
in the prev we used checkout session but now we need to support payment via invoice.
but checkout session doesn't support it
so I'm trying payment elements
What do you mean by payment via Invoice?
Do you mean using the Hosted Invoice Page + subscriptions?
collection_method
as 'send_invoice'
companies are asking invoice before payment
so need to do somehow
If you're using send_invoice why do you need a payment page at all? Typically with this flow, your customer will be emailed an Invoice and they can directly pay the Invoice from there
we use stripe checkout session
I didn't find a way to set collection_method as 'send_invoice'
Yes I understand that - but what I'm asking is why are you integrating with the Payment Element at all? You shouldn't need it because with send_invoice the Invoice is emailed directly to your customer and they are provided a link from there where they can pay
?
collection_method is by default 'charge_automatically'
and we're using stripe checkout session
I shared you my code
so I don't know how to create subscription via stripe checkout session by setting
collection_method as 'send_invoice'
I asked this here before and someone said me to use payment elements
and he said no way to do collection_method as 'send_invoice' with stripe checkout session
Instead of Checkout Sessions you'd use the Subscriptions API and set collection_method: send_invoice (https://stripe.com/docs/api/subscriptions/create#create_subscription-collection_method)
You don't necessarilly have to use the Payment Element with this flow - you only need to do that if you want your own custom payment page
If you're fine with using a Stripe-hosted page, then you don't need to use Payment Element
ok, so my request is like this
as I said before, we're using stripe checkout session for subscription
and we want to use collection_method as 'charge_automatically' for all users
but there are some exceptions
if user checks the box like 'I'd like to pay via invoice' then
then we want user to be able to pay via invcoie ( by setting 'collection_method as 'send_invoice'
@rancid sigil so you mean, if I don't need to have payment elements to support collection_method: send_invoice ?
just create subscription in our backend with collection_method: send_invoice ?
Just one question to confirm something - do your users want an Invoice before EVERY payment? Or just the first one?
before EVERY payment (if that user doesn't want auto charge )
general user will go with auto charge
company level customer will ask invoice before EVERY payment
๐ perfect
Then yes, you'll create the subscription server-side with collection_method: send_invoice. For the first payment you can finalize the latest_invoice immediately and then redirect your user to the hosted_invoice_url (https://stripe.com/docs/api/invoices/object#invoice_object-hosted_invoice_url) or you can just wait for the email to be sent to the customer and they'll pay from there
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
when email will be sent from stripe?
for the first payment
I created subscription with server-side with collection_method: send_invoice
then when will stripe send invoice?
In test mode we don't send these emails automatically (you need to trigger it through the dashboard to test it out)
In live mode the email will get sent after the invoice is finalized, which is typically 1 hour after the invoice has been created
in test mode, I can't expect email at all?
through dashboard? can you give me the dashboard link to trigger
Correct, in test mode you wouldn't get the email at all
And you can trigger it through the Dashboard yourself by opening the Invoice in the dashboard and clicking "Send Invoice"
clicking 'send invoice'?
in stripe dashboard?
this dashboard will have 'Send invoice' button somewhere once I create with
collection method: send_invoice ?
sorry for my dummy question
That invoice has already been paid so you can't sent it again
I know. just asking with screenshow
because I odn't have invoice with 'send_invoice' option yet
anyway, let me try.
even in test mode, once I click 'send invoice' button from stripe dashboard, I'll get an email?
Yea you should see something more like this
and when you click "Send Invoice" you'll see a popup where you an specify an email to send it to
ok.
and generally, invoice will be sent automatically (live) from stripe?
in that case email will be sent to stripe customer email?
and you said it will take 1 hour then how can I send user the link asap in our side. invoice object will have payment link so will just send payment link to the email?
Yes, the invoice will be send automatically from stripe as long as you have the "Send finalized invoices and credit notes to customers" setting enabled in your dashboard here (https://dashboard.stripe.com/settings/billing/automatic) and it'll be sent to the Customer's email
If you want the link asap then you can finalize the invoice (https://stripe.com/docs/api/invoices/finalize) and then manually send the invoice (https://stripe.com/docs/api/invoices/send)
yup!
so what you can say is invoice will be sent within 1 hour in general
and if I finalize and call send_invoice myself for invoice it will be sent soon?
correct!
thanks a lot,
then manually finalize and send invoice myself is better way for customers maybe
Thanks for your help you saved my time. I was going to waste time on payment elements LOL
Thanks , @rancid sigil
๐ happy to help! Definitely try it all out and make sure it does waht you want ๐
yep. (unfortunately finialize, send myself invoice can't be tested in test mode )
afraid to make it live without testing
Yeah, I know it's frustrating - one thing you can check for is the invoice.sent event. That event is what we emit when the invoice is emailed out, so if you get that event in test mode you'll know that it would be sent out
Bill.sent? you mean webhook event?
Yes, the invoice.sent webhook event - if you read out API reference we mention it there (https://stripe.com/docs/api/invoices/send)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
