我有一个反应应用程序,我想在其中设置 adyen(支付处理 API)。我想使用结帐 SDK(https://docs.adyen.com/developers/checkout/web-sdk),因为它非常简单,我已将js
逻辑移至componentDidMount
,但加载 sdk 时遇到问题,
<script type="text/javascript" src="https://checkoutshopper-test.adyen.com/checkoutshopper/assets/js/sdk/checkoutSDK.1.6.3.min.js"></script>
所以我可以使用 SDK 中的以下函数:
chckt.hooks.beforeComplete = function(node, paymentData) {
return false; // Indicates that you want to replace the default handling.
};
我尝试在我的 React 组件中使用react-script-tag:
render() {
return (
<div className='checkout-warpper'>
<ScriptTag type="text/javascript" src="https://checkoutshopper-test.adyen.com/checkoutshopper/assets/js/sdk/checkoutSDK.1.9.2.min.js" />
<div className="checkout" id="adyen-checkout">
{/* The checkout interface will be rendered here */}
</div>
</div>
);
}
但仍然得到错误:
Uncaught ReferenceError: chckt is not defined.