Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2cd7216423 | ||
|
|
0dc523cdf8 | ||
|
|
1e36375182 | ||
|
|
7587e87994 | ||
|
|
62758f2468 | ||
|
|
525f0f4079 | ||
|
|
ffe1e4a0b7 | ||
|
|
2d7fc6a6ec | ||
|
|
60a53b0e3a | ||
|
|
6a82a8550e | ||
|
|
5c70030dda | ||
|
|
9eb3b0092c | ||
|
|
bfc5decae8 | ||
|
|
084122ef3a |
@@ -3,7 +3,7 @@
|
||||
|
||||
---
|
||||
|
||||
# Bepusdt (Better Easy Payment Usdt)
|
||||
# BEpusdt (Better Easy Payment Usdt)
|
||||
|
||||
<p align="center">
|
||||
<img src="./static/img/tether.svg" width="15%" alt="tether">
|
||||
@@ -32,9 +32,10 @@
|
||||
- ✅ 支持自定义 USDT 支付精度与递增颗粒度
|
||||
- ✅ 底层区块扫描,无第三方 API,秒级响应
|
||||
- ✅ 支持波场能量代理与能量回收监控通知
|
||||
- ✅ 原生支持易支付对接,无需第三方插件
|
||||
- ✅ 支持创建订单时 自定义钱包地址 超时
|
||||
- ✅ 订单支持“等待支付”“支付超时”状态回调
|
||||
- ✅ 原生支持易支付对接,无三方插件依赖
|
||||
- ✅ 支持创建订单时 自定义超时 钱包地址
|
||||
- ✅ 完整支持`等待支付 支付超时`回调
|
||||
- ✅ 支持事件`WebHook` 方便多方协同
|
||||
|
||||
## 🚀 安装部署
|
||||
|
||||
@@ -48,6 +49,7 @@
|
||||
- [彩虹易支付对接教程](./docs/epay.md)
|
||||
- [API 对接开发签名算法](./docs/sign.md)
|
||||
- [对接 回调通知说明](./docs/notify-epusdt.md)
|
||||
- [Webhook 事件回调](./docs/webhook.md)
|
||||
|
||||
## 🖼 功能截图
|
||||
|
||||
@@ -167,8 +169,8 @@ POST /api/v1/order/cancel-transaction
|
||||
|
||||
## 🏝️ 交流反馈
|
||||
|
||||
- Telegram 频道:[https://t.me/BepusdtChannel](https://t.me/BepusdtChannel)
|
||||
- Telegram 群组:[https://t.me/BepusdtChat](https://t.me/BepusdtChat)
|
||||
- Telegram 群组:[https://t.me/BEpusdtChat](https://t.me/BEpusdtChat)
|
||||
- Telegram 频道:[https://t.me/BEpusdtChannel](https://t.me/BEpusdtChannel)
|
||||
|
||||
## 🙏 感谢
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ type Conf struct {
|
||||
StaticPath string `toml:"static_path"`
|
||||
SqlitePath string `toml:"sqlite_path"`
|
||||
TronGrpcNode string `toml:"tron_grpc_node"`
|
||||
WebhookUrl string `toml:"webhook_url"`
|
||||
Pay struct {
|
||||
TrxAtom float64 `toml:"trx_atom"`
|
||||
TrxRate string `toml:"trx_rate"`
|
||||
|
||||
@@ -33,3 +33,5 @@ const (
|
||||
UsdtXlayerDecimals = -6 // USDT Xlayer小数位数
|
||||
UsdtPolygonDecimals = -6 // USDT Polygon小数位数
|
||||
)
|
||||
|
||||
const NotifyMaxRetry = 10 // 最大重试次数,订单回调失败、Webhook失败
|
||||
|
||||
@@ -194,3 +194,8 @@ func GetPaymentAmountMax() decimal.Decimal {
|
||||
|
||||
return decimal.NewFromFloat(val)
|
||||
}
|
||||
|
||||
func GetWebhookUrl() string {
|
||||
|
||||
return cfg.WebhookUrl
|
||||
}
|
||||
|
||||
+1
-1
@@ -37,5 +37,5 @@ func Init() error {
|
||||
|
||||
func AutoMigrate() error {
|
||||
|
||||
return DB.AutoMigrate(&WalletAddress{}, &TradeOrders{}, &NotifyRecord{}, &Config{})
|
||||
return DB.AutoMigrate(&WalletAddress{}, &TradeOrders{}, &NotifyRecord{}, &Config{}, &Webhook{})
|
||||
}
|
||||
|
||||
+7
-19
@@ -11,11 +11,11 @@ import (
|
||||
const (
|
||||
OrderNotifyStateSucc = 1 // 回调成功
|
||||
OrderNotifyStateFail = 0 // 回调失败
|
||||
OrderStatusCanceled = 4 // 订单取消
|
||||
|
||||
OrderStatusExpired = 3 // 订单过期
|
||||
OrderStatusSuccess = 2 // 订单成功
|
||||
OrderStatusWaiting = 1 // 等待支付
|
||||
OrderStatusCanceled = 4 // 订单取消
|
||||
OrderStatusExpired = 3 // 订单过期
|
||||
OrderStatusSuccess = 2 // 订单成功
|
||||
OrderStatusWaiting = 1 // 等待支付
|
||||
|
||||
OrderTradeTypeBscBnb = "bsc.bnb"
|
||||
OrderTradeTypeEthEth = "ethereum.eth"
|
||||
@@ -89,7 +89,7 @@ func (o *TradeOrders) MarkSuccess(blockNum int64, from, hash string, at time.Tim
|
||||
DB.Save(o)
|
||||
}
|
||||
|
||||
func (o *TradeOrders) OrderSetNotifyState(state int) error {
|
||||
func (o *TradeOrders) SetNotifyState(state int) error {
|
||||
o.NotifyNum += 1
|
||||
o.NotifyState = state
|
||||
|
||||
@@ -161,19 +161,6 @@ func GetDetailUrl(tradeType, hash string) string {
|
||||
return "https://tronscan.org/#/transaction/" + hash
|
||||
}
|
||||
|
||||
func GetTradeType(trade string) string {
|
||||
if trade == OrderTradeTypeTronTrx {
|
||||
|
||||
return OrderTradeTypeTronTrx
|
||||
}
|
||||
if trade == OrderTradeTypeUsdtPolygon {
|
||||
|
||||
return OrderTradeTypeUsdtPolygon
|
||||
}
|
||||
|
||||
return OrderTradeTypeUsdtTrc20
|
||||
}
|
||||
|
||||
func GetTradeOrder(tradeId string) (TradeOrders, bool) {
|
||||
var order TradeOrders
|
||||
var res = DB.Where("trade_id = ?", tradeId).Take(&order)
|
||||
@@ -191,7 +178,8 @@ func GetOrderByStatus(Status int) []TradeOrders {
|
||||
|
||||
func GetNotifyFailedTradeOrders() ([]TradeOrders, error) {
|
||||
var orders []TradeOrders
|
||||
var res = DB.Where("status = ?", OrderStatusSuccess).Where("notify_num > ?", 0).
|
||||
var res = DB.Where("status = ?", OrderStatusSuccess).
|
||||
Where("notify_num <= ?", conf.NotifyMaxRetry).
|
||||
Where("notify_state = ?", OrderNotifyStateFail).Find(&orders)
|
||||
|
||||
return orders, res.Error
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/smallnest/chanx"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"math"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
WebhookStatusWait = 0
|
||||
WebhookStatusSucc = 1
|
||||
WebhookStatusFail = -1
|
||||
)
|
||||
|
||||
const (
|
||||
WebhookEventOrderCreate = "order.create" // 订单创建
|
||||
WebhookEventOrderPaid = "order.paid" // 订单支付
|
||||
WebhookEventOrderTimeout = "order.timeout" // 订单超时
|
||||
WebhookEventOrderCancel = "order.cancel" // 订单取消
|
||||
)
|
||||
|
||||
var WebhookHandleQueue = chanx.NewUnboundedChan[Webhook](context.Background(), 30)
|
||||
|
||||
type Webhook struct {
|
||||
ID int64 `gorm:"column:id;type:INTEGER PRIMARY KEY AUTOINCREMENT;" json:"id"`
|
||||
Status int8 `gorm:"column:status;type:tinyint;not null;default:0" json:"status"`
|
||||
Num int `gorm:"column:num;type:int(11);not null;default:0" json:"hook_num"`
|
||||
Url string `gorm:"column:url;type:varchar(255);not null;default:''" json:"url"`
|
||||
Event string `gorm:"column:event;type:varchar(64);not null;default:''" json:"event"`
|
||||
Data json.RawMessage `gorm:"column:data;type:json;not null" json:"data"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime;type:timestamp;not null;comment:创建时间"`
|
||||
UpdatedAt time.Time `gorm:"autoUpdateTime;type:timestamp;not null;comment:更新时间"`
|
||||
}
|
||||
|
||||
func (Webhook) TableName() string {
|
||||
|
||||
return "bep_webhook"
|
||||
}
|
||||
|
||||
func (w Webhook) PostData() string {
|
||||
var data = make(map[string]any)
|
||||
|
||||
data["event"] = w.Event
|
||||
data["data"] = w.Data
|
||||
|
||||
jsonData, _ := json.Marshal(data)
|
||||
|
||||
return string(jsonData)
|
||||
}
|
||||
|
||||
func (w Webhook) SetStatus(status int8) {
|
||||
if status == WebhookStatusSucc {
|
||||
DB.Model(&Webhook{}).Where("id = ?", w.ID).Update("status", status)
|
||||
|
||||
return
|
||||
}
|
||||
if status == WebhookStatusWait {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
w.Num = w.Num + 1
|
||||
if w.Num > conf.NotifyMaxRetry {
|
||||
|
||||
w.Status = WebhookStatusFail
|
||||
}
|
||||
|
||||
DB.Save(&w)
|
||||
}
|
||||
|
||||
func PushWebhookEvent(event string, data any) {
|
||||
go func() {
|
||||
var url = conf.GetWebhookUrl()
|
||||
if url == "" {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
bytes, _ := json.Marshal(data)
|
||||
|
||||
var w = Webhook{Status: WebhookStatusWait, Url: url, Event: event, Data: bytes}
|
||||
if err = DB.Create(&w).Error; err == nil {
|
||||
|
||||
WebhookHandleQueue.In <- w
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func ListWaitWebhooks() {
|
||||
var webhooks = make([]Webhook, 0)
|
||||
DB.Where("status = ?", WebhookStatusWait).Find(&webhooks)
|
||||
|
||||
for _, w := range webhooks {
|
||||
var next = w.CreatedAt.Add(time.Minute * time.Duration(math.Pow(2, float64(w.Num))))
|
||||
if time.Now().Unix() >= next.Unix() {
|
||||
|
||||
WebhookHandleQueue.In <- w
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ func bscInit() {
|
||||
Native: -18, // bsc.bnb 小数位数
|
||||
},
|
||||
Block: block{
|
||||
InitStartOffset: -400,
|
||||
ConfirmedOffset: 15,
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -16,6 +16,7 @@ func ethInit() {
|
||||
Native: -18, // ethereum.eth 小数位数
|
||||
},
|
||||
Block: block{
|
||||
InitStartOffset: -100,
|
||||
ConfirmedOffset: 12,
|
||||
},
|
||||
}),
|
||||
|
||||
+2
-1
@@ -52,6 +52,7 @@ type decimals struct {
|
||||
}
|
||||
|
||||
type block struct {
|
||||
InitStartOffset int64 // 首次偏移量,第一次启动时,区块高度需要叠加此值,设置为负值可解决部分已创建但未超时(未扫描)的订单问题
|
||||
RollDelayOffset int64 // 延迟偏移量,某些RPC节点如果不延迟,会报错 block is out of range,目前发现 https://rpc.xlayer.tech/ 存在此问题
|
||||
ConfirmedOffset int64 // 确认偏移量,开启交易确认后,区块高度需要减去此值认为交易已确认
|
||||
}
|
||||
@@ -146,7 +147,7 @@ func evmBlockRoll(ctx context.Context) {
|
||||
// 首次启动
|
||||
if lastBlockNumber == 0 {
|
||||
|
||||
lastBlockNumber = now - 1
|
||||
lastBlockNumber = now + cfg.Block.InitStartOffset
|
||||
}
|
||||
|
||||
// 区块高度没有变化
|
||||
|
||||
@@ -16,6 +16,7 @@ func polygonInit() {
|
||||
Native: -18, // polygon.pol 小数位数
|
||||
},
|
||||
Block: block{
|
||||
InitStartOffset: -600,
|
||||
ConfirmedOffset: 40,
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type contextKey struct{}
|
||||
|
||||
type task struct {
|
||||
ctx context.Context
|
||||
duration time.Duration
|
||||
|
||||
@@ -82,6 +82,8 @@ func orderTransferHandle(context.Context) {
|
||||
// 标记成功
|
||||
o.MarkSuccess(t.BlockNum, t.FromAddress, t.TxHash, t.Timestamp)
|
||||
|
||||
model.PushWebhookEvent(model.WebhookEventOrderPaid, o)
|
||||
|
||||
go notify.Handle(o) // 通知订单支付成功
|
||||
go bot2.SendTradeSuccMsg(o) // TG发送订单信息
|
||||
}
|
||||
@@ -213,6 +215,7 @@ func getAllWaitingOrders() map[string]model.TradeOrders {
|
||||
if time.Now().Unix() >= order.ExpiredAt.Unix() { // 订单过期
|
||||
order.OrderSetExpired()
|
||||
notify.Bepusdt(order)
|
||||
model.PushWebhookEvent(model.WebhookEventOrderTimeout, order)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
+2
-1
@@ -25,6 +25,7 @@ import (
|
||||
|
||||
// Tron区块确认偏移量
|
||||
const tronBlockConfirmedOffset = 30
|
||||
const tronBlockInitStartOffset = -400 // 大概为过去20分钟的区块高度
|
||||
|
||||
// usdt trc20 contract address 41a614f803b6fd780986a42c78ec9c7f77e6ded13c TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t
|
||||
var usdtTrc20ContractAddress = []byte{0x41, 0xa6, 0x14, 0xf8, 0x03, 0xb6, 0xfd, 0x78, 0x09, 0x86, 0xa4, 0x2c, 0x78, 0xec, 0x9c, 0x7f, 0x77, 0xe6, 0xde, 0xd1, 0x3c}
|
||||
@@ -96,7 +97,7 @@ func tronBlockRoll(context.Context) {
|
||||
// 首次启动
|
||||
if tronLastBlockNum == 0 {
|
||||
|
||||
tronLastBlockNum = now - 1
|
||||
tronLastBlockNum = now + tronBlockInitStartOffset
|
||||
}
|
||||
|
||||
// 区块高度没有变化
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/smallnest/chanx"
|
||||
"github.com/v03413/bepusdt/app"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
var webhookQueueKey = contextKey{}
|
||||
|
||||
func init() {
|
||||
register(task{
|
||||
callback: webhookRoll,
|
||||
ctx: context.WithValue(context.Background(), webhookQueueKey, model.WebhookHandleQueue)},
|
||||
)
|
||||
}
|
||||
|
||||
func webhookRoll(ctx context.Context) {
|
||||
var w model.Webhook
|
||||
var queue = ctx.Value(webhookQueueKey).(*chanx.UnboundedChan[model.Webhook])
|
||||
var ticker = time.NewTicker(time.Minute)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
model.ListWaitWebhooks()
|
||||
case w = <-queue.Out:
|
||||
go webhookHandle(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func webhookHandle(w model.Webhook) {
|
||||
var req, err = http.NewRequest("POST", w.Url, strings.NewReader(w.PostData()))
|
||||
if err != nil {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Powered-By", "https://github.com/v03413/bepusdt")
|
||||
req.Header.Set("User-Agent", "BEpusdt/"+app.Version)
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
log.Warn("Webhook request failed:", err.Error())
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
w.SetStatus(model.WebhookStatusFail)
|
||||
log.Warn("Webhook request failed with status code:", resp.StatusCode)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
w.SetStatus(model.WebhookStatusSucc)
|
||||
|
||||
log.Info("Webhook request success:", w.Event, "to", w.Url)
|
||||
}
|
||||
@@ -16,6 +16,7 @@ func xlayerInit() {
|
||||
Native: -18, // xlayer.okb 小数位数
|
||||
},
|
||||
Block: block{
|
||||
InitStartOffset: -600,
|
||||
RollDelayOffset: 3,
|
||||
ConfirmedOffset: 12,
|
||||
},
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package app
|
||||
|
||||
// Version 版本号说明 1.0.0 代表主版本号.功能版本号.修订号
|
||||
const Version = "1.20.4"
|
||||
const Version = "1.20.6"
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ func epaySubmit(ctx *gin.Context) {
|
||||
var tradeType = model.OrderTradeTypeUsdtTrc20
|
||||
if v, ok := data["type"]; ok {
|
||||
|
||||
tradeType = model.GetTradeType(cast.ToString(v))
|
||||
tradeType = cast.ToString(v)
|
||||
}
|
||||
|
||||
var params = orderParams{
|
||||
|
||||
@@ -159,6 +159,8 @@ func cancelTransaction(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
model.PushWebhookEvent(model.WebhookEventOrderCancel, order)
|
||||
|
||||
ctx.JSON(200, respSuccJson(gin.H{"trade_id": tradeId}))
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package notify
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/v03413/bepusdt/app"
|
||||
"github.com/v03413/bepusdt/app/bot"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/help"
|
||||
@@ -77,7 +78,7 @@ func epay(order model.TradeOrders) {
|
||||
return
|
||||
}
|
||||
|
||||
err = order.OrderSetNotifyState(model.OrderNotifyStateSucc)
|
||||
err = order.SetNotifyState(model.OrderNotifyStateSucc)
|
||||
if err != nil {
|
||||
log.Error("订单标记通知成功错误:", err, order.OrderId)
|
||||
} else {
|
||||
@@ -124,6 +125,7 @@ func epusdt(order model.TradeOrders) {
|
||||
|
||||
postReq.Header.Set("Content-Type", "application/json")
|
||||
postReq.Header.Set("Powered-By", "https://github.com/v03413/bepusdt")
|
||||
postReq.Header.Set("User-Agent", "BEpusdt/"+app.Version)
|
||||
resp, err := client.Do(postReq)
|
||||
if err != nil {
|
||||
markNotifyFail(order, err.Error())
|
||||
@@ -151,7 +153,7 @@ func epusdt(order model.TradeOrders) {
|
||||
return
|
||||
}
|
||||
|
||||
err = order.OrderSetNotifyState(model.OrderNotifyStateSucc)
|
||||
err = order.SetNotifyState(model.OrderNotifyStateSucc)
|
||||
if err != nil {
|
||||
log.Error("订单标记通知成功错误:", err, order.OrderId)
|
||||
} else {
|
||||
@@ -212,16 +214,16 @@ func Bepusdt(order model.TradeOrders) {
|
||||
// 再次序列化
|
||||
jsonBody, err = json.Marshal(body)
|
||||
var client = http.Client{Timeout: time.Second * 5}
|
||||
var postReq, err2 = http.NewRequest("POST", o.NotifyUrl, strings.NewReader(string(jsonBody)))
|
||||
var req, err2 = http.NewRequest("POST", o.NotifyUrl, strings.NewReader(string(jsonBody)))
|
||||
if err2 != nil {
|
||||
db.Rollback()
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
postReq.Header.Set("Content-Type", "application/json")
|
||||
postReq.Header.Set("Powered-By", "https://github.com/v03413/bepusdt")
|
||||
resp, err := client.Do(postReq)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Powered-By", "https://github.com/v03413/bepusdt")
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
db.Rollback()
|
||||
|
||||
@@ -251,7 +253,7 @@ func Bepusdt(order model.TradeOrders) {
|
||||
}
|
||||
|
||||
func markNotifyFail(order model.TradeOrders, reason string) {
|
||||
log.Warn(fmt.Sprintf("订单回调失败(%v):%s %v", order.TradeId, reason, order.OrderSetNotifyState(model.OrderNotifyStateFail)))
|
||||
log.Warn(fmt.Sprintf("订单回调失败(%v):%s %v", order.TradeId, reason, order.SetNotifyState(model.OrderNotifyStateFail)))
|
||||
go func() {
|
||||
bot.SendNotifyFailed(order, reason)
|
||||
}()
|
||||
|
||||
+3
-2
@@ -47,9 +47,8 @@ func buildOrder(p orderParams) (model.TradeOrders, error) {
|
||||
// 获取钱包地址
|
||||
var wallet = model.GetAvailableAddress(p.PayAddress, p.TradeType)
|
||||
if len(wallet) == 0 {
|
||||
log.Error("订单创建失败:还没有配置收款地址")
|
||||
|
||||
return order, fmt.Errorf("没检测到可用收款地址")
|
||||
return order, fmt.Errorf(fmt.Sprintf("类型(%s)没检测到可用收款地址", p.TradeType))
|
||||
}
|
||||
|
||||
// 计算交易金额
|
||||
@@ -93,5 +92,7 @@ func buildOrder(p orderParams) (model.TradeOrders, error) {
|
||||
return order, err
|
||||
}
|
||||
|
||||
model.PushWebhookEvent(model.WebhookEventOrderCreate, tradeOrder)
|
||||
|
||||
return tradeOrder, nil
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ sqlite_path = "/var/lib/bepusdt/sqlite.db"
|
||||
tron_grpc_node = "18.141.79.38:50051"
|
||||
# 日志输出路径
|
||||
output_log = "/var/log/bepusdt.log"
|
||||
# Webhook地址,留空则不弃用
|
||||
webhook_url = ""
|
||||
|
||||
[pay]
|
||||
# usdt 支付原子颗粒度,0.01表示支付数额保留两位小数,相同金额时递增颗粒度为0.01,依次类推,如无特殊需求不建议修改。
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
services:
|
||||
bepusdt:
|
||||
image: v03413/bepusdt:latest # 如果想使用最新的开发版本,可以将镜像名 latest 替换为 beta
|
||||
container_name: bepusdt
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- ./conf.toml:/usr/local/bepusdt/conf.toml
|
||||
- ./data:/var/lib/bepusdt
|
||||
Binary file not shown.
@@ -45,3 +45,19 @@ sqlite_path = "你的数据库文件路径"
|
||||
```
|
||||
|
||||
这样即使容器重新启动或删除,数据也不会丢失。
|
||||
|
||||
## Docker Compose 方式部署
|
||||
|
||||
```yml
|
||||
services:
|
||||
bepusdt:
|
||||
image: v03413/bepusdt:latest
|
||||
container_name: bepusdt
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- ./conf.toml:/usr/local/bepusdt/conf.toml
|
||||
- ./data:/var/lib/bepusdt
|
||||
```
|
||||
|
||||
|
||||
+18
-3
@@ -1,14 +1,29 @@
|
||||
# 独角数卡对接教程
|
||||
|
||||
确保`Bepusdt`已经安装成功,独角数卡后台原生支持对接,按照以下图片格式填写:
|
||||
由于新版`BEpusdt`开始支持不同区块链的USDT、超时回调等新特性,独角自带的`Epusdt`插件已经不再适配,无法直接使用,必须对原有插件进行替换。
|
||||
|
||||
- ‼️重要的事情说三遍,独角自带的`Epusdt`插件无法直接使用,使用必出问题!
|
||||
- ‼️重要的事情说三遍,独角自带的`Epusdt`插件无法直接使用,使用必出问题!
|
||||
- ‼️重要的事情说三遍,独角自带的`Epusdt`插件无法直接使用,使用必出问题!
|
||||
|
||||
因此我对独角数卡进行了适配调整,并对原项目发起了[PR](https://github.com/assimon/dujiaoka/pull/424),只能希望独角能尽快合并吧。
|
||||
|
||||
---
|
||||
|
||||
当你看到这篇文章时,我不确定PR是否已经合并,所以你最好下载此文件 [EpusdtController.php](https://raw.githubusercontent.com/v03413/dujiaoka/refs/heads/master/app/Http/Controllers/Pay/EpusdtController.php)
|
||||
然后在你安装好的独角数卡网站目录`app/Http/Controllers/Pay/`替换原有的同名文件。
|
||||
|
||||
确保`BEpusdt`已经安装成功,独角数卡后台支付对接按照以下图片格式填写:
|
||||
> 独角后台 -> 支付配置 -> 新增
|
||||
>
|
||||

|
||||
|
||||
**重点说下几个参数:**
|
||||
|
||||
- 商户ID:搭建`Bepusdt`时候的参数`AUTH_TOKEN`
|
||||
- 商户ID:搭建`BEpusdt`时候的参数`AUTH_TOKEN`
|
||||
- 支付标识:即收款交易类型,可选`tron.trx usdt.trc20 usdt.erc20`
|
||||
等,[可选列表参考](https://github.com/v03413/BEpusdt/blob/62758f24689a81853a215d122a6012bac8364a82/app/model/orders.go#L25:L30)!
|
||||
- 商户密钥:固定格式为`https://token.pay.com/api/v1/order/create-transaction` ,域名请自行替换
|
||||
- 支付处理路由:固定填写`/pay/epusdt`
|
||||
- 支付处理路由:固定填写`pay/epusdt`
|
||||
|
||||
其它参数按照实际情况填写保存,即可完成对接。
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 115 KiB After Width: | Height: | Size: 125 KiB |
+10
-5
@@ -1,9 +1,14 @@
|
||||
<?php
|
||||
declare (strict_types=1);
|
||||
|
||||
return [
|
||||
'alipay' => '支付宝',
|
||||
'wxpay' => '微信',
|
||||
'qqpay' => 'QQ钱包',
|
||||
'usdt.trc20' => 'USDT.TRC20',
|
||||
'tron.trx' => 'TRON.TRX',
|
||||
'alipay' => '支付宝',
|
||||
'wxpay' => '微信',
|
||||
'qqpay' => 'QQ钱包',
|
||||
'tron.trx' => 'TRON・TRX',
|
||||
'usdt.trc20' => 'USDT・TRC20',
|
||||
'usdt.bep20' => 'USDT・BEP20',
|
||||
'usdt.erc20' => 'USDT・ERC20',
|
||||
'usdt.polygon' => 'USDT・Polygon',
|
||||
'usdt.xlayer' => 'USDT・X-Layer',
|
||||
];
|
||||
@@ -21,7 +21,7 @@
|
||||
订单支付成功后,系统会向商户端发送支付成功回调通知,字段`status`的值为`2`。
|
||||
当响应状态码是`200`,并且响应内容为`ok`时,系统认定为回调成功;否则认为回调失败。
|
||||
|
||||
失败会进行重试,分钟间隔数:`2 4 8 16 32 64 ...`以此类推,当然通过机器人也可以手动标记回调成功。
|
||||
失败会进行重试,分钟间隔数:`2 4 8 16 32 64 ...`以此类推,最大重试次数10,当然通过机器人也可以手动标记回调成功。
|
||||
|
||||
### 等待支付
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# Webhook
|
||||
|
||||
自版本号`v1.20.6`开始,系统开始支持一个简易的Webhook功能。当系统发生特定事件时,向指定的URL发送HTTP POST请求。
|
||||
该功能默认关闭,当配置文件`webhook_url`参数不为空时,系统会自动开启Webhook功能,发生Post请求时:
|
||||
`Content-Type: application/json`,请求体为JSON格式。
|
||||
|
||||
## 事件类型
|
||||
|
||||
目前已知事件:https://github.com/v03413/BEpusdt/blob/525f0f407915b89ed7bccd14c84f32d22d389df1/app/model/webhook.go#L19:L22
|
||||
|
||||
## 请求数据
|
||||
|
||||
```json
|
||||
{
|
||||
"event": "event_type",
|
||||
"data": {
|
||||
"key1": "value1",
|
||||
"key2": "value2"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 请求说明
|
||||
|
||||
当事件发生时会自动触发一个Post请求,响应状态码必须为`200`,否则会认为失败;失败之后会以`2 4 8 16...`指数间隔分钟数重试,最大重试次数为
|
||||
`10`次。
|
||||
Reference in New Issue
Block a user