问题描述
我正在用Angular中的Firebase和Stripe制作付款系统,并带有Firebase的官方Stripe扩展。从github复制和改编的代码是:
const docRef = await this.firestore
.collection('customers')
.doc(userId)
.collection('checkout_sessions')
.add({
price,allow_promotion_codes: false,success_url: window.location.origin,cancel_url: window.location.origin,});
// Wait for the CheckoutSession to get attached by the extension
docRef.onSnapshot((snap) => {
const { error,sessionId } = snap.data();
if ( error && error !== undefined ) {
// Show an error to your customer and then inspect your function logs.
console.log('Error',error);
alert(`An error occured: ${error.message}`);
}
if ( sessionId && sessionId !== undefined ) {
// We have a session,let's redirect to Checkout
// Init Stripe
const stripe = Stripe(STRIPE_PUBLISHABLE_KEY);
stripe.redirecttocheckout({ sessionId });
}
});
它可以按固定的月度价格使用标准定价,但是每次我尝试使用Stripe中标记为“计量使用”的价格时,都会返回错误:
还有“分包定价”:
结帐不支持包裹定价,也称为
transform_quantity
中的line_items[price][0]
。
有人知道如何进行这项工作吗?或者只是扩展名仅接受标准的固定价格。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)