mirror of
https://github.com/GMWalletApp/epusdt.git
synced 2026-07-07 10:16:15 +00:00
2a36a10e7f
- add on-chain validation before manual mark-paid - verify recipient address, token contract, amount, confirmations, and tx time - reject duplicate transaction hashes and non on-chain orders - add manual payment verification tests for EVM, TRON, and Solana - change BSC network key to binance - add display_name to supported_assets while keeping network unchanged
39 lines
1.3 KiB
Go
39 lines
1.3 KiB
Go
package service
|
|
|
|
import (
|
|
"github.com/GMWalletApp/epusdt/config"
|
|
"github.com/GMWalletApp/epusdt/model/data"
|
|
"github.com/GMWalletApp/epusdt/model/response"
|
|
"github.com/GMWalletApp/epusdt/util/constant"
|
|
)
|
|
|
|
// ErrOrder is returned when checkout initialization cannot find the trade id.
|
|
var ErrOrder = constant.OrderNotExists
|
|
|
|
// GetCheckoutCounterByTradeId returns checkout initialization data for an existing order.
|
|
// It does not decide the payment state; callers should use CheckStatus for that.
|
|
func GetCheckoutCounterByTradeId(tradeId string) (*response.CheckoutCounterResponse, error) {
|
|
orderInfo, err := data.GetOrderInfoByTradeId(tradeId)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if orderInfo.ID <= 0 {
|
|
return nil, ErrOrder
|
|
}
|
|
|
|
resp := &response.CheckoutCounterResponse{
|
|
TradeId: orderInfo.TradeId,
|
|
Amount: orderInfo.Amount,
|
|
ActualAmount: orderInfo.ActualAmount,
|
|
Token: orderInfo.Token,
|
|
Currency: orderInfo.Currency,
|
|
ReceiveAddress: orderInfo.ReceiveAddress,
|
|
Network: orderInfo.Network,
|
|
ExpirationTime: orderInfo.CreatedAt.AddMinutes(config.GetOrderExpirationTime()).TimestampMilli(),
|
|
RedirectUrl: orderInfo.RedirectUrl,
|
|
CreatedAt: orderInfo.CreatedAt.TimestampMilli(),
|
|
IsSelected: orderInfo.IsSelected,
|
|
}
|
|
return resp, nil
|
|
}
|