-
Notifications
You must be signed in to change notification settings - Fork 0
/
Payment_Dfpay_addorder.go
52 lines (47 loc) · 2.32 KB
/
Payment_Dfpay_addorder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package x7s
import (
"context"
"go.dtapp.net/gojson"
"go.dtapp.net/gorequest"
)
type PaymentDfpayAddorderResponse struct {
Code int `json:"code"` // 0=错误 1=成功
Msg string `json:"msg"` // 描述
Data struct {
Status string `json:"status"` // 状态 -1=删除 0=可用 90=关闭
PartnerId string `json:"partner_id"` // 供应商ID
PartnerOrderNo string `json:"partner_order_no"` // 供应商订单号
Account string `json:"account"` // 账号
Amount string `json:"amount"` // 金额
ChargeAmount string `json:"charge_amount"` // 收费金额
} `json:"data,omitempty"`
}
type PaymentDfpayAddorderResult struct {
Result PaymentDfpayAddorderResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
}
func newPaymentDfpayAddorderResult(result PaymentDfpayAddorderResponse, body []byte, http gorequest.Response) *PaymentDfpayAddorderResult {
return &PaymentDfpayAddorderResult{Result: result, Body: body, Http: http}
}
// PaymentDfpayAddorder 统一下单接口
// https://gys.x7s.com/Home_Index_documenta.html#doc6
func (c *Client) PaymentDfpayAddorder(ctx context.Context, partnerOrderNo string, Type int, account string, amount float64, notifyUrl string, notMustParams ...gorequest.Params) (*PaymentDfpayAddorderResult, error) {
// 参数
params := gorequest.NewParamsWith(notMustParams...)
params.Set("partner_id", c.GetPartnerID()) // 供应商ID
params.Set("partner_order_no", partnerOrderNo) // 供应商订单号
params.Set("type", Type) // 类型 17-新奥燃气,16-云缴费电费,1000-国网电费,13-淘宝电费,31-话费
params.Set("account", account) // 账号 电费户号、话费手机号
params.Set("amount", amount) // 充值金额(元)
params.Set("notify_url", notifyUrl) // 回调通知地址
// 请求
request, err := c.request(ctx, c.GetApiURL()+"Payment_Dfpay_addorder", params)
if err != nil {
return newPaymentDfpayAddorderResult(PaymentDfpayAddorderResponse{}, request.ResponseBody, request), err
}
// 定义
var response PaymentDfpayAddorderResponse
err = gojson.Unmarshal(request.ResponseBody, &response)
return newPaymentDfpayAddorderResult(response, request.ResponseBody, request), err
}