跳到正文
Indiana
控制台
文档
章节目录 / 浏览器客户端

浏览器客户端

当前客户持有、账本、报价与优惠;业务动作通过 Funnel。

SDK 0.0.1更新于

浏览器 SDK

本页对应当前源码,必须使用与 Indiana 部署匹配的 SDK。npm 已发布 0.0.1 beta;当前源码的方法与 DTO 以本页和 contracts 为准,不能将工作区版本号当作发布回执。

先在宿主完成真实登录,由后端签发当前客户会话。浏览器不传任意 customerId。

当前导出与方法

  • setupPayment({ requestId, currency, makeDefault })

    权限billing:write

    创建独立银行卡设置;不产生订阅、权益或用量扣款授权。

    返回 { setup }

  • readPaymentSetup({ setupId })

    权限billing:read

    核对原设置的实际渠道结果,重试不会重复收费。

    返回 { setup }

  • readBillingInvoice({ invoiceId, after, limit })

    权限billing:read

    读取完整已验证明细,按 nextCursor 分页;不会收费。

    返回 { detail }

  • readCreditStatement({ from, to, entityId?, snapshotAt, after, limit })

    权限credits:read

    范围上限 366 天;首屏 snapshotAt/after 为 null,后续沿用原快照和完整游标。

    返回 { statement }

  • previewUpdate({ requestId, membershipId, timing, change })

    权限billing:read

    按明确会员合同固定套餐或席位报价,保留同订阅的其他套餐。

    返回 { quote }

  • update({ operationId })

    权限billing:write

    确认固定报价并恢复原收费尝试;实际已验证付款决定交付。

    返回 { operation }

  • readSubscriptionUpdate({ operationId })

    权限billing:read

    读取变更状态;待付款、下期计划和已生效均保留原操作身份。

    返回 { operation }

  • previewAttach({ entityId?, requestId, plans, provider, currency, offerId? })

    权限billing:read

    使用已识别客户会话保存 15 分钟报价;不传 customerId,不触发付款或付费授予。

    返回 { quote }

  • attach({ operationId })

    权限billing:write

    客户明确接受报价后执行;checkoutUrl 由宿主展示,响应丢失时重试原 operationId。

    返回 { operation }

  • restoreNativePurchase({ requestId, provider, purchaseIntentId, productId, signedTransaction?, purchaseToken? })

    权限billing:write

    使用已识别客户身份恢复经过商店验证的购买。

    返回 { restore }

  • readSubscriptionOperation({ operationId })

    权限billing:read

    恢复原订单状态和验证后的交付,不重新发起收款。

    返回 { operation }

  • setBillingCoupons({ authorizationId, requestId, grantIds })

    权限billing:write

    为当前客户的已启用授权设置有序优惠;只能使用本人持有的券。原 requestId 的重试返回原回执,待结算期间不能更换优惠。

    返回 { coupons }

  • confirmBillingAdjustment({ invoiceId, accepted: true })

    权限billing:write

    仅在客户审阅并同意当前固定追加账单后调用。不能由页面加载或自动重试推断同意。

    返回 { invoice }

  • readBillingControls(input?)

    权限billing:read

    读取已验证客户的授权、限额、窗口和自动充值状态。

    返回 { controls }

  • prepareBillingAuthorization(input)

    权限billing:write

    保留原 requestId,准备固定版本与限额条款;准备不等于客户同意。

    返回 { prepared }

  • confirmBillingAuthorization({ authorizationId, accepted: true })

    权限billing:write

    只在客户明确接受条款后调用;服务端再次验证当前授权和 provider 设置。

    返回 { authorization }

  • revokeBillingAuthorization({ authorizationId, requestId })

    权限billing:write

    撤销当前客户授权;原请求重试不换 UUID。

    返回 { authorization }

  • listBillingInvoices({ after, limit }?)

    权限billing:read

    读取当前客户用量账单;按 nextCursor 分页,limit 最多 100。

    返回 { invoices }

  • readBillingControls(input) / listBillingInvoices({ after, limit })

    权限billing:read

    读取当前已认证客户的自动付款授权、用量窗口、限额与分页账单。读取、刷新和分页不触发扣款。

    返回 { controls } / { invoices }

  • prepareBillingAuthorization(input) / confirmBillingAuthorization({ authorizationId, accepted: true }) / revokeBillingAuthorization({ authorizationId, requestId })

    权限billing:write

    以持久 requestId 准备固定条款与 Sandbox 支付方式;只有支付准备完成且客户明确接受后才能启用付款。撤销会阻止后续自动付款,并保留已有财务事实。

    返回 { prepared } / { authorization }

  • identify(customerToken) / reset()

    Token 只保存在内存;重置或换号会中止旧身份请求。展示中的 Funnel 也必须销毁并丢弃。

    返回 void

  • subscribeIdentity(listener)

    观察 identify/reset,宿主据此清理界面;返回取消订阅函数。

    返回 Unsubscribe function

  • checkEntitlement({ requirement, commerce?, paywallId? })

    权限entitlements:read

    后续源码入口,已发布 npm 0.0.1 不含此方法。匹配 SDK/服务后,使用当前客户 Token 返回 allowed、拒绝原因和商品推荐;浏览器不能指定客户身份。

    返回 { check }

  • readHoldings()

    权限entitlements:read

    读取当前已认证客户的会员与余额,不接收 customerId。

    返回 { holdings }

  • readLedger(query)

    权限credits:read

    按当前客户分页读取完整历史;游标包含记录类型与精确时间。

    返回 { ledger }

  • quoteBalance(command)

    权限credits:read

    传 operation: quote、entitlementId、十进制 quantity 和 properties。只估价,不扣量。

    返回 { quote }

  • listOffers()

    权限offers:resolve

    读取当前客户的有效优惠;实际领取和购买在发布的 Funnel 节点中执行。

    返回 Offer[]

  • redeemCoupon(code, requestId)

    权限offers:resolve

    兑换当前范围中的优惠码,原 requestId 用于响应丢失后的重试。

    返回 { offer, reason }

  • redeemReward(input) / createReferralCode(input)

    权限offers:resolve

    按已配置的奖励与推荐计划执行;创建推荐码另需 offers:resolve。

    返回 Reward / referral code

  • setBillingCoupons(input)

    权限billing:write

    在客户确认的授权上替换后续收款的有序优惠券列表;空列表移除,重试保留 requestId。进行中的收款拒绝修改。

    返回 BillingCoupons

  • claimRewardProduct(input)

    权限offers:resolve

    审阅奖励兑换与后续续费条款后传入 accepted: true;重试保留 redemptionId 和 requestId。新订阅返回 type: checkout 与结账状态;已有相同付费订阅返回 type: subscription 与追加优惠任务状态,保留原优惠和订阅身份。

    返回 RewardProductCheckout

  • formatCouponTerms / formatCouponDiscount / formatCouponMoney

    使用服务端返回的 coupon 条款格式化展示,文案不决定资格或实际收费。

    返回 string