package lakala import ( "context" "encoding/json" "fmt" "github.com/go-pay/gopay" ) // 创建小程序订单 // 文档:https://payjp.lakala.com/docs/cn/#api-Miniprogram_Payment-microapp func (c *Client) CreateMiniProgramOrder(ctx context.Context, orderId string, bm gopay.BodyMap) (rsp *PaymentRsp, err error) { if orderId == gopay.NULL { return nil, fmt.Errorf("orderId is empty") } if err = bm.CheckEmptyError("description", "price", "channel"); err != nil { return nil, err } url := fmt.Sprintf(newMiniProgramOrder, c.PartnerCode, orderId) bs, err := c.doPut(ctx, url, bm) if err != nil { return nil, err } rsp = new(PaymentRsp) err = json.Unmarshal(bs, rsp) if err != nil { return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs)) } return rsp, nil }