Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expired API Key provided Error when executing presentPaymentSheet() #1661

Open
fimbres opened this issue May 16, 2024 · 1 comment
Open

Expired API Key provided Error when executing presentPaymentSheet() #1661

fimbres opened this issue May 16, 2024 · 1 comment

Comments

@fimbres
Copy link

fimbres commented May 16, 2024

Describe the bug
When I open the payment sheet in my react native with expo app it opens with loading state, then it closes and an error appears saying: Expired API Key provided: ek_test_YW*********************************************************************_******r1xQ.

Fun fact 1: I don't know what does 'ek' at the start of the key even means, cause for example I think pk means public key or sk means secret key. And any of my current keys ends with 'r1xQ', so I don't know where that key came from.

Fun fact 2: It was working and suddenly after doing a couple changes in my implementation to change the appearance of the sheet. It began to crash.

To Reproduce
Steps to reproduce the behavior:

  1. Build React Native App
  2. Implement the code here: https://docs.stripe.com/connect/direct-charges
  3. Open the sheet and maybe face the error.

Expected behavior
be able to open the sheet again, and complete a payment.

Screenshots
If applicable, add screenshots to help explain your problem.
Screenshot 2024-05-15 at 10 46 56 p m
Screenshot 2024-05-15 at 10 47 23 p m

Smartphone (please complete the following information):

  • Device: IPhone 15 Pro Simulator
  • OS: IOS 17.4

Additional context
Add any other context about the problem here.

@fimbres
Copy link
Author

fimbres commented May 16, 2024

Some Code:

const openPaymentSheet = async () => {
    const { error } = await presentPaymentSheet();

    if (error) {
      Alert.alert(`Error code: ${error.code}`, error.message);
    } else {
      Alert.alert('Success', 'Your order is confirmed!');
    }
  };

  const initializePaymentSheet = async () => {
    setStatus('loading');

    const data = await createCheckout(userData?.stripeCustomerId!, userData?.stripeEphemeralKey!, totalPrice);

    const { error } = await initPaymentSheet({
      merchantDisplayName: "Paycon México",
      customerId: data?.customer,
      customerEphemeralKeySecret: data?.ephemeralKey,
      paymentIntentClientSecret: data?.paymentIntent!,
      allowsDelayedPaymentMethods: false,
      defaultBillingDetails: {
        name: userData?.name,
      },
      returnURL: 'paycon://home/checkout'
    });

    if (error) {
      setStatus('error');
    }
    else {
      setStatus('success');
    }
  };

  useEffect(() => {
    initializePaymentSheet();
  }, []);

<AppButton variant='primary' disabled={status === 'loading'} onPressIn={openPaymentSheet}>Realizar Compra</AppButton>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant