#xyz_api

1 messages ยท Page 1 of 1 (latest)

pearl ploverBOT
#

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

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

fickle hearth
#

Hey there, let me take a look.

vague kestrel
#

Yes please.. we wanna fix this ASAP

#

I get payment failed : no such payment intent 'some id' is displayed

fickle hearth
#

Ok, it appears you're attempting to confirm a PaymentIntent (req_9VPX078u04CaKB) that was created in the Sandbox in Live Mode (req_U8IuQBvE13u5aP) which you cannot do.

vague kestrel
#

How can I change that. Can you guide me please

fickle hearth
#

Objects created in the Sandbox are not available to Production and vice versa.

#

If your intent is to confirm the PaymentIntent that was created in the Sandbox, you'll need to make sure you're using the API keys associated with the Sandbox when sending the API request.

vague kestrel
#

I changed it to production now. Updated the keys with live keys

#

Do I need to change anything else ?

#

This is my code

console.log('๐Ÿ’ณ Stripe routes initialized');

stripeRouter.post('/create-payment-intent', validatePaymentData, async (req, res) => {
try {
const { amount } = req.body;

const paymentIntent = await stripe.paymentIntents.create({
  amount: Math.round(amount * 20),
  currency: 'usd',
  automatic_payment_methods: {
    enabled: true,
  },
});

console.log('โœ… Payment intent created:', { id: paymentIntent.id });

res.status(200).json({
  clientSecret: paymentIntent.client_secret,
});

} catch (error: any) {
console.error('โŒ Payment error:', error);

// Handle different Stripe error types
let errorMessage = 'Payment processing failed';
let statusCode = 500;

if (error.type === 'StripeCardError') {
  // Card was declined
  errorMessage = error.message || 'Your card was declined';
  statusCode = 402;
} else if (error.type === 'StripeAuthenticationError') {
  // Invalid API keys
  errorMessage = 'Payment system configuration error';
  statusCode = 500;
} else if (error.type === 'StripeInvalidRequestError') {
  // Invalid parameters
  errorMessage = 'Invalid payment request';
  statusCode = 400;
} else if (error.type === 'StripeRateLimitError') {
  // Too many requests made
  errorMessage = 'Payment system busy, please try again';
  statusCode = 429;
}

res.status(statusCode).json({ 
  error: errorMessage,
  code: error.code || 'unknown',
  type: error.type || 'unknown'
});

}
});

fickle hearth
#

If you've switched to production and updated to the live keys you should be fine.

#

You just need to be sure you're no longer trying to interact with anything you've done in the Sandbox like in this case.

vague kestrel
#

I used a working credit card but still it returns the same error. Should we add stripeAccount in the header while passing ?

#

Is that the probable cause ?

fickle hearth
#

Can you provide the request ID that was returned?

vague kestrel
#

intent ID ?

#

Can you let me know the fix ASAP please. We wanna take the site live shortly

fickle hearth
#

This is the same as previous. The PaymentIntent is being created in the Sandbox account (req_DrFbn7DhXVOWwM) and being confirmed in Live Mode (req_7ZJmaGarSVrvT0)