mirror of
https://github.com/GMWalletApp/epusdt.git
synced 2026-07-07 02:06:16 +00:00
32 lines
959 B
Go
32 lines
959 B
Go
package service
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/assimon/luuu/config"
|
|
"github.com/assimon/luuu/model/data"
|
|
"github.com/assimon/luuu/model/mdb"
|
|
"github.com/assimon/luuu/model/response"
|
|
)
|
|
|
|
// GetCheckoutCounterByTradeId returns checkout info for a pending order.
|
|
func GetCheckoutCounterByTradeId(tradeId string) (*response.CheckoutCounterResponse, error) {
|
|
orderInfo, err := data.GetOrderInfoByTradeId(tradeId)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if orderInfo.ID <= 0 || orderInfo.Status != mdb.StatusWaitPay {
|
|
return nil, errors.New("pending order does not exist or has expired")
|
|
}
|
|
|
|
resp := &response.CheckoutCounterResponse{
|
|
TradeId: orderInfo.TradeId,
|
|
ActualAmount: orderInfo.ActualAmount,
|
|
ReceiveAddress: orderInfo.ReceiveAddress,
|
|
Token: orderInfo.Token,
|
|
ExpirationTime: orderInfo.CreatedAt.AddMinutes(config.GetOrderExpirationTime()).TimestampMilli(),
|
|
RedirectUrl: orderInfo.RedirectUrl,
|
|
}
|
|
return resp, nil
|
|
}
|