#bugkiller.

1 messages ยท Page 1 of 1 (latest)

frank heraldBOT
rancid sigil
#

Hello! How are you currently setting clientSecret in your code? Where are you getting that value from?

vivid hemlock
#

how to specify it?

rancid sigil
#

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

vivid hemlock
#

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

rancid sigil
#

What do you mean by payment via Invoice?

#

Do you mean using the Hosted Invoice Page + subscriptions?

vivid hemlock
#

collection_method

#

as 'send_invoice'

#

companies are asking invoice before payment

#

so need to do somehow

rancid sigil
#

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

vivid hemlock
#

we use stripe checkout session

#

I didn't find a way to set collection_method as 'send_invoice'

rancid sigil
#

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

vivid hemlock
#

?

#

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

rancid sigil
#

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

vivid hemlock
#

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 ?

rancid sigil
#

Just one question to confirm something - do your users want an Invoice before EVERY payment? Or just the first one?

vivid hemlock
#

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

rancid sigil
#

๐Ÿ‘ 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

vivid hemlock
#

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?

rancid sigil
#

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

vivid hemlock
#

in test mode, I can't expect email at all?

#

through dashboard? can you give me the dashboard link to trigger

rancid sigil
#

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"

vivid hemlock
#

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

rancid sigil
#

That invoice has already been paid so you can't sent it again

vivid hemlock
#

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?

rancid sigil
#

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

vivid hemlock
#

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?

rancid sigil
vivid hemlock
#

this setting?

rancid sigil
#

yup!

vivid hemlock
#

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?

rancid sigil
#

correct!

vivid hemlock
#

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

rancid sigil
#

๐Ÿ‘ happy to help! Definitely try it all out and make sure it does waht you want ๐Ÿ™‚

vivid hemlock
#

yep. (unfortunately finialize, send myself invoice can't be tested in test mode )

#

afraid to make it live without testing

rancid sigil
#

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

vivid hemlock
#

Bill.sent? you mean webhook event?

rancid sigil
vivid hemlock
#

thanks I'll read the links you provided.

#

thanks for your kind explain

#

thanks again @rancid sigil

#

have a good time for your rest of the day