reactjs - 未处理的拒绝(错误):无效的钩子调用 React Stripe Fpx
问题描述
在 ReactJS 上提交我的 FpxBank 元素时遇到问题。
这是我的 FpxBank 元素组件
Fpx.Js
import React, {useEffect} from 'react';
import {withRouter, useLocation} from 'react-router-dom';
import {FpxBankElement, Elements, useStripe, useElements} from '@stripe/react-stripe-js';
import {loadStripe} from '@stripe/stripe-js';
const stripePromise = loadStripe("pk_test_rgWMA3zxjAtwaB6iV8b5W40x");
const FpxForm = () => {
return (
<Elements stripe={stripePromise}>
<FpxBankElement options={{accountHolderType: 'individual'}} />
</Elements>
);
};
export default FpxForm;
这是我的购物车页面:
else if(this.props.productInput.payment_method == 'fpx'){
const stripe = useStripe();
const elements = useElements();
const result = await stripe.confirmFpxPayment('pk_test_rgWMA3zxjAtwaB6iV8sb5W40x', {
payment_method: {
fpx: elements.getElement(FpxBankElement) ,
},
// Return URL where the customer should be redirected after the authorization
return_url: `${window.location.href}`,
});
if (result.error) {
// Inform the customer that there was an error.
const errorElement = document.getElementById('error-message');
errorElement.textContent = result.error.message;
}
}
任何解决方案或帮助?
解决方案
推荐阅读
- python - jupyter notebook:如何设置固定密码并禁用令牌使用?
- java - 测试用例单独运行时通过,一起运行时失败
- python - 在不同的列中获取后续日期
- r - 结合来自 tidyvese 的 sample() 和 group_by()
- android - Google 移动广告 (Admob) - 在测试和生产之间切换?
- python - 在python中遍历带有2个指针变量的链表
- javascript - 如何调整模态反应引导的宽度?
- rust - 使用 tonic 和 rust 创建 grpc 客户端
- python - 从 3D 数组中的行中删除索引
- c++ - Nsight 无法捕获所有无绑定图像