条带错误react-Uncaught IntegrationError:元素值无效():clientSecret 应该是 ${id}_secret_${secret} 形式的客户端密钥

问题描述 投票:0回答:1

从 stripe 文档中,我已将 stripe 集成到基于反应打字稿的项目中。但我收到客户端秘密 ID 错误。下面是我的代码:

placeOrder.tsx:

import {Elements} from '@stripe/react-stripe-js';
import {loadStripe} from '@stripe/stripe-js';
import CheckoutForm from './Checkout';

// Make sure to call `loadStripe` outside of a component’s render to avoid
// recreating the `Stripe` object on every render.
const stripePromise = loadStripe('pk_test_..Pdx'); // public key from stripe dashboard

export default function PlaceORder() {
  const options = {
    // passing the client secret obtained from the server
    clientSecret: 'sk_test_.....YKGWngQO', // client secret from stipe dashboard
    theme: 'stripe',
  };

  
  return (
    <Elements stripe={stripePromise} options={options}>
      <CheckoutForm />
    </Elements>
  );
};

checkout.tsx:

import {PaymentElement} from '@stripe/react-stripe-js';

const CheckoutForm = () => {
  return (
    <form>
      <PaymentElement />
      <button>Submit</button>
    </form>
  );
};

export default CheckoutForm;

请帮我解决这个问题!

reactjs stripe-payments react-typescript
1个回答
0
投票

你能告诉我你遇到的错误吗?

© www.soinside.com 2019 - 2024. All rights reserved.