#maufcost - Confirm PI errors

1 messages · Page 1 of 1 (latest)

low pagoda
#

Hi 👋
do you have an example PI I could look at?

old nova
#

Yes. Here's one of the PI's id: pi_3LLWJcDHu3ajdCof1O8TpeSx_secret_suGKkbebyN6H1QXB7UbUGjJzG

#

The specific error is: Payment confirmation error {"code": "Failed", "declineCode": null, "localizedMessage": "There was an unexpected error -- try again in a few seconds", "message": "Não há payment_intent: 'pi_3LLWJcDHu3ajdCof1O8TpeSx'", "stripeErrorCode": "resource_missing", "type": "invalid_request_error"}

old nova
#

Did you manage to take a look at it?

low pagoda
#

Not yet just getting to it. It's been really busy today

old nova
#

No prob. Take your time. I can wait here 🙂

low pagoda
#

Okay so the PI is just fine and this error is coming from the Stripe.js library. How are you confirming the payment intent?

old nova
#

I am confirming on my React Native app as such:

#
        const billingDetails = { email: user ? user.email : "no-email" }

        // Creates payment intent and fetches the intent's client secret from the backend
        const { clientSecret } = await createPaymentIntentAndCaptureFunds(order)

        console.log(clientSecret)

        const { paymentIntent, error } = await confirmPayment(clientSecret, {
            paymentMethodType: 'Card',
            paymentMethodData: { billingDetails },
        })

        if (error) {
            console.log(error);
        } else if (paymentIntent) {
            // console.log('paymentIntent: ', paymentIntent);
        }
low pagoda
old nova
#

Yes. Correct

#

It's so weird. Everything was working just fine. Then, I switched from my personal account to my business account and swapped the keys and the PIs are not confirmed anymore

low pagoda
#

Okay....wait a sec. You just said the magic words. Swapped the keys. I think not all the keys are properly swapped.
Can you translate this bit for me?

Não há payment_intent: 'pi_3LLWJcDHu3ajdCof1O8TpeSx

old nova
#

This means: "There isn't a payment intent: pi_3LLWJcDHu3ajdCof1O8TpeSx"

low pagoda
#

Perfect

#

yes so what is means is that the Payment Intent was created on the back-end with an API key that is from a different account than the API key used on the front-end

old nova
#

Jeez. I've checked that three times. Gonna check it again

low pagoda
#

The best way to check is to have the API keys logged at runtime just prior to when the PI is created/confirmed.

#

When apps get bigger it can be easy to lose track of which variable gets assigned where

old nova
#

That's a great tip. I'm gonna log them as see what comes up

#

Duuuuuude. I believe xcode + metro cached the previous public key on my virtual env. Recompiling everything now

low pagoda
#

Ugh. I'm not the biggest fan of XCode....so I'm not surprised

old nova
#

That was it. Metro or xcode must've cached it. Everything works now.

#

Thanks for your time. As always, splendid work y'all