[go: nahoru, domu]

Skip to content

Commit

Permalink
feat(payment): add Apply4Sub client
Browse files Browse the repository at this point in the history
  • Loading branch information
Matrix-X committed Jun 11, 2023
1 parent 0b6d99f commit bd041a4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/payment/apply4Sub/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ func NewClient(app *payment.ApplicationPaymentInterface) (*Client, error) {

// 特约商户进件
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter11_1_1.shtml
func (comp *Client) ApplyForBusiness(ctx context.Context, params *request.RequestApply) (*response.ResponseApply, error) {
func (comp *Client) ApplyForBusiness(ctx context.Context, params *request.RequestApplyForBusiness) (*response.ResponseApplyForBusiness, error) {

result := &response.ResponseApply{}
result := &response.ResponseApplyForBusiness{}

// 获取RSA签名器
config := (*comp.App).GetConfig()

rsaSigner, err := sign.NewRSASigner(crypto.SHA1)
Expand All @@ -44,6 +45,7 @@ func (comp *Client) ApplyForBusiness(ctx context.Context, params *request.Reques
return nil, err
}

// 加密params.ContactInfo.ContactEmail
cipherData, err := rsaSigner.RSAEncryptor.Encrypt([]byte(params.ContactInfo.ContactEmail))
buffer := base64.StdEncoding.EncodeToString(cipherData)
if err != nil {
Expand All @@ -54,6 +56,7 @@ func (comp *Client) ApplyForBusiness(ctx context.Context, params *request.Reques
return nil, err
}

// 结构体转化
options, err := object.StructToHashMap(params)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion src/payment/apply4Sub/request/requestApplyment.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package request

type RequestApply struct {
type RequestApplyForBusiness struct {
BusinessCode string `json:"business_code"`
ContactInfo struct {
BusinessAuthorizationLetter string `json:"business_authorization_letter"`
Expand Down
2 changes: 1 addition & 1 deletion src/payment/apply4Sub/response/responseApply.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package response

type ResponseApply struct {
type ResponseApplyForBusiness struct {
ApplymentId int64 `json:"applyment_id"`
}

0 comments on commit bd041a4

Please sign in to comment.