代码之家  ›  专栏  ›  技术社区  ›  Gaz

FIrebase&Run Payments with Stripe-TypeError:无法读取未定义的属性(读取“getProvider”)

  •  -1
  • Gaz  · 技术社区  · 1 年前

    在用户注册订阅后,尝试将用户导航到其客户门户时出现此错误。

    这是错误消息。

    enter image description here

    在这种情况下,用户已成功注册订阅并已通过身份验证。订阅开始和结束日期显示正确,但我无法导航到用户的支付门户。

    我也得到了一个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>
    
    0 回复  |  直到 1 年前
        1
  •  -1
  •   Gaz    1 年前

    必须导入应用程序,firebase无法在同一应用程序上管理两个条带扩展。该区域是从错误的扩展中提取的,导致了错误。

    import { app } from "/firebase"