#joseph01

1 messages ยท Page 1 of 1 (latest)

reef wigeonBOT
lusty citrus
#

You can grab that and send the email to your customer on your server

fervent venture
#

After clicking it directly redirects to the checkout session link. How to just grab the link without redirect. And I am checking the link you provided.

slate trail
#

You can create a webpage and do it your checkout success. Then you can put crossdomain in Google Analytics, and voilรก! You will see the checkout session

fervent venture
lusty citrus
#

You control the redirect process

#

How are you creating checkout sessions? On your server?

robust wraith
#

no, but I need to get the list of the payouts mades on a customer account

lusty citrus
#

@robust wraith you're in the wrong thread

fervent venture
#

app.post('/create-checkout-session', async (req, res) => {

const products = req.body.products;
const country = req.body.country;

const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
line_items: [
...products.map(p => ({
price_data: {
currency: currency,
product_data: {
name: p.title,
images: [p.image.asset.url]
},
unit_amount: price,
},
quantity: qty,
}))
],
mode: 'payment',
success_url: "http://localhost:3000/services/registration",
cancel_url: "http://localhost:3000/services/registration",
});

res.json({ id: session.id });
});

#

Hey, like this am creating the link

lusty citrus
#

Ok so in your server just grab session.url

#

And use that to send to your customer

#

All server-side

#

And just don't implement a redirect to the url on your client side

fervent venture
#

Oh okay. Let me check once then.

lusty citrus
fervent venture
#

Hey, Thank you so much!! I am getting the url. Now how can I make URL open once only for payment and get's disabled if opened the link again. For security purposes.

#

Or if clicked the back button then the link doesn't work for payment. Either way

lusty citrus
#

There's not a easy way to handle this, but if I can understand your usecase, that might help a bit. What's the specific concern with being able to load the url multiple times? If it is paid, then the link becomes disabled

fervent venture
lusty citrus
#

If you explicitly set the amount when you create the session server-side it can't be tampered

fervent venture
#

But I saw to validate the link tamper and amount some use-shopping-cart package is used. But the issue is my app is not structured that way to implement right now. Or else would have done so. Any other solutions if you could give.

lusty citrus
#

Oh you're concerned about the amount that's passed from your frontend to the backend? What's your pricing structure look like? Does the amount you're charging vary a lot?

fervent venture
#

Yeah kind of. ๐Ÿ™ƒ

lusty citrus
#

Ok makes sense. Can you explain the pricing structure?

fervent venture
#

Pricing structure? I didn't understood ๐Ÿ˜‘

lusty citrus
#

So how does the amount vary? Are there a few options? Or does it depend on many factors? Just need more info here

fervent venture
#

Actually pricing is mainly changed from backend sanity headless cms. And there is multiple pricing according to currency of country.

lusty citrus
#

Ok. I just need to know more about what part of the front end process you're concerned about. If pricing is controlled on the backend, why do you need to handle price tampering?

fervent venture
#

Now the issue is we are allowing our customers to retain the cart from local storage. And from that the price is also getting stored. That's the only issue.

lusty citrus
#

Hm ok. I don't know how much I can advise on cart tampering specifically, but from the stripe side, if you have pre-defined price objects, that can help with tampering a bit since you'll be referencing price id's not amounts.

fervent venture
#

Wow that really a nice idea.

#

But how can I add the price_id's for more than 1 product? I have passed it for one product it's fine from that.

#

Can you help with that? And thank you for this ๐Ÿ™‚

#

price_data: {
currency: currency,
product_data: {
name: p.title,
images: [p.image.asset.url]
},
unit_amount: price,
},

will this work if I give price_id in place of amount for the unit_amount

lusty citrus
fervent venture
icy drift
#

๐Ÿ‘‹ stepping in as codename_duchess needs to step away

icy drift
#

The product/image is created ahead of time in this case when you create the Price

#

Recommend reading fully through the guide shared above and taking a look at the API Reference

fervent venture
icy drift
#

Right but your question was about how to not pass price_data and instead just pass price, right?

fervent venture
icy drift
#

So the image/name is created ahead of time here instead of inline

icy drift
fervent venture
#

But already I had the setup done in sanity. Now I have to do that in stripe dashboard.

icy drift
#

Not sure if that is a question? ๐Ÿ™‚

fervent venture
#

Haha. No thank you so much! Really appreciate!