在用户注册订阅后,尝试将用户导航到其客户门户时出现此错误。
这是错误消息。
在这种情况下,用户已成功注册订阅并已通过身份验证。订阅开始和结束日期显示正确,但我无法导航到用户的支付门户。
我也得到了一个CORS错误,直到我包括
app, 'us-central1'
调用函数时
const functions = getFunctions()
正如最近的一次firebase更新中所要求的那样。
<script>
import { getFunctions, httpsCallable } from "firebase/functions"
export default {
props: ["subscription"],
data() {
return {
isLoading: false,
}
},
methods: {
async openCustomerPortal() {
this.isLoading = true
console.log(app)
const functions = getFunctions(app, 'us-central1')
const functionRef = httpsCallable(
functions,
"ext-firestore-stripe-payments-createPortalLink",
)
const { data } = await functionRef({
returnUrl: window.location.origin,
})
window.location.assign(data.url)
},
},
}
</script>
<template>
<div class="row">
<div class="col">
<h2>Subscribed Account</h2>
<div
v-if="subscription.cancel_at_period_end"
class="alert alert-warning"
>
This subscription will cancel at the end of the period.
</div>
<p>
Current period start:
{{
new Date(
subscription.current_period_start.seconds * 1000
).toLocaleString()
}}
</p>
<p>
Current period end:
{{
new Date(
subscription.current_period_end.seconds * 1000
).toLocaleString()
}}
</p>
<button
class="btn btn-primary"
:disabled="isLoading"
@click="openCustomerPortal"
>
{{ isLoading ? "Loading..." : "Open my billing portal" }}
</button>
</div>
</div>
</template>