jquery Chargebee:未捕获类型错误:this.page.urlFetcher(...).then不是函数

wfypjpf4  于 2023-10-17  发布在  jQuery
关注(0)|答案(1)|浏览(90)

我目前正在尝试将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>
nwlls2ji

nwlls2ji1#

在检查支持之后,结果发现托管页面函数应该返回一个approach调用(promise)。下面是文档中的一个示例:

return $.ajax({
                  method: "post",
                  url: "http://localhost:8000/api/generate_checkout_new_url",
                  data: {
                    plan_id: "cbdemo_scale"
                  }
                });

相关问题