#harshit-reactnative-ephemeralkey

1 messages · Page 1 of 1 (latest)

cedar cloakBOT
covert ice
#

harshit-reactnative-ephemeralkey

#

@gentle ether 99.9% of the time the error is really because you didn't pass the right value for the secret.

gentle ether
#

It works perfectly fine on android

#

the same exact thing

#

same value for the secret

covert ice
#

I think the first step is to cleanly log what you are passing to the iOS SDK first. It's likely something is wrong in your code still. Can you please share your exact code for that part and clean logs of what you are logging (except the API key)

gentle ether
#

the secret I'm passing is something like {customerEphemeralKeySecret: "ephkey_XXXXXXVUYL9I6Y4Ss5XXXXX"}

#

I will give you the exact format, android vs iOS

covert ice
#

thanks, make sure you log if there are any invisible characters or spaces before/after. Also share exact code, exact logs, an example id (it's a secret key but sadly not sure how else to debug) and also exact version of the ReactNative SDK

gentle ether
#

Hi @covert ice, DM'ed you

covert ice
#

please share the full info here, just redact the values so that it's easier for other people on my team to help if needed. But I'm looking at what you DM-ed me

#

also confirm if those are hardcoded values in the code

gentle ether
#

the values aren't hardcoded, they're coming from server

covert ice
#

okay, can you try hardcoding them just to see what happens?

Can you also share your current real code since what you shared isn't really your code

gentle ether
#

Here is the log
// for iOS
await initPaymentSheet({
"allowsDelayedPaymentMethods": true,
"customerEphemeralKeySecret": "ephkey_XXXXXXXXUYL9I6Y4SXXXXX",
"customerId": "cus_P9XXXXXyuA12H",
"defaultBillingDetails": {
"email": "mjeXXXXX@gmail.com",
"name": "XXXXan"
},
"merchantDisplayName": "XXXXXXX",
"paymentIntentClientSecret": "pi_3ObSDLGVUYL9I6Y42yXXXX_secret_CrQc3KZgrguQkkIVFPrXXX"
})
// gives error as {"code": "Failed", "declineCode": null, "localizedMessage": "customerEphemeralKeySecret format does not match expected client secret formatting.", "message": "customerEphemeralKeySecret format does not match expected client secret formatting.", "stripeErrorCode": null, "type": null}

// for android
await initPaymentSheet({
    "allowsDelayedPaymentMethods": true,
    "customerEphemeralKeySecret": "ephkey_XXXXXXXXUYL9I6Y4SXXXXX",
    "customerId": "cus_P9XXXXXyuA12H",
    "defaultBillingDetails": {
        "email": "mjeXXXXX@gmail.com",
        "name": "XXXXan"
    },
    "merchantDisplayName": "XXXXXXX YYYYYYYY, Plano",
    "paymentIntentClientSecret": "pi_3ObSGzGVUYL9I6Y4XXXX_secret_Kk6dlQJoDI0Zt5IM4XXXX"
})
// works fine
#

Here is my code

const stripeCustomerId = savedCardDetails?.data?.stripeCustomerId
  const ephemeralKey = savedCardDetails?.data?.ephemeralKey
  const orderId = placeOrderResponse?.id
  const selectedMerchantsName = selectedMerchants?.name
  // @ts-ignore
  const userName = profile?.name;
  const userEmail = profile?.email;
  const { initPaymentSheet, presentPaymentSheet } = useStripe();

const options = {
      merchantDisplayName: selectedMerchantsName || 'XXX Default Name',
      customerId: stripeCustomerId,
      customerEphemeralKeySecret: ephemeralKey,
      paymentIntentClientSecret: clientSecret,
      allowsDelayedPaymentMethods: true,
      defaultBillingDetails: {
        name: userName,
        email: userEmail,
      },
    };
    console.log('initPaymentSheet', options);
    const { error } = await initPaymentSheet(options);

    if (error) {
      console.log(`Error initializing PaymentSheet }`, error);
      console.error(error);
    } else {
      await openPaymentSheet()
      setLoading(true);
    }
covert ice
#

Okay so first try hardcoding that customerEphemeralKeySecret and see what it does/says

gentle ether
#

Sure

#

Gives the same error

covert ice
#

Okay can you share your exact ReactNative SDK version please?

gentle ether
#

Its 0.28.0

covert ice
#

Any chance you can try the latest version as 0.28.0 is from June 2023? Or are you using Expo?

gentle ether
#

Yeah, I'm using expo

covert ice
#

Ack that makes things harder as Expo is drastically harder to use and debug sadly

gentle ether
#

Yeah, don't have access to native code :/

covert ice
#

I'm looking into how we can help you debug, will take some time unfortunately

gentle ether
#

Tried upgrading the version but probably since the native SDK version is same, nothing changes!

covert ice
#

since the native SDK version is same
not sure what that could mean, we definitely upgrade the underlying iOS and Android SDK with higher versions of our ReactNative SDKs

#

@gentle ether looking at what you DM-ed me, you seem to pass the EphemeralKey id instead of it's secret

#

I don't understand how this could even work on Android but I think that's your real bug

gentle ether
#

Oh, I will try to change that and test it

covert ice
#

Okay I confirmed that for some reason Android basically ignores that value

#

I'm really sorry, it's such an obvious validation mistake on our part and so hard to figure out

gentle ether
#

@covert ice it works! I think android ignores it, yes

covert ice
#

Yeah I'm working with our eng teams to fix this in a future version, so confusing

#

also someone on that team replied on that Github issue for other developers

gentle ether
#

Thank you so much for the help! 🙂