-
-
Notifications
You must be signed in to change notification settings - Fork 9k
添加小游戏道具直购(present_goods)API支持 #3811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Co-authored-by: binarywang <[email protected]>
Co-authored-by: binarywang <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
本 PR 为微信小游戏虚拟支付模块新增道具直购(present_goods)API 支持,解决用户反馈的功能缺失问题。实现方式与现有的代币直购(presentCurrency)API 保持一致,遵循项目现有的代码风格和架构模式。
主要变更:
- 新增
presentGoodsAPI 接口及其请求/响应对象 - 完善的字段注释和文档说明
- 遵循现有 XPay 服务的实现模式
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| WxMaApiUrlConstants.java | 新增道具直购 API 的 URL 常量定义 |
| WxMaXPayPresentGoodsRequest.java | 新建道具直购请求对象,包含 openid、env、order_id、device_type、goods_id、goods_number 等字段 |
| WxMaXPayPresentGoodsResponse.java | 新建道具直购响应对象,返回 order_id |
| WxMaXPayService.java | 在服务接口中添加 presentGoods 方法声明 |
| WxMaXPayServiceImpl.java | 实现 presentGoods 方法,包含请求发送、响应解析和错误处理逻辑 |
| public WxMaXPayPresentGoodsResponse presentGoods(WxMaXPayPresentGoodsRequest request, WxMaXPaySigParams sigParams) throws WxErrorException { | ||
| final String postBody = request.toJson(); | ||
| final String uri = sigParams.signUriWithPay(PRESENT_GOODS_URL, postBody); | ||
| String responseContent = this.service.post(uri, postBody); | ||
| WxMaXPayPresentGoodsResponse getDetailResponse = WxMaGsonBuilder.create() | ||
| .fromJson(responseContent, WxMaXPayPresentGoodsResponse.class); | ||
|
|
||
| if (getDetailResponse.getErrcode() != 0) { | ||
| throw new WxErrorException( | ||
| new WxError(getDetailResponse.getErrcode(), getDetailResponse.getErrmsg())); | ||
| } | ||
|
|
||
| return getDetailResponse; | ||
| } |
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
新增的 presentGoods 方法缺少对应的测试用例。建议在 WxMaXPayServiceImplTest 中添加 testPresentGoods 方法,参考 testPresentCurrency 的实现模式。
| * | ||
| * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||
| */ | ||
| @Data |
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method overrides WxMaBaseResponse.canEqual; it is advisable to add an Override annotation.
用户反馈无法找到小游戏道具直购功能支持。根据微信官方文档,添加
present_goodsAPI 实现。新增内容
WxMaXPayService.presentGoods()WxMaXPayPresentGoodsRequest- 包含 openid、env、order_id、device_type、goods_id、goods_numberWxMaXPayPresentGoodsResponse- 返回 order_idWxMaApiUrlConstants.XPay.PRESENT_GOODS_URL使用示例
实现模式与现有虚拟支付 API(如
presentCurrency)保持一致。Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.