Skip to content

Commit

Permalink
Merge pull request #2958 from mojinxun/feature/小程序虚拟支付
Browse files Browse the repository at this point in the history
小程序虚拟支付
  • Loading branch information
JeffreySu authored Nov 30, 2023
2 parents fc9cc36 + 5dfba62 commit 903ceed
Show file tree
Hide file tree
Showing 36 changed files with 2,067 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
namespace Senparc.Weixin.MP.Entities
{
public class RequestMessageEvent_XPay_Coin_Pay_Notify : RequestMessageEventBase, IRequestMessageEventBase
{
public override Event Event
{
get { return Event.xpay_goods_deliver_notify; }
}

/// <summary>
/// 用户openid
/// </summary>
public string OpenId { get; set; }

/// <summary>
/// 业务订单号
/// </summary>
public string OutTradeNo { get; set; }

/// <summary>
/// 环境配置 0:现网环境(也叫正式环境)1:沙箱环境
/// </summary>
public string Env { get; set; }

/// <summary>
/// 微信支付信息 非微信支付渠道可能没有
/// </summary>
public WeChatPayInfo WeChatPayInfo { get; set; }

/// <summary>
/// 道具参数信息
/// </summary>
public CoinInfo CoinInfo { get; set; }
}

/// <summary>
/// 道具参数信息
/// </summary>
public class CoinInfo
{
/// <summary>
/// 数量
/// </summary>
public int Quantity { get; set; }

/// <summary>
/// 物品原始价格 (单位:分)
/// </summary>
public int OrigPrice { get; set; }

/// <summary>
/// 物品实际支付价格(单位:分)
/// </summary>
public int ActualPrice { get; set; }

/// <summary>
/// 透传信息
/// </summary>
public string Attach { get; set; }

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
namespace Senparc.Weixin.MP.Entities
{
public class RequestMessageEvent_XPay_Goods_Deliver_Notify : RequestMessageEventBase, IRequestMessageEventBase
{
public override Event Event
{
get { return Event.xpay_goods_deliver_notify; }
}

/// <summary>
/// 用户openid
/// </summary>
public string OpenId { get; set; }

/// <summary>
/// 业务订单号
/// </summary>
public string OutTradeNo { get; set; }

/// <summary>
/// 环境配置 0:现网环境(也叫正式环境)1:沙箱环境
/// </summary>
public string Env { get; set; }

/// <summary>
/// 微信支付信息 非微信支付渠道可能没有
/// </summary>
public WeChatPayInfo WeChatPayInfo { get; set; }

/// <summary>
/// 道具参数信息
/// </summary>
public GoodsInfo GoodsInfo { get; set; }
}

/// <summary>
/// 微信支付信息 非微信支付渠道可能没有
/// </summary>
public class WeChatPayInfo
{
/// <summary>
/// 微信支付商户单号
/// </summary>
public string MchOrderNo { get; set; }

/// <summary>
/// 交易单号(微信支付订单号)
/// </summary>
public string TransactionId { get; set; }

/// <summary>
/// 用户支付时间,Linux秒级时间戳
/// </summary>
public long PaidTime { get; set; }
}

/// <summary>
/// 道具参数信息
/// </summary>
public class GoodsInfo
{
/// <summary>
/// 道具ID
/// </summary>
public string ProductId { get; set; }

/// <summary>
/// 数量
/// </summary>
public int Quantity { get; set; }

/// <summary>
/// 物品原始价格 (单位:分)
/// </summary>
public int OrigPrice { get; set; }

/// <summary>
/// 物品实际支付价格(单位:分)
/// </summary>
public int ActualPrice { get; set; }

/// <summary>
/// 透传信息
/// </summary>
public string Attach { get; set; }

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
namespace Senparc.Weixin.MP.Entities
{
public class RequestMessageEvent_XPay_Refund_Notify : RequestMessageEventBase, IRequestMessageEventBase
{
public override Event Event
{
get { return Event.xpay_refund_notify; }
}

/// <summary>
/// 用户openid
/// </summary>
public string OpenId { get; set; }

/// <summary>
/// 微信退款单号
/// </summary>
public string WxRefundId { get; set; }

/// <summary>
/// 商户退款单号
/// </summary>
public string MchRefundId { get; set; }

/// <summary>
/// 退款单对应支付单的微信单号
/// </summary>
public string WxOrderId { get; set; }

/// <summary>
/// 退款单对应支付单的商户单号
/// </summary>
public string MchOrderId { get; set; }

/// <summary>
/// 退款金额,单位分
/// </summary>
public int RefundFee { get; set; }

/// <summary>
/// 退款结果,0为成功,非0为失败
/// </summary>
public int RetCode { get; set; }

/// <summary>
/// 退款结果详情,失败时为退款失败的原因
/// </summary>
public string RetMsg { get; set; }

/// <summary>
/// 开始退款时间,秒级时间戳
/// </summary>
public long RefundStartTimestamp { get; set; }

/// <summary>
/// 结束退款时间,秒级时间戳
/// </summary>
public long RefundSuccTimestamp { get; set; }

/// <summary>
/// 退款单的微信支付单号
/// </summary>
public string WxpayRefundTransactionId { get; set; }

/// <summary>
/// 重试次数,从0开始。重试间隔为2 4 8 16...最多15次
/// </summary>
public int RetryTimes { get; set; }
}
}
23 changes: 20 additions & 3 deletions src/Senparc.Weixin.MP/Senparc.Weixin.MP/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public enum Event
/// 点击菜单跳转小程序的事件推送
/// </summary>
view_miniprogram,

#region 微信认证事件推送
/// <summary>
/// 资质认证成功(此时立即获得接口权限)
Expand Down Expand Up @@ -408,7 +408,7 @@ public enum Event
/// </summary>
submit_invoice_title,
#endregion

#region 订阅通知
/// <summary>
/// 用户操作订阅通知弹窗 场景:用户在图文等场景内订阅通知的操作
Expand All @@ -423,7 +423,24 @@ public enum Event
/// <summary>
/// 发送订阅通知 场景:调用 bizsend 接口发送通知
/// </summary>
subscribe_msg_sent_event
subscribe_msg_sent_event,
#endregion

#region 小程序虚拟支付
/// <summary>
/// 道具发货推送
/// </summary>
xpay_goods_deliver_notify,

/// <summary>
/// 代币支付推送
/// </summary>
xpay_coin_pay_notify,

/// <summary>
/// 退款推送
/// </summary>
xpay_refund_notify,
#endregion
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,24 @@ public virtual async Task<IResponseMessageBase> OnEventRequestAsync(IRequestMess
break;

#endregion

#region 微信电子发票
case Event.user_authorize_invoice:
responseMessage = await OnEvent_User_Authorize_InvoiceAsync(RequestMessage as RequestMessageEvent_User_Authorize_Invoice).ConfigureAwait(false);
break;
#endregion

#region 小程序虚拟支付
case Event.xpay_goods_deliver_notify:
responseMessage = await OnEvent_XPay_Goods_Deliver_NotifyAsync(RequestMessage as RequestMessageEvent_XPay_Goods_Deliver_Notify);
break;
case Event.xpay_coin_pay_notify:
responseMessage = await OnEvent_XPay_Coin_Pay_NotifyAsync(RequestMessage as RequestMessageEvent_XPay_Coin_Pay_Notify);
break;
case Event.xpay_refund_notify:
responseMessage = await OnEvent_XPay_Refund_NotifyAsync(RequestMessage as RequestMessageEvent_XPay_Refund_Notify);
break;
#endregion

default:
throw new Exceptions.UnknownRequestMsgTypeException("未知的Event下属请求信息", null);
Expand Down Expand Up @@ -735,6 +747,7 @@ public virtual async Task<IResponseMessageBase> OnEvent_Submit_Invoice_TitleAsyn
return await DefaultAsyncMethod(requestMessage, () => OnEvent_Submit_Invoice_Title(requestMessage)).ConfigureAwait(false);
}
#endregion

#region 订阅通知
/// <summary>
/// 用户管理订阅通知
Expand Down Expand Up @@ -765,6 +778,21 @@ public virtual async Task<IResponseMessageBase> OnEvent_Subscribe_Msg_SentReques
}
#endregion

#region 小程序虚拟支付
public virtual async Task<IResponseMessageBase> OnEvent_XPay_Goods_Deliver_NotifyAsync(RequestMessageEvent_XPay_Goods_Deliver_Notify requestMessage)
{
return await DefaultAsyncMethod(requestMessage, () => OnEvent_XPay_Goods_Deliver_Notify(requestMessage)).ConfigureAwait(false);
}
public virtual async Task<IResponseMessageBase> OnEvent_XPay_Coin_Pay_NotifyAsync(RequestMessageEvent_XPay_Coin_Pay_Notify requestMessage)
{
return await DefaultAsyncMethod(requestMessage, () => OnEvent_XPay_Coin_Pay_Notify(requestMessage)).ConfigureAwait(false);
}
public virtual async Task<IResponseMessageBase> OnEvent_XPay_Refund_NotifyAsync(RequestMessageEvent_XPay_Refund_Notify requestMessage)
{
return await DefaultAsyncMethod(requestMessage, () => OnEvent_XPay_Refund_Notify(requestMessage)).ConfigureAwait(false);
}
#endregion

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ public virtual IResponseMessageBase OnEventRequest(IRequestMessageEventBase requ
responseMessage = OnEvent_Subscribe_Msg_SentRequest(RequestMessage as RequestMessageEvent_Subscribe_Msg_Sent);
break;


#region 卡券回调

case Event.giftcard_pay_done:
Expand Down Expand Up @@ -237,6 +236,7 @@ public virtual IResponseMessageBase OnEventRequest(IRequestMessageEventBase requ
// responseMessage = OnEvent_WeAppAuditFailRequest(RequestMessage as RequestMessageEvent_WeAppAuditFail);
// break;
#endregion

#region 微信电子发票
case Event.user_authorize_invoice:
responseMessage = OnEvent_User_Authorize_Invoice(RequestMessage as RequestMessageEvent_User_Authorize_Invoice);
Expand All @@ -245,6 +245,19 @@ public virtual IResponseMessageBase OnEventRequest(IRequestMessageEventBase requ
responseMessage = OnEvent_Submit_Invoice_Title(RequestMessage as RequestMessageEvent_Submit_Invoice_Title);
break;
#endregion

#region 小程序虚拟支付
case Event.xpay_goods_deliver_notify:
responseMessage = OnEvent_XPay_Goods_Deliver_Notify(RequestMessage as RequestMessageEvent_XPay_Goods_Deliver_Notify);
break;
case Event.xpay_coin_pay_notify:
responseMessage = OnEvent_XPay_Coin_Pay_Notify(RequestMessage as RequestMessageEvent_XPay_Coin_Pay_Notify);
break;
case Event.xpay_refund_notify:
responseMessage = OnEvent_XPay_Refund_Notify(RequestMessage as RequestMessageEvent_XPay_Refund_Notify);
break;
#endregion

default:
throw new Exceptions.UnknownRequestMsgTypeException("未知的Event下属请求信息", null);
}
Expand Down Expand Up @@ -770,6 +783,21 @@ public virtual IResponseMessageBase OnEvent_Subscribe_Msg_SentRequest(RequestMes
return DefaultResponseMessage(requestMessage);
}
#endregion

#region 小程序虚拟支付
public virtual IResponseMessageBase OnEvent_XPay_Goods_Deliver_Notify(RequestMessageEvent_XPay_Goods_Deliver_Notify requestMessage)
{
return DefaultResponseMessage(requestMessage);
}
public virtual IResponseMessageBase OnEvent_XPay_Coin_Pay_Notify(RequestMessageEvent_XPay_Coin_Pay_Notify requestMessage)
{
return DefaultResponseMessage(requestMessage);
}
public virtual IResponseMessageBase OnEvent_XPay_Refund_Notify(RequestMessageEvent_XPay_Refund_Notify requestMessage)
{
return DefaultResponseMessage(requestMessage);
}
#endregion
#endregion
}
}
Loading

0 comments on commit 903ceed

Please sign in to comment.