Skip to content

Commit 7ee08b1

Browse files
Copilotbinarywang
andauthored
feat: 补充虚拟支付iOS退款通知xpay_subscribe_ios_refund_query_notify相关字段和事件类型常量
Agent-Logs-Url: https://github.com/binarywang/WxJava/sessions/bf33fa74-c952-4beb-ae60-2e66235e7fa5 Co-authored-by: binarywang <1343140+binarywang@users.noreply.github.com>
1 parent e6ce2f8 commit 7ee08b1

3 files changed

Lines changed: 145 additions & 0 deletions

File tree

weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,11 @@ public static class EventType {
499499
* 订单完成发货时、订单结算时
500500
*/
501501
public static final String TRADE_MANAGE_ORDER_SETTLEMENT = "trade_manage_order_settlement";
502+
/**
503+
* 虚拟支付 iOS 退款查询通知
504+
* 文档:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/virtual-payment/ios.html
505+
*/
506+
public static final String XPAY_SUBSCRIBE_IOS_REFUND_QUERY_NOTIFY = "xpay_subscribe_ios_refund_query_notify";
502507
}
503508

504509
/**

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/WxMaMessage.java

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,80 @@ public class WxMaMessage implements Serializable {
464464
@XStreamConverter(value = XStreamCDataConverter.class)
465465
private String requestId;
466466

467+
// xpay_subscribe_ios_refund_query_notify iOS退款查询通知字段
468+
469+
/**
470+
* 问询时间,Unix时间戳.
471+
* xpay_subscribe_ios_refund_query_notify
472+
*/
473+
@SerializedName("refund_time")
474+
@XStreamAlias("refund_time")
475+
@XStreamConverter(value = XStreamCDataConverter.class)
476+
private String refundTime;
477+
478+
/**
479+
* 该笔退款的订单时间(退款订单对应的交易时间),Unix时间戳.
480+
* xpay_subscribe_ios_refund_query_notify
481+
*/
482+
@SerializedName("order_time")
483+
@XStreamAlias("order_time")
484+
@XStreamConverter(value = XStreamCDataConverter.class)
485+
private String orderTime;
486+
487+
/**
488+
* Apple 支付票据号.
489+
* xpay_subscribe_ios_refund_query_notify
490+
*/
491+
@SerializedName("channel_bill")
492+
@XStreamAlias("channel_bill")
493+
@XStreamConverter(value = XStreamCDataConverter.class)
494+
private String channelBill;
495+
496+
/**
497+
* 应用的 Apple bundleid.
498+
* xpay_subscribe_ios_refund_query_notify
499+
*/
500+
@SerializedName("bundleid")
501+
@XStreamAlias("bundleid")
502+
@XStreamConverter(value = XStreamCDataConverter.class)
503+
private String bundleid;
504+
505+
/**
506+
* 道具 id.
507+
* xpay_subscribe_ios_refund_query_notify
508+
*/
509+
@SerializedName("product_id")
510+
@XStreamAlias("product_id")
511+
@XStreamConverter(value = XStreamCDataConverter.class)
512+
private String xpayProductId;
513+
514+
/**
515+
* 道具/代币数量.
516+
* xpay_subscribe_ios_refund_query_notify
517+
*/
518+
@SerializedName("p_count")
519+
@XStreamAlias("p_count")
520+
@XStreamConverter(value = XStreamCDataConverter.class)
521+
private String pCount;
522+
523+
/**
524+
* 用户请求退款的原因.
525+
* xpay_subscribe_ios_refund_query_notify
526+
*/
527+
@SerializedName("refund_request_reason")
528+
@XStreamAlias("refund_request_reason")
529+
@XStreamConverter(value = XStreamCDataConverter.class)
530+
private String refundRequestReason;
531+
532+
/**
533+
* 发货状态,0:未发货 1:已发货 2:发货中.
534+
* xpay_subscribe_ios_refund_query_notify
535+
*/
536+
@SerializedName("provide_status")
537+
@XStreamAlias("provide_status")
538+
@XStreamConverter(value = XStreamCDataConverter.class)
539+
private String provideStatus;
540+
467541
/**
468542
* 不要直接使用这个字段,
469543
* 这个字段只是为了适配 SubscribeMsgPopupEvent SubscribeMsgChangeEvent SubscribeMsgSentEvent

weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,4 +457,70 @@ private void checkXPayComplaintNotifyMessage(WxMaMessage msg) {
457457
assertEquals(msg.getRetryTimes(), new Integer(0));
458458
assertEquals(msg.getRequestId(), "req_005");
459459
}
460+
461+
/**
462+
* 虚拟支付 iOS 退款查询通知事件 xpay_subscribe_ios_refund_query_notify 测试用例(XML格式)
463+
*/
464+
@Test
465+
public void testXPaySubscribeIosRefundQueryNotifyFromXml() {
466+
String xml = "<xml>\n" +
467+
" <ToUserName><![CDATA[gh_abcdefg]]></ToUserName>\n" +
468+
" <FromUserName><![CDATA[oABCDEFG]]></FromUserName>\n" +
469+
" <CreateTime>1700001000</CreateTime>\n" +
470+
" <MsgType><![CDATA[event]]></MsgType>\n" +
471+
" <Event><![CDATA[xpay_subscribe_ios_refund_query_notify]]></Event>\n" +
472+
" <refund_time><![CDATA[1700000900]]></refund_time>\n" +
473+
" <order_time><![CDATA[1699990000]]></order_time>\n" +
474+
" <channel_bill><![CDATA[apple_bill_001]]></channel_bill>\n" +
475+
" <bundleid><![CDATA[com.example.app]]></bundleid>\n" +
476+
" <product_id><![CDATA[product_xyz]]></product_id>\n" +
477+
" <p_count><![CDATA[1]]></p_count>\n" +
478+
" <refund_request_reason><![CDATA[不喜欢]]></refund_request_reason>\n" +
479+
" <provide_status><![CDATA[1]]></provide_status>\n" +
480+
"</xml>";
481+
482+
WxMaMessage msg = WxMaMessage.fromXml(xml);
483+
checkXPaySubscribeIosRefundQueryNotifyMessage(msg);
484+
}
485+
486+
/**
487+
* 虚拟支付 iOS 退款查询通知事件 xpay_subscribe_ios_refund_query_notify 测试用例(JSON格式)
488+
*/
489+
@Test
490+
public void testXPaySubscribeIosRefundQueryNotifyFromJson() {
491+
String json = "{\n" +
492+
" \"ToUserName\": \"gh_abcdefg\",\n" +
493+
" \"FromUserName\": \"oABCDEFG\",\n" +
494+
" \"CreateTime\": 1700001000,\n" +
495+
" \"MsgType\": \"event\",\n" +
496+
" \"Event\": \"xpay_subscribe_ios_refund_query_notify\",\n" +
497+
" \"refund_time\": \"1700000900\",\n" +
498+
" \"order_time\": \"1699990000\",\n" +
499+
" \"channel_bill\": \"apple_bill_001\",\n" +
500+
" \"bundleid\": \"com.example.app\",\n" +
501+
" \"product_id\": \"product_xyz\",\n" +
502+
" \"p_count\": \"1\",\n" +
503+
" \"refund_request_reason\": \"不喜欢\",\n" +
504+
" \"provide_status\": \"1\"\n" +
505+
"}";
506+
507+
WxMaMessage msg = WxMaMessage.fromJson(json);
508+
checkXPaySubscribeIosRefundQueryNotifyMessage(msg);
509+
}
510+
511+
private void checkXPaySubscribeIosRefundQueryNotifyMessage(WxMaMessage msg) {
512+
assertEquals(msg.getToUser(), "gh_abcdefg");
513+
assertEquals(msg.getFromUser(), "oABCDEFG");
514+
assertEquals(msg.getCreateTime(), new Integer(1700001000));
515+
assertEquals(msg.getMsgType(), WxConsts.XmlMsgType.EVENT);
516+
assertEquals(msg.getEvent(), WxConsts.EventType.XPAY_SUBSCRIBE_IOS_REFUND_QUERY_NOTIFY);
517+
assertEquals(msg.getRefundTime(), "1700000900");
518+
assertEquals(msg.getOrderTime(), "1699990000");
519+
assertEquals(msg.getChannelBill(), "apple_bill_001");
520+
assertEquals(msg.getBundleid(), "com.example.app");
521+
assertEquals(msg.getXpayProductId(), "product_xyz");
522+
assertEquals(msg.getPCount(), "1");
523+
assertEquals(msg.getRefundRequestReason(), "不喜欢");
524+
assertEquals(msg.getProvideStatus(), "1");
525+
}
460526
}

0 commit comments

Comments
 (0)