Skip to content

Commit

Permalink
增加商户分账
Browse files Browse the repository at this point in the history
  • Loading branch information
pyihe committed Jul 15, 2020
1 parent 01707e3 commit efcfb14
Show file tree
Hide file tree
Showing 3 changed files with 686 additions and 8 deletions.
37 changes: 31 additions & 6 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,27 @@ type WePayer interface {
GetPublicKey(p12CertPath string, targetPath string) error
//TODO 待验证 企业付款到银行卡
TransferBank(param Param, p12CertPath string, publicKeyPath string) (ResultParam, error)
////TODO 待验证 查询企业付款到银行卡
//TODO 待验证 查询企业付款到银行卡
TransferBankQuery(param Param, p12CertPath string) (ResultParam, error)

//分账相关
//申请单次分账or多次分账
ProfitSharing(param Param, p12CertPath string, multiTag bool) (ResultParam, error)
//查询申请分账的结果
QueryProfitSharing(param Param, p12CertPath string) (ResultParam, error)
//添加分账接收方
AddProfitSharingReceiver(param Param) (ResultParam, error)
//删除分账接收方
RemoveProfitSharingReceiver(param Param) (ResultParam, error)
//完结分账
FinishProfitSharing(param Param, p12CertPath string) (ResultParam, error)
//分账回退
ReturnProfitSharing(param Param, p12CertPath string) (ResultParam, error)
//回退结果查询
QueryProfitSharingReturn(param Param) (ResultParam, error)
//分账动帐通知(此处无视返回结果的层级关系,对需要的字段直接使用Get方法获取对应的结果)
ProfitSharingNotify(body io.Reader) (ResultParam, error)

//小程序相关
//获取授权access_token
GetAccessTokenForMini() (Param, error) //获取小程序接口凭证,使用者自己保存token,过期重新获取
Expand All @@ -80,11 +98,12 @@ var (
)

type myPayer struct {
once sync.Once
appId string //appid
mchId string //mchid
secret string //secret用于获取token
apiKey string //用于支付
once sync.Once
appId string //appid
mchId string //mchid
secret string //secret用于获取token
apiKey string //用于支付
apiV3Key string //api v3 key
}

//不向微信发送接口请求report
Expand Down Expand Up @@ -122,6 +141,12 @@ func WithApiKey(key string) option {
}
}

func WithApiV3Key(v3Key string) option {
return func(payer *myPayer) {
payer.apiV3Key = v3Key
}
}

func (m *myPayer) checkForPay() error {
if m.appId == "" {
return errors.New("need appid")
Expand Down
4 changes: 2 additions & 2 deletions pay.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (m *myPayer) UnifiedOrder(param Param) (ResultParam, error) {
//获取交易类型和签名类型
var (
unifiedMustParam = []string{"appid", "mch_id", "nonce_str", "sign", "body", "out_trade_no", "total_fee", "spbill_create_ip", "notify_url", "trade_type"}
unifiedOptionalParam = []string{"device_info", "sign_type", "detail", "attach", "fee_type", "time_start", "time_expire", "goods_tag", "limit_pay", "receipt", "openid", "product_id", "scene_info"}
unifiedOptionalParam = []string{"device_info", "sign_type", "detail", "attach", "fee_type", "time_start", "time_expire", "goods_tag", "limit_pay", "receipt", "openid", "product_id", "scene_info", "profit_sharing"}
tradeType string
signType = e.SignTypeMD5 //默认MD5签名方式
)
Expand Down Expand Up @@ -228,7 +228,7 @@ func (m *myPayer) UnifiedMicro(param Param) (ResultParam, error) {
//获取交易类型和签名类型
var (
microMustParam = []string{"appid", "mch_id", "nonce_str", "sign", "body", "out_trade_no", "total_fee", "spbill_create_ip", "auth_code"}
microOptionalParam = []string{"device_info", "sign_type", "detail", "attach", "fee_type", "goods_tag", "limit_pay", "time_start", "time_expire", "receipt", "scene_info"}
microOptionalParam = []string{"device_info", "sign_type", "detail", "attach", "fee_type", "goods_tag", "limit_pay", "time_start", "time_expire", "receipt", "scene_info", "profit_sharing"}
signType = e.SignTypeMD5 //默认MD5签名方式
)

Expand Down
Loading

0 comments on commit efcfb14

Please sign in to comment.