#boss-amp_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/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.
- boss-amp_code, 1 hour ago, 9 messages
TAP TO SIMULATE PAYMENT
Ah you are saying you see an error of:
You must provide a paymentIntent that was returned from either createPaymentIntent or retrievePaymentIntent."
?
YES
ERROR โ Error confirmPaymentIntent: {"code": "INTEGRATION_ERROR.INVALID_REQUIRED_PARAMETER", "message": "You must provide a paymentIntent that was returned from either createPaymentIntent or retrievePaymentIntent."}
Yep so that seems pretty self explanatory. Have you logged out your PaymentIntent that you are passing to collectPaymentMethod()?
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}));
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?
no, this is my entire code
Oh okay yeah you were doing JSON.stringify which is why the log looks weird
Hrmmm
That does look fine though...
I'm doing something wrong ๐
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
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."}
Have you done a full rebuild of your app since you fixed that?
this was the solution
const { paymentIntent: confirmedPaymentIntent, error: confirmError } = await confirmPaymentIntent({ paymentIntent })
I don't have the error anymore
What did you change?
does it look good to you? https://dashboard.stripe.com/test/payments/pi_3RIy6GFH7PYR773I1AO9IJwt
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
this:
const { paymentIntent: confirmedPaymentIntent, error: confirmError } = await confirmPaymentIntent(collectedPaymentIntent);
I changed it to this:
const { paymentIntent: confirmedPaymentIntent, error: confirmError } = await confirmPaymentIntent({ paymentIntent })
Did you un-alias from the above?
Is that what you are saying
But yeah that PaymentIntent succeeded
So looks good
Did you un-alias from the above? - I don't understand you
bad - await confirmPaymentIntent(collectedPaymentIntent);
goodc- await confirmPaymentIntent({ paymentIntent })
Ah I see now
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
You were previously passing the response from collectPaymentMethod instead of the original PaymentIntent object.