#zelda.zonk

1 messages · Page 1 of 1 (latest)

lusty ridgeBOT
blissful gorge
flint jetty
#

'add_invoice_items' => [['price' => '{{PRICE_ID}}']], since i have to provide an PRICE_ID, does this mean i have to then add all my products to stripe then?

blissful gorge
flint jetty
#

does creating ad-hoc price using add_invoice_items.price_data create a product in stripe (price object) or is it just temporary price object?

blissful gorge
#

It'll be temp price object

flint jetty
#

ok great thanks, so ``` add_invoice_items.price_data.product required

The ID of the product that this price will belong to.``` is just my product id in the app database nothing to do with stripe products, I just need to pass a just a unique id for the product?

blissful gorge
#

A price should belong to a product. A product is the information of the item created with Stripe. It has to be a product ID in Stripe.

flint jetty
#

damn, ok so i do need to create product ID in Stripe for all my products then?

blissful gorge
#

Yup! Product creation will be required, but prices can be ad-hoc

flint jetty
#

I asked chatgpt about this, and got the following ``` Separate the cart items:
Before starting the payment process, you should separate the cart items into two groups: subscription products and non-subscription products.

Create a Setup Intent for subscriptions:
For the subscription products, create a Setup Intent. This is typically done on the server-side and involves specifying the relevant payment method and any other required details. The Setup Intent allows you to set up a future payment for the subscription.

Create a Payment Intent for non-subscription products:
For the non-subscription products, create a Payment Intent. This is also typically done on the server-side and involves specifying the payment method and the amount to be charged for the non-subscription products.

Confirm the Payment Intent for non-subscription products:
After creating the Payment Intent, confirm it on the server-side. This step will handle the immediate charge for the non-subscription products.

Handle the subscription products:
Once the Payment Intent for non-subscription products is confirmed successfully, you can proceed with handling the subscription products. This might involve associating the subscription with the user's account, setting up billing intervals, etc.

Complete the payment flow:
Once both the Setup Intent and the Payment Intent are successfully handled, you can complete the payment flow. You should provide appropriate feedback to the user to indicate that the payment process is complete.
#

if i did the above process, i wouldnt need to create product IDs in Stripe for all my products correct only for the subscriptio products

blissful gorge
#

Can you share what you're trying to achieve? The answer from chatgpt is two different independent payment integration flows for subscription and one-time payment that the customer will be charged twice for two different types of products instead of the single payment like what i suggested

flint jetty
#

ok so lets say i have 1000 products in my shop and 1 subscription product. most of the checkouts would be Payment Intents for single charges yes, and I dont have to create 1000 products in stripe. But if customer adds that 1 subscription product to cart along with a few other non-subscription products, now I have I have to create 1001 products in stripe in order to have one single payment is that correct?

blissful gorge
#

Yes, that's correct.

flint jetty
#

so is there a way to handle a checkout with a subcription and non-subscription products without having to create them all as products in stripe?

blissful gorge
#

Another alternative I can think of is to:

  1. Create the subscription only first and collect the saved payment method details
  2. Use saved payment method to charge the one-time payment with Payment Intent

With this flow, you only need to create the subscription product, but there will be two charges on customer statement - one for subscription and one for one-time payment

flint jetty
#

as it would get tricky doing this all on webhook event

blissful gorge
#

Or another alternative I can think of is to collect the payment method with Setup Intent first, then use the saved payment method to create a subscription and one-time payment. That will also work.

Steps:

  1. Use Setup Intent to save the payment method: https://stripe.com/docs/payments/save-and-reuse
  2. Create the subscription and set default_payment_method created from Step 1: https://stripe.com/docs/api/subscriptions/create#create_subscription-default_payment_method
  3. Create one-time payment with payment_method created from Step 1: https://stripe.com/docs/payments/save-and-reuse?platform=web&ui=elements#charge-saved-payment-method
flint jetty
#

but using stripe.confirmPayment it will redirect to return_url, thats when i would Create one-time payment with payment_method ?

#

but stripe says not to count on return_url and instead use webhooks

blissful gorge
flint jetty
#

yess but stripe docs say the user could close the browser before callback of return_url, so instead rely on webhooks to finalise order correct?

#

so i would have to complete step 3: Create one-time payment with payment_method created from Step 1 from webhook event

blissful gorge
#

Yes, that's possible. Your system can do both or either of them by

  1. checking payment intent status after return_url and charge one-time payment
  2. wait for payment_intent.succeeded or invoice.paid event, then get saved payment method to charge one-time payment

If you do both, your system should ensure that the customer is only charged once for one-time payment

flint jetty
#

right but just to clarify there would still be two charges on customer statement - one for subscription and one for one-time payment

blissful gorge
#

Yup! There will be two charges if you do not wish to use add_invoice_items with pre-created product for one single payment

flint jetty
blissful gorge
#

This will also work, but it'll be creating the one-time payment (full flow) first, then create the subscription. You system should also ensure that the Payment Intent creation in Step 6 includes setup_future_usage: 'off_session' to save the payment method in order to be used in subscription.

flint jetty
#

right ok thanks for all your help

#

is there a way in discord to save this convo for later refernece?

blissful gorge
flint jetty
#

thanks