#suren168

1 messages · Page 1 of 1 (latest)

spring marshBOT
lone hedge
#

What is your purpose of having an invoice?

sullen basin
#

i wanted to show all the items price etc. for example when i sent a receipt

#

also when the payment is successful i want to show all the details as well in the success page

#

the webhook is also where i use to store the data in my database. if there is no invoice i think most of the items wont be sent to the webhook?

lone hedge
#

I see! With Payment Element on Payment Intent, it's possible to send the receipt, but it will only have the amount charged without item breakdown: https://stripe.com/docs/receipts?payment-ui=elements

If you wish to use invoice, then:

Should I create/search customer when they login?
If the user has signed up on your website before, you should store the Stripe customer ID that maps to your own customer ID in the database. You shouldn't need to perform any search. If the customer is new, you may create the Stripe customer when he/she signs up an account with your website or when they perform their first checkout.

Should the invoice items be created and saved to the cart context I have when an item is added?
Invoice items should only be added when the customer has finalised the items to purchase and proceed to the checkout page.

Or should i skip all those steps and just create a regular payment intent and add most item data etc to the metadata field instead of creating an invoice.
If the purpose is to have receipt without breakdown, then regular Payment Intent on Payment Element should be sufficient without invoice. It'll be your business decision to decide what you would like to show and send to customer.

sullen basin
#

so im guessing what ive done is largely correct. I might have to do a loading indicator instead in that case. Maybe i can create the invoice before? So my steps will be something like.

The user logs in > I send the customer id which is saved via context to be able to use on my whole app. The user is ready to checkout .

Once the checkout button is clicked I create the invoice and items via a post request. I send the customer ID in the body of the post etc. At this stage the shipping method is not inputted nor has the address. the post request will give me the invoice id which I will use to add the shipping rate and then finalize once the user proceeds to payments. The intent is received and payment element is shown next.

spring marshBOT
sullen basin
#

So to simplify. I click checkout which takes me to the delivery page > I send the customer ID to create invoice + items > I enter the shipping and address click next button to go to payment > Invoice is now finalized with shipping and a client secret is sent to client > Stripe Payment > Success

restive crow
#

Hi @sullen basin I'm taking over this thread

sullen basin
#

hiya. Thankyou. just need a little more so i can finish it. Thanks for your help!

restive crow
#

It's a long discussion, can you tell me what you want to achieve and what problem you are facing?

sullen basin
#

basically when loading the payment element it's somewhat slow. I was wondering how to split the invoice creation. customer etc.

#

I currently create everything all at once when the payment page is loaded

#

customer invoice items finalize etc.

restive crow
#

Can you tell me more on "loading the payment element it's somewhat slow." ?

#

And I dont' think invoice has anything to do with paymennt element loading.

sullen basin
#

i think its mainly that i need the secret from the payment intent to be able to load payment elements

#

and if i do all of it at once on my server its slow.

restive crow
#

So it's not a problem about payment element loading

#

You might want to create the invoice before loading the checkout page, so that the client secret is ready