#penguin420_

1 messages · Page 1 of 1 (latest)

ruby dirgeBOT
limber river
#

hey!

jaunty steppe
limber river
#

what is there then?

jaunty steppe
limber river
#

cause there was in payment intent

limber river
jaunty steppe
limber river
# jaunty steppe On the Payment Intent creation API, https://stripe.com/docs/api/payment_intents/...

right done,

  • error Error: Received unknown parameters: 0, 1
    at StripeError.generate (C:\Users\fuzzb\Downloads\UI update urlcut\urlcut\node_modules\stripe\cjs\Error.js:10:20)
    at res.toJSON.then.Error_js_1.StripeAPIError.message (C:\Users\fuzzb\Downloads\UI update urlcut\urlcut\node_modules\stripe\cjs\RequestSender.js:105:54)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
    digest: undefined
    }
#

where am i getting this from

#

nvm

#

ill check the link

#
  • error Error: No such source: 'card'
#

how

#
 if (items[0].id === "Personal") {
      const customer = await stripe.customers.create({
        email: userinfo.email,
        name: userinfo.username,
      });

      const paymentIntent = await stripe.subscriptions.create({
        customer: customer.id,
        items: [
          {
            price: "price_1NQGBeL6k3oFrmnnKPdotzOD",
          },
        ],
        currency: "gbp",
        payment_settings: {
          payment_method_types: ["card", "paypal"],
        },
        default_source: "card",
      });
    }

#

does default source go into payment settings object?

jaunty steppe
limber river
#

wait what i do not understand

#

how do i know there card number etc??!?

jaunty steppe
limber river
#

yeh but why

#

what abt in live mode

jaunty steppe
#

Let's back up, what integration documentation are you using?

limber river
#

i used this at firs

#
// This is your test secret API key.
const stripe = require("stripe")(process.env.STRIPE_SECRET_KEY);

const calculateOrderAmount = (items) => {
  // Replace this constant with a calculation of the order's amount
  // Calculate the order total on the server to prevent
  // people from directly manipulating the amount on the client
  return 1400;
};

export default async function handler(req, res) {
  const { items } = req.body;

  // Create a PaymentIntent with the order amount and currency
  const paymentIntent = await stripe.paymentIntents.create({
    amount: calculateOrderAmount(items),
    currency: "eur",
    automatic_payment_methods: {
      enabled: true,
    },
  });

  res.send({
    clientSecret: paymentIntent.client_secret,
  });
};
#

and that is how easy it was

#
{clientSecret && (
                <Elements options={options} stripe={stripePromise}>
                  <CheckoutForm />
                </Elements>
              )}
``` and this is my frontend
jaunty steppe
limber river
#

thanks

#

i do not understand

jaunty steppe
#

Which part on the document do you not understand?

limber river
#

look

#

used to be like that

#
// This is your test secret API key.
const stripe = require("stripe")(process.env.STRIPE_SECRET_KEY);

const calculateOrderAmount = (items) => {
  // Replace this constant with a calculation of the order's amount
  // Calculate the order total on the server to prevent
  // people from directly manipulating the amount on the client
  return 1400;
};

export default async function handler(req, res) {
  const { items } = req.body;

  console.log(items[0].id);

  if (items[0].id === "Personal") {
    const paymentIntent = await stripe.paymentIntents.create({
      amount: calculateOrderAmount(items),
      currency: "gbp",
      payment_method_types: ["card", "paypal"],
    });

    res.send({
      clientSecret: paymentIntent.client_secret,
    });
  }
}
#

and i want it like that

#

with subscribtions tho

#

not recoding the whole thing

jaunty steppe
limber river
#

??

#

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

#

what is that

#

i can tell it is nodejs backend but still

#

const paymentIntent = await stripe.subscriptions.create({
customer: customer.id,
items: [
{
price: "price_1NQGBeL6k3oFrmnnKPdotzOD",
},
],
currency: "gbp",
payment_settings: {
payment_method_types: ["card", "paypal"],
},
});
}

#

i just want it like this simple

jaunty steppe
limber river
#

wait

#

works???

jaunty steppe
#

On the server-side, after your create the subscription with status incomplete using payment_behavior=default_incomplete. You'd want to return the client_secret from the subscription’s first payment intent to the frontend to complete payment.

#

Yea!

jaunty steppe
#

Happy to help!

#

Sure

limber river
#

thanks!

#

how can i get this

#

like credit card or like what they paid with

#

is it possible not to use webhooks and validate by payment intent secret

#

cause it seems to change on every payment

jaunty steppe
#

You can retrieve the Payment Intent, https://stripe.com/docs/api/payment_intents/retrieve to attain the payment method details used. I do not understand what you mean by 'is it possible not to use webhooks and validate by payment intent secret', can you add more details?

limber river
jaunty steppe
#

What does 'validate' mean here?

limber river
#

to make sure they have paid

#

and then i can give the user premium

#

on the backend

#

so they cannot just go to premium? a random query and get premium

jaunty steppe
#

Ah, I see. It's highly recommended that you listen to webhook for Payment Intents that succeeded.

limber river
#

and is it normal to have the same customer cause each time i make a request to the backend it makes one

jaunty steppe
limber river
jaunty steppe
#

Bevause you're making requests each time to retirve the Payment Intent, and when you grow 10X, you put way too much load on making these requests.

limber river
#

ahh i see!

jaunty steppe
limber river
#

ah cool!

#

and also

#

webhooks

#

how can i test on local

#

on vsc

jaunty steppe
limber river
#

Thank you very much!

jaunty steppe
#

Happy to help!

limber river
#

it works perfect!!! thanks alot for your time and help!

jaunty steppe
#

Sure, have a great day!