Skip to content

Commit 5bfc22a

Browse files
author
Matrix-X
committed
feat(payment): add ElecSign apis
1 parent f185f61 commit 5bfc22a

File tree

3 files changed

+79
-1
lines changed

3 files changed

+79
-1
lines changed

src/payment/bill/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (comp *Client) GetFlowBill(ctx context.Context, date string, accountType st
5959
return result, err
6060
}
6161

62-
// https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_8.shtml
62+
// https://pay.weixin.qq.com/doc/v3/merchant/4013071238
6363
func (comp *Client) DownloadBill(ctx context.Context, requestDownload *power.RequestDownload, filePath string) (int64, error) {
6464
return comp.StreamDownload(ctx, requestDownload, filePath)
6565
}

src/payment/fundApp/client.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"github.com/ArtisanCloud/PowerLibs/v3/object"
7+
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/power"
78
"github.com/ArtisanCloud/PowerWeChat/v3/src/payment/fundApp/request"
89
"github.com/ArtisanCloud/PowerWeChat/v3/src/payment/fundApp/response"
910
payment "github.com/ArtisanCloud/PowerWeChat/v3/src/payment/kernel"
@@ -77,3 +78,52 @@ func (comp *Client) Cancel(ctx context.Context, outBillNO string) (*response.Res
7778

7879
return result, err
7980
}
81+
82+
// 商户单号申请电子回单
83+
// https://pay.weixin.qq.com/doc/v3/merchant/4012716452
84+
func (comp *Client) ApplyForElecSign(ctx context.Context, outBillNO string) (*response.ResponseApplyForElecSign, error) {
85+
86+
result := &response.ResponseApplyForElecSign{}
87+
88+
endpoint := "/v3/fund-app/mch-transfer/elecsign/out-bill-no"
89+
_, err := comp.SafeRequestV3(ctx, endpoint, nil, http.MethodPost, &object.HashMap{
90+
"out_bill_no": outBillNO,
91+
}, nil, result)
92+
93+
return result, err
94+
}
95+
96+
// 商户单号查询电子回单
97+
// https://pay.weixin.qq.com/doc/v3/merchant/4012716436
98+
func (comp *Client) QueryElecSign(ctx context.Context, outBillNO string) (*response.ResponseQueryElecSign, error) {
99+
result := &response.ResponseQueryElecSign{}
100+
endpoint := comp.Wrap(fmt.Sprintf("/v3/fund-app/mch-transfer/elecsign/out-bill-no/%s", outBillNO))
101+
_, err := comp.SafeRequestV3(ctx, endpoint, nil, http.MethodGet, &object.HashMap{}, nil, result)
102+
return result, err
103+
}
104+
105+
// 微信单号申请电子回单
106+
// https://pay.weixin.qq.com/doc/v3/merchant/4012716456
107+
func (comp *Client) ApplyForElecSignByTransferBillNo(ctx context.Context, transferBillNO string) (*response.ResponseApplyForElecSign, error) {
108+
result := &response.ResponseApplyForElecSign{}
109+
endpoint := "/v3/fund-app/mch-transfer/elecsign/transfer-bill-no"
110+
_, err := comp.SafeRequestV3(ctx, endpoint, nil, http.MethodPost, &object.HashMap{
111+
"transfer_bill_no": transferBillNO,
112+
}, nil, result)
113+
return result, err
114+
}
115+
116+
// 微信单号查询电子回单
117+
// https://pay.weixin.qq.com/doc/v3/merchant/4012716455
118+
func (comp *Client) QueryElecSignByTransferBillNo(ctx context.Context, transferBillNO string) (*response.ResponseQueryElecSign, error) {
119+
result := &response.ResponseQueryElecSign{}
120+
endpoint := comp.Wrap(fmt.Sprintf("/v3/fund-app/mch-transfer/elecsign/transfer-bill-no/%s", transferBillNO))
121+
_, err := comp.SafeRequestV3(ctx, endpoint, nil, http.MethodGet, &object.HashMap{}, nil, result)
122+
return result, err
123+
}
124+
125+
// 下载电子回单
126+
// https://pay.weixin.qq.com/doc/v3/merchant/4013866774
127+
func (comp *Client) DownloadElecSignToFilePath(ctx context.Context, requestDownload *power.RequestDownload, filePath string) (int64, error) {
128+
return comp.StreamDownload(ctx, requestDownload, filePath)
129+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package response
2+
3+
import (
4+
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/response"
5+
"time"
6+
)
7+
8+
type ResponseApplyForElecSign struct {
9+
response.ResponsePayment
10+
11+
State string `json:"state"`
12+
CreateTime time.Time `json:"create_time"`
13+
}
14+
15+
type ResponseQueryElecSign struct {
16+
State string `json:"state"`
17+
CreateTime time.Time `json:"create_time"`
18+
UpdateTime time.Time `json:"update_time"`
19+
HashType string `json:"hash_type"`
20+
HashValue string `json:"hash_value"`
21+
DownloadUrl string `json:"download_url"`
22+
}
23+
24+
type RequestDownloadUrl struct {
25+
HashType string `json:"hash_type"`
26+
HashValue string `json:"hash_value"`
27+
DownloadUrl string `json:"download_url"`
28+
}

0 commit comments

Comments
 (0)