gpt4 book ai didi

firebase - Stripe 订阅创建失败 - parameter_unknown : source

转载 作者:行者123 更新时间:2023-12-05 04:02:10 25 4
gpt4 key购买 nike

我在 firebase 中创建了一个函数,用于在创建用户时创建 strip 订阅。这一切都很好,但是当我切换到另一个 strip 帐户时(切换了前端和后端的 api key 并更改了 plan_id)

我收到以下错误:收到未知参数:来源。

我有一个代码有效的 Stripe 帐户和另一个以不同方式处理代码的帐户。我可以切换 api key 并观察它从失败到成功,反之亦然。

这是我创建订阅的代码部分

return stripe.subscriptions.create({
customer: customerId,
source: collectedToken,
coupon: couponId,
items: [{plan: 'plan_xxxxxxxx'}],
});

已检查 strip 帐户的后端和前端的所有 API key 是否正确。除了使用不同的 strip api key 外,测试期间的前端完全相同。我尝试切换 firebase 帐户以查看是否是问题所在,但得到了相同的结果。

有效的是创建一个客户和 token ,该 token 与记录在该 strip 帐户上的数据相匹配,但在创建订阅时都失败了。这让我认为这是我的 stripe 帐户中的配置错误。我已经检查了两个 Stripe 帐户,使它们尽可能相同。

这是一个失败的帖子/回复:

Request POST body
{
"customer": "cus_EWLxBmoZgtdVKQ",
"source": "tok_1E3JFsJUEng1Y6esS4bme82U",
"coupon": "",
"items": {
"0": {
"plan": "plan_EUshZMWWubOprv"
}
}
}

Response body
{
"error": {
"code": "parameter_unknown",
"doc_url": "https://stripe.com/docs/error-codes/parameter-unknown",
"message": "Received unknown parameter: source",
"param": "source",
"type": "invalid_request_error"
}
}

这是一个成功的帖子/回复:

{
"customer": "cus_EW3IIVqlBt9fFD",
"source": "tok_1E31BZLdCGsF9mmTflmDjd0x",
"coupon": "",
"items": {
"0": {
"plan": "plan_ESdEWggGYJ89FB"
}
}
}

{
"id": "sub_EW3IWD0NCyDVUi",
"object": "subscription",
"application_fee_percent": null,
"billing": "charge_automatically",
"billing_cycle_anchor": 1549977641,
"billing_thresholds": null,
"cancel_at": null,
.................

我希望如果计划、客户、 token 有效,它应该可以在另一个 strip 帐户上工作,前提是该 strip 帐户的设置方式相同。

最佳答案

这可能是因为您正在使用的新 API key 正在更新版本的 Stripe API 上运行。您可以查看您的developers section of the dashboard 下的版本.

updated subscriptions API您只需要一个客户和一个计划(在项目列表中)即可创建新订阅。源已完全删除,API 现在依赖于客户的默认源。

关于firebase - Stripe 订阅创建失败 - parameter_unknown : source,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54666560/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com