#zzawaideh-react-upgrade

1 messages ยท Page 1 of 1 (latest)

ashen sphinx
#

Hi there! Do you already have a paymentmethod saved for the Customer?

alpine hamlet
#

Hey guys

fallow cedar
#

I have a payment intent on my server for one time purchases

#

That is it

alpine hamlet
#

@fallow cedar Stripe API allows you to do a recurring payment

fallow cedar
#

the one time charge uses PaymentElement

ashen sphinx
#

Ah okay and you expect to always collect the one-time first ahead of upgrading to the recurring Subscription?

fallow cedar
#

So the business model is that customers can buy an online product one time (I already have this part). Or they can get a premium plan and get unlimited free products

ashen sphinx
#

And the premium is monthly, correct?

fallow cedar
#

Yes

ashen sphinx
#

Okay cool. So you'll want to integrate two flows.

fallow cedar
#

Yes

ashen sphinx
#

First, for your one-time payment, you will want to make a couple changes.

fallow cedar
#

I already have one

#

Why?

alpine hamlet
#

@ashen sphinx isn't it easier to have just different code for the reccuring one?

ashen sphinx
#

If you already have the Customer and PaymentMethod then you can just create the Subscription, but if you don't have either of those yet then you will need the whole Subscription flow.

alpine hamlet
#

Just as a side note, if it gets too complicated, you can just have the customer pay every month manually using the one time payment way

fallow cedar
#

app.post('/create-checkout-session', async (req, res) => {
const session = await stripe.checkout.sessions.create({
line_items: [
{
price_data: {
currency: 'usd',
product_data: {
name: 'T-shirt',
},
unit_amount: 2000,
},
quantity: 1,
},
],
mode: 'payment',
success_url: 'https://example.com/success',
cancel_url: 'https://example.com/cancel',
});

res.redirect(303, session.url);
});

#

Can I use this to allow a subscription purchase?

ashen sphinx
#

You can use Stripe Checkout if you prefer โ€” you would use mode: 'subscription'.

#

However, if you already have Payment Element implemented then it seems a bit odd you would want to use Checkout.

fallow cedar
#

They are for two different types of purchases

#

That is why

#

Is that bad?

#

This is my first time using stripe, so I may not know what is right

ashen sphinx
#

I mean it is fine from the Stripe side of things. Just a little weird you would want to include a redirect as well as an embedded flow on your website.

#

But that is up to you.

fallow cedar
#

Oh okay, thank you.

#

I am getting the following error: You must provide at least one recurring price in subscription mode when using
prices.

#

Does the "unit_amount" not suffice for the price?

ashen sphinx
#

The interval indicates how it should recur

fallow cedar
#

What purpose does this data serve?

ashen sphinx
#

It determines whether it is a daily/weekly/monthly/annual sub

fallow cedar
#

Ahhhh okay. Thank you

#

Ill take a look

ashen sphinx
#

๐Ÿ‘

fallow cedar
#

Would this work to create a product that bills every month?

ashen sphinx
#

Yep that looks good to me.

#

Best thing to do is to test it ๐Ÿ™‚

fallow cedar
#

I was about to ask about this

#

Thank you so much

#

You are awesome