Skip to content

feat(types): add requestCommonPayment typings - #19496

Open
dvd233 wants to merge 1 commit into
NervJS:mainfrom
dvd233:fix/request-common-payment-types
Open

feat(types): add requestCommonPayment typings#19496
dvd233 wants to merge 1 commit into
NervJS:mainfrom
dvd233:fix/request-common-payment-types

Conversation

@dvd233

@dvd233 dvd233 commented Sep 1, 2026

Copy link
Copy Markdown

这个 PR 做了什么? (简要描述所做更改)

  • 为运行时已透传的 Taro.requestCommonPayment 补充 TypeScript 声明,关闭 添加微信基础接口wx.requestCommonPayment(Object object) #16605
  • 根据微信官方文档约束 4 种支付 mode、字符串化 signData、必填签名参数,以及 success/fail 回调结果。
  • 该微信 API 不支持 Promise 风格调用,因此声明返回 void,与 Taro 当前的原生透传行为保持一致。
  • 补充基础库版本、官方文档链接和可直接使用的示例。

Fixes #16605

这个 PR 是什么类型? (至少选择一个)

  • 错误修复 (Bugfix) issue: fix #
  • 新功能 (Feature)
  • 代码重构 (Refactor)
  • TypeScript 类型定义修改 (Types)
  • 文档修改 (Docs)
  • 代码风格更新 (Code style update)
  • 构建优化 (Chore)
  • 其他,请描述 (Other, please describe):

这个 PR 涉及以下平台:

  • 所有平台
  • Web 端(H5)
  • 移动端(React-Native)
  • 鸿蒙(Harmony)
  • 鸿蒙容器(Harmony Hybrid)
  • ASCF 元服务
  • 快应用(QuickApp)
  • 所有小程序
  • 微信小程序
  • 企业微信小程序
  • 京东小程序
  • 百度小程序
  • 支付宝小程序
  • 支付宝 IOT 小程序
  • 钉钉小程序
  • QQ 小程序
  • 飞书小程序
  • 快手小程序
  • 头条小程序

验证

  • Prettier 检查通过。
  • 全仓 ESLint 通过。
  • 严格 TypeScript 消费 fixture 通过,覆盖 4 种合法 mode、void 返回值、回调结果,以及非法 mode、未序列化 signData、缺少签名等负向用例。
  • 对照 origin/main 运行同一 fixture,确认修复前因 API 缺失失败、修复后通过。
  • npm pack 确认声明进入 @tarojs/taro tarball;解包后的消费者类型检查通过。

Summary by CodeRabbit

  • 新功能
    • 新增通用支付接口,支持四种 B2B 支付模式。
    • 支持传入支付签名信息,并通过回调获取支付成功或失败结果。
    • 补充完整的支付参数及回调结果类型定义,便于开发者集成使用。
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 78ed3d46-89ce-4b33-88ea-50253b8c8e41

📥 Commits

Reviewing files that changed from the base of the PR and between d6d69e3 and 5bda01b.

📒 Files selected for processing (1)
  • packages/taro/types/api/payment/index.d.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


Walkthrough

新增 requestCommonPayment 的类型声明。定义 B2b 支付模式、请求参数、成功回调和失败回调结果,并将方法加入 TaroStatic

Changes

通用支付 API

Layer / File(s) Summary
支付契约与 API 入口
packages/taro/types/api/payment/index.d.ts
新增 requestCommonPayment.OptionModeSuccessCallbackResultFailCallbackResult。新增 TaroStatic.requestCommonPayment(option) 方法声明,并标注为仅支持微信小程序。

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 5bda0

This change adds compile-time TypeScript support for an already available WeChat payment API without changing runtime behavior, permissions, or deployment. No actionable merge-blocking risk remains after normal checks and review.

Poem

小兔抱着类型表,
四种支付模式排成行。
回调接口添新章,
requestCommonPayment 轻轻登场。
签名齐备,支付启航。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题明确说明为 requestCommonPayment 添加类型声明,准确概括了本次变更的主要内容。
Linked Issues check ✅ Passed PR 为 Taro.requestCommonPayment 添加了 TypeScript 类型声明,包括 B2B 支付模式、签名参数、成功与失败回调结果,以及 void 返回值,符合关联问题 #16605 的编码目标。
Out of Scope Changes check ✅ Passed 变更仅涉及支付 API 类型声明,并且与关联问题 #16605 直接相关。未发现无关的代码变更。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant