我目前正在尝试将chargebee drop in脚本包含到网站中,但当我使用托管页面对象调用它时,我得到了错误
未捕获的类型错误:this.page.urlFetcher(...).then不是函数
我写了一个小脚本来复制错误:
<!DOCTYPE html>
<html>
<head>
<script src="https://js.chargebee.com/v2/chargebee.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$( document ).ready(function() {
/* Initialize a Chargebee instance after mounting the root component. */
var chargebeeInstance = Chargebee.init({
site: "..."
});
// You can access the above created instance anywhere using the following code
var chargebeeInstance = Chargebee.getInstance();
});
$( document ).ready(function() {
$("button").click(function() {
var chargebeeInstance = Chargebee.getInstance();
chargebeeInstance.openCheckout({
hostedPage: function() {
return {"expires_at":...,"updated_at":...,"created_at":..,"id":"...","state":"created","embed":true,"type":"checkout_new","resource_version":...,"url":"...","object":"hosted_page"};
},
success: function(hostedPageId) {
// success callback
}
});
});
});
</script>
</head>
<body>
<button> click me </button>
</body>
</html>
1条答案
按热度按时间nwlls2ji1#
在检查支持之后,结果发现托管页面函数应该返回一个approach调用(promise)。下面是文档中的一个示例: