#gilbot-reactnative-error

1 messages · Page 1 of 1 (latest)

twin dome
#

Hello @haughty bobcat can you share the doc you are following and your exact code for the confirm part?

haughty bobcat
#

absolutely

#

heres the doc

#

oh wait i think i might see the error. one second

twin dome
#

🤞

haughty bobcat
#

damn nvm heres out code snippet

#

const { paymentIntent, error } = await confirmPayment(clientSecret, {
paymentMethodType: 'Card',
paymentMethodData: {
billingDetails: {
phone: +${userDetails?.phone ?? ''},
},
},
});

    if (error) {
      // do something
      console.log('error', error);
    }

    if (paymentIntent) {
      console.log('sdfsdf', paymentIntent);
      // payment is successful. create order
    }
  },
#

@twin dome for context when creating the card paymentMethod, im supplying the card number, exp month, exp year, cvc and postal code. Does this expect any additional information?

twin dome
#

Looking

#

What do you mean you are "creating a paymentMethod" since you aren't doing that here? You're just confirming the PaymentIntent right?

haughty bobcat
#

correct right here im just confirming the paymentIntent

twin dome
#

so you are not creating the PaymentMethod? What's the exact output of your code, where exactly does it break?

haughty bobcat
#

no we create the payment method else where and we used the saved paymentMethod id when creating the paymentIntent before confirming

#

in the code snippet i sent in a couple messages ago, we always get an error that looks like this


{
  "stripeErrorCode": null,
  "declineCode": null,
  "localizedMessage": "Card details not complete",
  "message": "Card details not complete",
  "type": null,
  "code": "Failed"
}
twin dome
#

I have no idea what that means

#

you say you don't create a payment method but also say you do

#

Sorry to be pushy but I really need you to be crisp about what's happening

haughty bobcat
#

so we do create a payment method id but not in this flow. By the time we attempt to confirm a paymentIntent, we used a created paymentMethod id to create/confirm the paymentIntent, however every time we try to confirm the payment intent, we get the above error message

twin dome
#

I'm so sorry this is still so unclear

#

Are you saying that you have a PaymentMethod pm_123 and you explicitly confirm the PaymentIntent pi_ABC with it, but then client-side for some reason you call confirmPayment() again? Because that will never work

haughty bobcat
#

no

#

we confirm on clientSide only

twin dome
#

but you just said the complete opposite earlier

#

By the time we attempt to confirm a paymentIntent, we used a created paymentMethod id to create/confirm the paymentIntent

#

you literally said this

haughty bobcat
#

sorry if that was confusing, let me elaborate, we create the intent and attach a paymentMethod to in our API. Once the client receives the secret in the response, we then calll confirmPayment and get the error

twin dome
#

cool

#

that's all completely expected

haughty bobcat
#

how come?

twin dome
#

you're misunderstanding the whole flow and not following our doc I would say. That doc is here to show you have to have a UI to collect card details inline as you confirm. But your are not doing that, you already have a PaymentMethod pm_45678 and trying to use that and not the existing UI to collect card details. Right?

haughty bobcat
#

yea we initially wanted to use the Card component however our team wanted to style it differently which made us move in a different direction

#

in that case im guessing we have to confirm the paymentIntent on our backend instead?

twin dome
#

I think you have to tweak your code to explicitly pass the existing pm_123

haughty bobcat
#

when creating the intent?

twin dome
#
  paymentMethodType: 'Card',
  paymentMethodData: {
    paymentMethodId: 'pm_ABC',
    billingDetails: {
      phone: +${userDetails?.phone ?? ''},
    },
  },
});```
#

no

haughty bobcat
#

oh interesting let me give that a shot

#

same error

twin dome
#

are you sure you put the right payment method id in there?

haughty bobcat
#

yup

#

ok i reboot the app and got a different error, i got a different error this time around but this one makes sense

{
  "stripeErrorCode": "resource_missing",
  "declineCode": null,
  "localizedMessage": "There was an unexpected error -- try again in a few seconds",
  "message": "No such payment_intent: 'pi_3Lf5b1DrfnMckC5C4pKntHdX'; a similar object exists in test mode, but a live mode key was used to make this request.",
  "type": "invalid_request_error",
  "code": "Failed"
}
#

looks like we arent using a test key in dev

#

is that correct?

twin dome
#

yes

haughty bobcat
#

ahh yea one of our devs used the live key by mistakes, but this looks to solve our problem, thanks!