#nhannguyenvan_code

1 messages ยท Page 1 of 1 (latest)

pallid doveBOT
#

๐Ÿ‘‹ 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/1264896466447634483

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

ionic flareBOT
#

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.

swift bone
#

I mean user type a promotion code in coupon and validate this is valid or not

#

something like "SALE50OFF"

stoic cliff
swift bone
#

I use invoice, step bellow:
Steps to use discounts with stripe
Split the payment form into two steps
Event details and coupon field
Payment form (card details, apple pay, google pay)
User enters or skips the coupon details on screen one and presses the submit/next button. Then we hit the API and do the following
Create a new invoice - https://docs.stripe.com/api/invoices/create
Create a new invoice item with the invoice id from step a and the coupon code if entered by the user in 1.a - https://docs.stripe.com/api/invoiceitems/create
Once the invoice item is created and attached to the invoice, finalise the invoice - https://docs.stripe.com/api/invoices/finalize
It will generate a payment intent attached to the invoice object
Return that payment intent id to the frontend
Use the payment intent id to render the payment form from step 2
User enters the card details and clicks pay now
Confirm the payment on the frontend using the stripe API (how it is working currently)

#

--
If user enter promotion code. I want call api to validte it

pallid doveBOT
limber wraith
swift bone
#

Yep so I want a step before to validate the promotioncode is valid in specify subscription or not before create invoice

limber wraith
#

There is no endpoint really to validate the application of a coupon other than just trying to apply it

swift bone
#

no way to validate code is valid in products?

limber wraith
swift bone
#

So I add promotion code -> create preview invoice -> check preview invoice is valid before create reality invoice with promotion code?

limber wraith
#

Yep should work

swift bone
#

sounds good, thank you, let me try it

#

Hey mate

#

relate this follow. Do you think should update any step? Please corrrect it and give better guidance if needder

limber wraith
#

Seems fine, it's just a bit cumbersome because that's not really how the Invoices API is supposed to work (i.e. use the intent secret on the front-end)

swift bone
#

can you explain more detail?

#

after user click paynow in payment element, I wwill call strip.confirmpayment

limber wraith
#

What you have is fine. There's a lot of API calls sure, to create the invoice, add the items, etc. But that's just how the API works/is designed โ€“ nothing you can do to optimise that

swift bone
#

thanks mate, will try thiss flow