Files
baseapi/platformapi/tiktok/tiktok_pay_model.go
richboo111 104c6f7a60 tt
2022-08-19 15:04:11 +08:00

137 lines
6.3 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package tiktok
const (
PayUrl = "https://developer.toutiao.com/api/apps/ecpay/v1/create_order" // 抖音下支付单
RefundUrl = "https://developer.toutiao.com/api/apps/ecpay/v1/create_refund" // 申请退款
QueryRefundUrl = "https://developer.toutiao.com/api/apps/ecpay/v1/query_refund" // 查询申请退款记录
GetTiktokToken = "https://developer.toutiao.com/api/apps/v2/token" // 查询申请退款记录
GetTiktokOauth = "https://developer.toutiao.com/api/apps/v2/jscode2session" // 获取抖音授权
GetTiktokQrCode = "https://developer.toutiao.com/api/apps/qrcode" // 获取小程序二维码
TiktokAppId = "tta6a1d01c399f264201"
TiktokSecret = "5c08a0465cf0f996af254a03b6c2548defef87ad"
TiktokJXDJAppID = "ttaceeda5333d7a7ab01"
TiktokJXDJSecret = "5c8492ec2744fb72bb6cc356983f3cfc317f85d4"
)
// 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 *TiktokData `json:"data"`
}
type TiktokData 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 {
AppID string `json:"app_id"` // 小程序APPID
OutOrderNo string `json:"out_order_no"` // 开发者侧的订单号
TotalAmount int `json:"total_amount"` // 支付价格。
Subject string `json:"subject"` // 商品描述。
Body string `json:"body"` // 商品详情
ValidTime int `json:"valid_time"` // 订单过期时间(秒)。
Sign string `json:"sign"` // 签名,详见请求加签算法
CpExtra string `json:"cp_extra"` // 开发者自定义字段,回调原样回传
NotifyURL string `json:"notify_url"` // 商户自定义回调地址
}
// 预发单返回值
type PreOrderResult struct {
ErrNo int64 `json:"err_no"` // 错误码
ErrTips string `json:"err_tips"` // 错误信息
Data *struct {
OrderId string `json:"order_id"` // 抖音侧唯一订单号
OrderToken string `json:"order_token"` //签名后的订单信息
}
}
type AccessToken struct {
Data *struct {
AccessToken string `json:"access_token"` //token
ExpiresIn int64 `json:"expires_in"` // 过期时间
} `json:"data"`
ErrNo int64 `json:"err_no"` // 错误码
ErrTips string `json:"err_tips"` // 错误信息
}
// 退款
type ReturnMoneyReq struct {
AppID string `json:"app_id"` // 小程序APPID
OutOrderNo string `json:"out_order_no"` //商户分配支付单号,标识进行退款的订单
OutRefundNo string `json:"out_refund_no"` // 商户分配退款号,保证在商户中唯一
Reason string `json:"reason"` // 退款原因
RefundAmount int `json:"refund_amount"`
Sign string `json:"sign"`
CpExtra string `json:"cp_extra"`
NotifyURL string `json:"notify_url"`
}
/***************回调****************/
type CallBackResult struct {
Timestamp string `json:"timestamp"` // Unix 时间戳10 位,整型数
Nonce string `json:"nonce"` // 随机数
Msg string `json:"msg"` // 订单信息的 json 字符串
TypePay string `json:"type"` // 回调类型标记,支付成功回调为"payment"
MsgSignature string `json:"msg_signature"` // 签名,详见
}
// 详细信息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"` // 抖音侧订单号
}