Skip to content

Develop #659

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

Merged
merged 4 commits into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/kernel/models/payment.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,36 @@ type Amount struct {
// 去掉非充值代金券退款金额后的退款金额,单位为分,退款金额=申请退款金额-非充值代金券退款金额,退款金额<=申请退款金额

}

// --- TransferBills models ----

const WX_TRANSFERBILLS_STATE_SUCCESS = "SUCCESS" // 转账成功
const WX_TRANSFERBILLS_STATE_ACCEPTED = "ACCEPTED" // 单据已受理
const WX_TRANSFERBILLS_STATE_NOTPAY = "PROCESSING" // 单据处理中
const WX_TRANSFERBILLS_STATE_WAIT_USER_CONFIRM = "WAIT_USER_CONFIRM" // 待收款用户确认,可拉起微信收款确认页面进行收款确认
const WX_TRANSFERBILLS_STATE_TRANSFERING = "TRANSFERING" // 转账中,转账结果尚未明确,可拉起微信收款确认页面再次重试确认收款
const WX_TRANSFERBILLS_STATE_FAIL = "FAIL" // 转账失败
const WX_TRANSFERBILLS_STATE_CANCELING = "CANCELING" // 撤销中
const WX_TRANSFERBILLS_STATE_CANCELLED = "CANCELLED" // 已撤销

// TransferBills
type TransferBills struct {
// 商户单号:商户系统内部的商家单号,在商户系统内部唯一
OutBillNo string `json:"out_bill_no"`
// 商家转账订单号:微信单号,微信商家转账系统返回的唯一标识
TransferBillNo string `json:"transfer_bill_no"`
// 单据状态:商家转账订单状态
State string `json:"state"`
// 商户号:微信支付分配的商户号
MchId string `json:"mch_id"`
// 转账金额:转账总金额,单位为“分”
TransferAmount int `json:"transfer_amount"`
// 收款用户OpenID:用户在商户appid下的唯一标识
OpenId string `json:"open_id"`
// 失败原因:单已失败或者已退资金时,会返回订单失败原因
FailReason string `json:"fail_reason"`
// 单据创建时间:遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE
CreateTime string `json:"create_time"`
// 最后一次状态变更时间:遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE
UpdateTime string `json:"update_time"`
}
4 changes: 4 additions & 0 deletions src/payment/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,10 @@ func (app *Payment) HandleRefundedNotify(request *http.Request, closure func(mes
return notify.NewRefundNotify(app, request).Handle(closure)
}

func (app *Payment) HandleTransferBillsNotify(request *http.Request, closure func(message *request.RequestNotify, transaction *models.TransferBills, fail func(message string)) interface{}) (*http.Response, error) {
return notify.NewTransferBillsNotify(app, request).Handle(closure)
}

func (app *Payment) HandleScannedNotify(request *http.Request, closure func(message *request.RequestNotify, fail func(message string), alert func(message string)) interface{}) (*http.Response, error) {
return notify.NewScannedNotify(app, request).Handle(closure)
}
Expand Down
48 changes: 48 additions & 0 deletions src/payment/notify/transfer_bills.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package notify

import (
"github.com/ArtisanCloud/PowerLibs/v3/object"
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/models"
"github.com/ArtisanCloud/PowerWeChat/v3/src/payment/kernel"
"github.com/ArtisanCloud/PowerWeChat/v3/src/payment/notify/request"
"net/http"
)

type TransferBills struct {
*Handler
}

func NewTransferBillsNotify(app kernel.ApplicationPaymentInterface, request *http.Request) *TransferBills {

paid := &TransferBills{
NewHandler(app, request),
}

return paid
}

func (comp *TransferBills) Handle(closure func(message *request.RequestNotify, refund *models.TransferBills, fail func(message string)) interface{}) (*http.Response, error) {

message, err := comp.GetMessage()
if err != nil {
return nil, err
}

reqInfo, err := comp.reqInfo()
if err != nil {
return nil, err
}

// struct the content
transferBills := &models.TransferBills{}
err = object.JsonDecode([]byte(reqInfo), transferBills)
if err != nil {
return nil, err
}

result := closure(message, transferBills, comp.Fail)
comp.Strict(result)

return comp.ToResponse()

}
2 changes: 1 addition & 1 deletion src/payment/security/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (comp *Client) GetCertificates(ctx context.Context) (*response.ResponseGetC
}

// Get RSA Public Key.
// https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay_yhk.php?chapter=25_7&index=4
// https://pay.weixin.qq.com/doc/v2/merchant/4011941097
func (comp *Client) GetRSAPublicKey(ctx context.Context) (*response.ResponseGetPublicKey, error) {
config := comp.App.GetConfig()

Expand Down