#boss-amp_code

1 messages ยท Page 1 of 1 (latest)

raven lightBOT
#

๐Ÿ‘‹ 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/1366501575740096634

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

steep burrow
raven lightBOT
steep burrow
#

I have this error after clicking simulate payment

thorny schooner
#

Hello there

#

What does that say on the screen?

steep burrow
#

TAP TO SIMULATE PAYMENT

thorny schooner
#

Ah you are saying you see an error of:

You must provide a paymentIntent that was returned from either createPaymentIntent or retrievePaymentIntent."

?

steep burrow
#

YES

ERROR โŒ Error confirmPaymentIntent: {"code": "INTEGRATION_ERROR.INVALID_REQUIRED_PARAMETER", "message": "You must provide a paymentIntent that was returned from either createPaymentIntent or retrievePaymentIntent."}

thorny schooner
#

Yep so that seems pretty self explanatory. Have you logged out your PaymentIntent that you are passing to collectPaymentMethod()?

steep burrow
#

logged out your PaymentIntent?

#

in backend?

#

const express = require('express');
const cors = require('cors');
require('dotenv').config();

const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);

const app = express();
app.use(cors());
app.use(express.json());

console.log('Stripe key:', process.env.STRIPE_SECRET_KEY);

// Endpoint do tworzenia ConnectionToken dla Terminala
app.post('/connection_token', async (req, res) => {
try {
const connectionToken = await stripe.terminal.connectionTokens.create();
res.json({ secret: connectionToken.secret });
} catch (err) {
console.error(err);
res.status(500).json({ error: err.message });
}
});

// ๐Ÿ“ข NOWY Endpoint: tworzenie PaymentIntent
app.post('/create_payment_intent', async (req, res) => {
try {
const { amount } = req.body; // Odbieramy kwotฤ™ z frontu
const paymentIntent = await stripe.paymentIntents.create({
amount: amount,
currency: 'pln',
payment_method_types: ['card_present'],
capture_method: 'automatic', // โœ… Automatyczne pobranie pieniฤ™dzy!
});

  res.json({
    clientSecret: paymentIntent.client_secret,
    paymentIntentId: paymentIntent.id,
  });
} catch (err) {
  console.error(err);
  res.status(500).json({ error: err.message });
}

});

const PORT = process.env.PORT || 4244;
app.listen(PORT, () => console.log(Stripe server listening on port ${PORT}));

thorny schooner
#

Nope in your frontend

#

Before calling collectPaymentMethod()

steep burrow
#

is that what you meant?

thorny schooner
#

Yep

#

Are you messing with anything here in your logs? Would expect a different order of properties... like id is always the first property.

#

Can you show me the updated code snippet with that log included?

steep burrow
thorny schooner
#

Oh okay yeah you were doing JSON.stringify which is why the log looks weird

#

Hrmmm

#

That does look fine though...

steep burrow
thorny schooner
#

Can you try not doing any aliasing here

#

I have no idea why that would mess with things...

#

Oh wait

#

Ah

#

You are passing collectedPaymentIntent.id

#

It should be the whole object

#

Remove .id and it should work

steep burrow
#

I know, I did it for a while for testing, I don't use it anymore and I still have the same error as at the beginning

#

I currently have this code

#

and still the same error - ERROR โŒ Error when confirmPaymentIntent: {"code": "INTEGRATION_ERROR.INVALID_REQUIRED_PARAMETER", "message": "You must provide a paymentIntent that was returned from either createPaymentIntent or retrievePaymentIntent."}

thorny schooner
#

Have you done a full rebuild of your app since you fixed that?

steep burrow
#

this was the solution

const { paymentIntent: confirmedPaymentIntent, error: confirmError } = await confirmPaymentIntent({ paymentIntent })

#

I don't have the error anymore

thorny schooner
#

What did you change?

steep burrow
#

this:

const { paymentIntent: confirmedPaymentIntent, error: confirmError } = await confirmPaymentIntent(collectedPaymentIntent);

I changed it to this:

const { paymentIntent: confirmedPaymentIntent, error: confirmError } = await confirmPaymentIntent({ paymentIntent })

thorny schooner
#

Did you un-alias from the above?

#

Is that what you are saying

#

But yeah that PaymentIntent succeeded

#

So looks good

steep burrow
#

Did you un-alias from the above? - I don't understand you

#

bad - await confirmPaymentIntent(collectedPaymentIntent);
goodc- await confirmPaymentIntent({ paymentIntent })

thorny schooner
#

Ah I see now

steep burrow
#

now the payment works, it goes through, but when I click cancel on the card screen, I get - ERROR โŒ Error during collectPaymentMethod: {"code": "USER_ERROR.CANCELED", "message": "Contactless transaction was canceled"}
and the payment is still Incomplete, it does not change to canceled

thorny schooner
#

You were previously passing the response from collectPaymentMethod instead of the original PaymentIntent object.