100
This commit is contained in:
@@ -16,43 +16,6 @@ const (
|
|||||||
TtPayWay = "10" // 10-抖音支付
|
TtPayWay = "10" // 10-抖音支付
|
||||||
)
|
)
|
||||||
|
|
||||||
type CallBackResult struct {
|
|
||||||
Timestamp int `json:"timestamp"` // Unix 时间戳,10 位,整型数
|
|
||||||
Nonce string `json:"nonce"` // 随机数
|
|
||||||
Msg string `json:"msg"` // 订单信息的 json 字符串
|
|
||||||
TypePay string `json:"type"` // 回调类型标记,支付成功回调为"payment"
|
|
||||||
Msgsignature string `json:"msgsignature"` // 签名,详见
|
|
||||||
}
|
|
||||||
|
|
||||||
// 详细信息MSG(支付回调)
|
|
||||||
type DetailCallBackMessage struct {
|
|
||||||
AppId string `json:"appid"` // 当前交易发起的小程序id
|
|
||||||
CpOrderno string `json:"cp_orderno"` // 开发者侧的订单号
|
|
||||||
CpExtra string `json:"cp_extra"` // 预下单时开发者传入字段
|
|
||||||
Way string `json:"way"` // way 字段中标识了支付渠道:1-微信支付,2-支付宝支付,10-抖音支付
|
|
||||||
ChannelNo string `json:"channel_no"` // 支付渠道侧单号
|
|
||||||
PaymentOrderNo string `json:"payment_order_no"` // 支付渠道侧商家订单号
|
|
||||||
TotalAmount int64 `json:"total_amount"` // 支付金额,单位为分
|
|
||||||
Status string `json:"status"` // 固定SUCCESS
|
|
||||||
ItemId string `json:"item_id"` // 订单来源视频对应视频 id
|
|
||||||
SellerUid string `json:"seller_uid"` // 该笔交易卖家商户号
|
|
||||||
PaidAt int64 `json:"paid_at"` // 支付时间,Unix 时间戳,10 位,整型数
|
|
||||||
OrderId string `json:"order_id"` // 抖音侧订单号
|
|
||||||
}
|
|
||||||
|
|
||||||
// 详细信息MSG(退款回调)
|
|
||||||
type DetailCallBackMessage2Refund struct {
|
|
||||||
AppId string `json:"appid"` // 当前交易发起的小程序id
|
|
||||||
CpRefundno string `json:"cp_refundno"` // 开发者侧的退款订单号
|
|
||||||
CpExtra string `json:"cp_extra"` // 预下单时开发者传入字段
|
|
||||||
Status string `json:"status"` // 固定SUCCESS/FAIL
|
|
||||||
RefundAmount int64 `json:"refund_amount"` // 退款金额
|
|
||||||
RefundedAt int64 `json:"refunded_at"` // 退款时间
|
|
||||||
Message string `json:"message"` // 退款失败描述
|
|
||||||
OrderId string `json:"order_id"` // 抖音侧订单号
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *API) GetCallbackMsg(request *http.Request) (call *DetailCallBackMessage, refund *DetailCallBackMessage2Refund, payType string, err error) {
|
func (a *API) GetCallbackMsg(request *http.Request) (call *DetailCallBackMessage, refund *DetailCallBackMessage2Refund, payType string, err error) {
|
||||||
data, err := ioutil.ReadAll(request.Body)
|
data, err := ioutil.ReadAll(request.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ const (
|
|||||||
BaseURL = "https://open.snssdk.com" // 头条
|
BaseURL = "https://open.snssdk.com" // 头条
|
||||||
TiktokTokenUrl = "oauth/access_token/"
|
TiktokTokenUrl = "oauth/access_token/"
|
||||||
TiktokRefreshTokenUrl = "oauth/renew_refresh_token/"
|
TiktokRefreshTokenUrl = "oauth/renew_refresh_token/"
|
||||||
|
|
||||||
|
salt = "TUsUuzcfWriQ8ZXUQOrxPcScjEGlgMSjJaDMCtVy"
|
||||||
|
ResponseCodeSuccess = "SUCCESS"
|
||||||
|
ResponseCodeFail = "FAIL"
|
||||||
)
|
)
|
||||||
|
|
||||||
type API struct {
|
type API struct {
|
||||||
|
|||||||
@@ -10,12 +10,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
salt = "TUsUuzcfWriQ8ZXUQOrxPcScjEGlgMSjJaDMCtVy"
|
|
||||||
ResponseCodeSuccess = "SUCCESS"
|
|
||||||
ResponseCodeFail = "FAIL"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 获取支付签名
|
// 获取支付签名
|
||||||
func (a *API) Sign(paramsMap map[string]interface{}) string {
|
func (a *API) Sign(paramsMap map[string]interface{}) string {
|
||||||
var paramsArr []string
|
var paramsArr []string
|
||||||
|
|||||||
@@ -4,6 +4,43 @@ const (
|
|||||||
PayUrl = "https://developer.toutiao.com/api/apps/ecpay/v1/create_order"
|
PayUrl = "https://developer.toutiao.com/api/apps/ecpay/v1/create_order"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// OauthAccessTokenResData access_token
|
||||||
|
type OauthAccessTokenResData struct {
|
||||||
|
ErrorCode int64 `json:"error_code"` // 错误码
|
||||||
|
ExpiresIn uint64 `json:"expires_in"` // access_token接口调用凭证超时时间,单位(秒)
|
||||||
|
OpenId string `json:"open_id"` // 授权用户唯一标识
|
||||||
|
RefreshExpiresIn int64 `json:"refresh_expires_in"` // refresh_token凭证超时时间,单位(秒)
|
||||||
|
RefreshToken string `json:"refresh_token"` // 用户刷新access_token
|
||||||
|
Scope string `json:"scope"` // 用户授权的作用域(Scope),使用逗号(,)分隔,开放平台几乎几乎每个接口都需要特定的Scope。
|
||||||
|
AccessToken string `json:"access_token"` // 接口调用凭证
|
||||||
|
Description string `json:"description"` // 错误码描述
|
||||||
|
}
|
||||||
|
|
||||||
|
// DYError 错误结构体
|
||||||
|
type DYError struct {
|
||||||
|
ErrorCode int64 `json:"error_code,omitempty"` // 错误码
|
||||||
|
Description string `json:"description,omitempty"` // 错误码描述
|
||||||
|
}
|
||||||
|
|
||||||
|
// OauthAccessTokenRes access_token
|
||||||
|
type OauthAccessTokenRes struct {
|
||||||
|
Data *OauthAccessTokenResData
|
||||||
|
Message string `json:"message"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 抖音登录返回值
|
||||||
|
type TiktokOauthResone struct {
|
||||||
|
ErrNo int64 `json:"err_no"`
|
||||||
|
ErrTips string `json:"err_tips"`
|
||||||
|
Data *struct {
|
||||||
|
SessionKey string `json:"session_key"`
|
||||||
|
OpenId string `json:"openid"` // 授权用户唯一标识
|
||||||
|
AnonymousOpenid string `json:"anonymous_openid"`
|
||||||
|
Unionid string `json:"unionid"`
|
||||||
|
Dopenid string `json:"dopenid"`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 预下单
|
// 预下单
|
||||||
type TickTokCreateOrder struct {
|
type TickTokCreateOrder struct {
|
||||||
AppID string `json:"app_id"` // 小程序APPID
|
AppID string `json:"app_id"` // 小程序APPID
|
||||||
@@ -45,3 +82,41 @@ type ReturnMoneyReq struct {
|
|||||||
CpExtra string `json:"cp_extra"`
|
CpExtra string `json:"cp_extra"`
|
||||||
NotifyURL string `json:"notify_url"`
|
NotifyURL string `json:"notify_url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***************回调****************/
|
||||||
|
type CallBackResult struct {
|
||||||
|
Timestamp int `json:"timestamp"` // Unix 时间戳,10 位,整型数
|
||||||
|
Nonce string `json:"nonce"` // 随机数
|
||||||
|
Msg string `json:"msg"` // 订单信息的 json 字符串
|
||||||
|
TypePay string `json:"type"` // 回调类型标记,支付成功回调为"payment"
|
||||||
|
Msgsignature string `json:"msgsignature"` // 签名,详见
|
||||||
|
}
|
||||||
|
|
||||||
|
// 详细信息MSG(支付回调)
|
||||||
|
type DetailCallBackMessage struct {
|
||||||
|
AppId string `json:"appid"` // 当前交易发起的小程序id
|
||||||
|
CpOrderno string `json:"cp_orderno"` // 开发者侧的订单号
|
||||||
|
CpExtra string `json:"cp_extra"` // 预下单时开发者传入字段
|
||||||
|
Way string `json:"way"` // way 字段中标识了支付渠道:1-微信支付,2-支付宝支付,10-抖音支付
|
||||||
|
ChannelNo string `json:"channel_no"` // 支付渠道侧单号
|
||||||
|
PaymentOrderNo string `json:"payment_order_no"` // 支付渠道侧商家订单号
|
||||||
|
TotalAmount int64 `json:"total_amount"` // 支付金额,单位为分
|
||||||
|
Status string `json:"status"` // 固定SUCCESS
|
||||||
|
ItemId string `json:"item_id"` // 订单来源视频对应视频 id
|
||||||
|
SellerUid string `json:"seller_uid"` // 该笔交易卖家商户号
|
||||||
|
PaidAt int64 `json:"paid_at"` // 支付时间,Unix 时间戳,10 位,整型数
|
||||||
|
OrderId string `json:"order_id"` // 抖音侧订单号
|
||||||
|
}
|
||||||
|
|
||||||
|
// 详细信息MSG(退款回调)
|
||||||
|
type DetailCallBackMessage2Refund struct {
|
||||||
|
AppId string `json:"appid"` // 当前交易发起的小程序id
|
||||||
|
CpRefundno string `json:"cp_refundno"` // 开发者侧的退款订单号
|
||||||
|
CpExtra string `json:"cp_extra"` // 预下单时开发者传入字段
|
||||||
|
Status string `json:"status"` // 固定SUCCESS/FAIL
|
||||||
|
RefundAmount int64 `json:"refund_amount"` // 退款金额
|
||||||
|
RefundedAt int64 `json:"refunded_at"` // 退款时间
|
||||||
|
Message string `json:"message"` // 退款失败描述
|
||||||
|
OrderId string `json:"order_id"` // 抖音侧订单号
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -39,3 +39,9 @@ func TestCode22(t *testing.T) {
|
|||||||
fmt.Println(1&1 != 0)
|
fmt.Println(1&1 != 0)
|
||||||
fmt.Println(2&2 != 0)
|
fmt.Println(2&2 != 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetToken(t *testing.T) {
|
||||||
|
a := New("5c08a0465cf0f996af254a03b6c2548defef87ad", "tta6a1d01c399f264201")
|
||||||
|
a.GetTiktokToken()
|
||||||
|
fmt.Println(a.msgToken)
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,43 +4,6 @@ import (
|
|||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// OauthAccessTokenResData access_token
|
|
||||||
type OauthAccessTokenResData struct {
|
|
||||||
ErrorCode int64 `json:"error_code"` // 错误码
|
|
||||||
ExpiresIn uint64 `json:"expires_in"` // access_token接口调用凭证超时时间,单位(秒)
|
|
||||||
OpenId string `json:"open_id"` // 授权用户唯一标识
|
|
||||||
RefreshExpiresIn int64 `json:"refresh_expires_in"` // refresh_token凭证超时时间,单位(秒)
|
|
||||||
RefreshToken string `json:"refresh_token"` // 用户刷新access_token
|
|
||||||
Scope string `json:"scope"` // 用户授权的作用域(Scope),使用逗号(,)分隔,开放平台几乎几乎每个接口都需要特定的Scope。
|
|
||||||
AccessToken string `json:"access_token"` // 接口调用凭证
|
|
||||||
Description string `json:"description"` // 错误码描述
|
|
||||||
}
|
|
||||||
|
|
||||||
// DYError 错误结构体
|
|
||||||
type DYError struct {
|
|
||||||
ErrorCode int64 `json:"error_code,omitempty"` // 错误码
|
|
||||||
Description string `json:"description,omitempty"` // 错误码描述
|
|
||||||
}
|
|
||||||
|
|
||||||
// OauthAccessTokenRes access_token
|
|
||||||
type OauthAccessTokenRes struct {
|
|
||||||
Data *OauthAccessTokenResData
|
|
||||||
Message string `json:"message"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// 抖音登录返回值
|
|
||||||
type TiktokOauthResone struct {
|
|
||||||
ErrNo int64 `json:"err_no"`
|
|
||||||
ErrTips string `json:"err_tips"`
|
|
||||||
Data *struct {
|
|
||||||
SessionKey string `json:"session_key"`
|
|
||||||
OpenId string `json:"openid"` // 授权用户唯一标识
|
|
||||||
AnonymousOpenid string `json:"anonymous_openid"`
|
|
||||||
Unionid string `json:"unionid"`
|
|
||||||
Dopenid string `json:"dopenid"`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取抖音登录授权2
|
// 获取抖音登录授权2
|
||||||
func (a *API) GetTiktokOauth(code string) (*TiktokOauthResone, error) {
|
func (a *API) GetTiktokOauth(code string) (*TiktokOauthResone, error) {
|
||||||
tokenReq := make(map[string]interface{}, 3)
|
tokenReq := make(map[string]interface{}, 3)
|
||||||
|
|||||||
Reference in New Issue
Block a user