diff --git a/unify/pay.go b/unify/pay.go index 0817a1f..4a126f4 100644 --- a/unify/pay.go +++ b/unify/pay.go @@ -54,9 +54,15 @@ func (p *Pay) CreateOrder(order *CreateOrderReq) (map[string]interface{}, error) return rsp.Data, nil } -func (p *Pay) CreatePartnerOrder(params map[string]interface{}) (map[string]interface{}, error) { +func (p *Pay) CreatePartnerOrder(order *CreatePartnerOrderReq) (map[string]interface{}, error) { - reqBody, _ := json.Marshal(params) + if order.PayType == "" { + errors.New("payType is nil") + } + if order.PayPrice <= 0 { + return nil, errors.New("payPrice is nil") + } + reqBody, _ := json.Marshal(order) result, err := util.HttpPostJson(p.address+"/api/pay/partner/order", map[string]string{ "x-token": p.token, diff --git a/unify/pay_type.go b/unify/pay_type.go index a41fab4..1b8905e 100644 --- a/unify/pay_type.go +++ b/unify/pay_type.go @@ -33,6 +33,17 @@ type CreateOrderReq struct { Goods *OrderGoods `json:"goods,omitempty"` } +type CreatePartnerOrderReq struct { + PayType string `json:"payType"` + PaySource string `json:"paySource"` + PayPrice int64 `json:"payPrice"` + GoodsName string `json:"goodsName"` + OutTradeNo string `json:"outTradeNo"` + NotifyUrl string `json:"notifyUrl"` + PartnerId string `json:"partnerId"` + Extra interface{} `json:"extra"` +} + type CommonResponse struct { Code int `json:"code"` Message string `json:"message"`