#karryon_code

1 messages ¡ Page 1 of 1 (latest)

thin swallowBOT
#

👋 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.

solar cypress
#

it cut out the code, here it is:

thin swallowBOT
native mortar
#

Custom payment methods are not available with Checkout. We document this here

solar cypress
#
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;```
solar cypress
turbid beacon
#

Hi, taking over as my teammate needs to step away.

solar cypress
#

No problem! Nice to meet you

turbid beacon
solar cypress
#

Got it! I'll try that

turbid beacon
solar cypress
#

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?

turbid beacon
solar cypress
#

I seem to qualify based on the docs, but i dont see it still

solar cypress
#

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?

turbid beacon
#

What do you mean? Can you reword your ask please?

solar cypress
#

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?:

turbid beacon
#

That is on the client-side

solar cypress
turbid beacon
#

If that is not it, can you confirm what you're looking for here?

solar cypress
#

Ill get back to you

#

May take an hr ish

thin swallowBOT