Chargebee:未捕获的TypeError:this.page.urlFetcher(...)。然后不是函数

时间:2018-09-10 11:43:43

标签: javascript jquery html

我目前正在尝试将脚本中的Chargebee放置到网站中,但是当我使用托管页面对象调用它时,会出现错误

  

未捕获的TypeError:this.page.urlFetcher(...)。则不是函数

我写了一个小脚本来复制错误:

<!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 个答案:

答案 0 :(得分:0)

在与支持人员联系后,事实证明,托管页面功能应返回ajax调用(承诺)。 这是文档中的示例:

>>> s = 'a,b:i,c,d:i,e,f,g,h'
>>> tokens = s.split(':i')
>>> col, noncol = tokens[:-1], tokens[-1:]
>>> col
['a,b', ',c,d']
>>> noncol
[',e,f,g,h']