#karryon_code
1 messages ¡ Page 1 of 1 (latest)
đ 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/1367187816446033940
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
it cut out the code, here it is:
const express = require('express');
const stripe = require('stripe')(`sk_test_key`);
const router = express.Router();
router.post('/', async (req, res) => {
try {
const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
line_items: [
{
price_data: {
currency: 'usd',
product_data: {
name: 'Six Flags Reservation',
description: 'Includes park ticket + transportation.',
},
unit_amount: 9500,
},
quantity: 1,
},
],
mode: 'payment',
success_url: 'http://localhost:5174/payment?success=true',
cancel_url: 'http://localhost:5174/payment?canceled=true',
});
res.status(200).json({ sessionId: session.id });
} catch (error) {
console.error('Stripe session error:', error);
res.status(500).json({ error: 'Unable to create Stripe checkout session.' });
}
});
module.exports = router;```
Got it, is it possible to use an iframe instead of it opening a tab?
Hi, taking over as my teammate needs to step away.
No problem! Nice to meet you
That is not supported as my teammate suggested, https://docs.stripe.com/payments/payment-methods/custom-payment-methods#custom-payment-method-integrations and the only work around is to use it with PaymentElement: https://docs.stripe.com/payments/payment-element/custom-payment-methods
Got it! I'll try that
Sounds good, it's a more advanced integration but it will give you the supportability you're looking for: https://docs.stripe.com/payments/accept-a-payment-deferred
So I have auto payments enabled:
const express = require("express");
const stripe = require("stripe")(`sk_test_key`);
const router = express.Router();
router.post("/", async (req, res) => {
try {
const paymentIntent = await stripe.paymentIntents.create({
amount: 9500,
currency: "usd",
automatic_payment_methods: { enabled: true },
description: "Six Flags Reservation (Ticket + Transportation)",
});
res.status(200).json({ clientSecret: paymentIntent.client_secret });
} catch (error) {
console.error("Stripe PaymentIntent error:", error);
res.status(500).json({ error: "Unable to create payment intent" });
}
});
module.exports = router;```
These are the options it shows
Does PayPal not show in the test env?
It should as long as you've enabled it and it meets the requierements: https://docs.stripe.com/payments/paypal
Are you following this integration, https://docs.stripe.com/payments/accept-a-payment-deferred and https://docs.stripe.com/payments/payment-element/custom-payment-methods ?
async function handleSubmit(e) {
const { submitError, selectedPaymentMethod } = await elements.submit();
if (selectedPaymentMethod === '{{CUSTOM_PAYMENT_METHOD_TYPE_ID}}') {
// Process CPM payment on merchant server and handle redirect
const res = await fetch("/process-cpm-payment", { method: 'post' });
...
} else {
// Process Stripe payment methods
...
}
}
The process-cpm-payment endpoint, where's the integration for that?
What do you mean? Can you reword your ask please?
Yeah, sorry for confusing you. The code makes a post req to the /process-cpm-payment. Where is the source code for that endpoint, so I can add it to my backend?
Before I ask that, is this done on the client side or server side?:
That is on the client-side
Were you able to understand this?