refactor: 更新项目引用路径从perfect-panel/ppanel-server到perfect-panel/server

feat: 添加版本和构建时间变量
fix: 修正短信队列类型注释错误
style: 清理未使用的代码和测试文件
docs: 更新安装文档中的下载链接
chore: 迁移数据库脚本添加日志和订阅配置
This commit is contained in:
2025-10-13 01:33:03 -07:00
parent 393b42f35a
commit c582087c0f
974 changed files with 23609 additions and 23398 deletions
+2 -2
View File
@@ -4,8 +4,8 @@ import (
"context"
"net/url"
"github.com/perfect-panel/ppanel-server/pkg/logger"
"github.com/perfect-panel/ppanel-server/pkg/tool"
"github.com/perfect-panel/server/pkg/logger"
"github.com/perfect-panel/server/pkg/tool"
"github.com/pkg/errors"
"github.com/smartwalle/alipay/v3"
)
+2 -2
View File
@@ -9,8 +9,8 @@ import (
"strings"
"time"
"github.com/perfect-panel/ppanel-server/pkg/logger"
"github.com/perfect-panel/ppanel-server/pkg/tool"
"github.com/perfect-panel/server/pkg/logger"
"github.com/perfect-panel/server/pkg/tool"
)
type Client struct {
-127
View File
@@ -1,127 +0,0 @@
package payssion
import (
"bytes"
"encoding/json"
"fmt"
"github.com/perfect-panel/ppanel-server/pkg/md5"
"github.com/pkg/errors"
"go.uber.org/zap"
"io"
"log"
"net/http"
)
type Order struct {
Name string
OrderNo string
Amount float64
NotifyUrl string
ReturnUrl string
}
type Client struct {
Name string
ApiKey string
SecretKey string
QueryUrl string
CreateUrl string
PmId string
Currency string
}
func NewClient(apiKey string, secretKey, pmId, currency, queryUrl, createUrl string) *Client {
return &Client{
ApiKey: apiKey,
SecretKey: secretKey,
PmId: pmId,
Currency: currency,
QueryUrl: queryUrl,
CreateUrl: createUrl,
}
}
func (c *Client) CreateOrder(order Order) (string, error) {
content := fmt.Sprintf("%s|%s|%.2f|%s|%s|%s", c.ApiKey, c.PmId, order.Amount, "USD", order.OrderNo, c.SecretKey)
sign := md5.Sign(content)
params := map[string]string{
"api_key": c.ApiKey,
"pm_id": c.PmId,
"amount": fmt.Sprintf("%.2f", order.Amount),
"currency": "USD",
"description": "shop",
"order_id": order.OrderNo,
"api_sig": sign,
"return_url": order.ReturnUrl,
}
marshal, _ := json.Marshal(params)
resp, err := http.Post(c.CreateUrl, "application/json", bytes.NewBuffer(marshal))
if err != nil {
return "", err
}
all, err := io.ReadAll(resp.Body)
if err != nil {
return "", err
}
log.Println(string(all))
result := make(map[string]interface{})
err = json.Unmarshal(all, &result)
if err != nil {
return "", err
}
result_code := result["result_code"]
if fmt.Sprintf("%v", result_code) != "200" {
return "", errors.New(result["description"].(string))
}
url := result["redirect_url"]
if url == nil {
return "", errors.New(string(all))
}
return url.(string), nil
}
func (c *Client) QueryOrder(orderNo string) (queryResult *QueryResult, err error) {
content := fmt.Sprintf("%s|%s|%s", c.ApiKey, orderNo, c.SecretKey)
sign := md5.Sign(content)
params := map[string]string{
"api_key": c.ApiKey,
"order_id": orderNo,
"api_sig": sign,
}
marshal, _ := json.Marshal(params)
resp, err := http.Post(c.QueryUrl, "application/json", bytes.NewBuffer(marshal))
if err != nil {
return nil, err
}
all, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
zap.S().Infof("Payssion QueryOrderDetail result: %s", string(all))
err = json.Unmarshal(all, &queryResult)
return queryResult, err
}
type QueryResult struct {
Transaction struct {
TransactionID string `json:"transaction_id"`
Description string `json:"description"`
AppName string `json:"app_name"`
PmID string `json:"pm_id"`
Amount string `json:"amount"`
Currency string `json:"currency"`
OrderID string `json:"order_id"`
Paid string `json:"paid"`
Net string `json:"net"`
State string `json:"state"`
Fee string `json:"fee"`
Refund string `json:"refund"`
RefundFee string `json:"refund_fee"`
Created int64 `json:"created"`
Updated int64 `json:"updated"`
Fees string `json:"fees"`
FeesAdd string `json:"fees_add"`
RefundFees string `json:"refund_fees"`
} `json:"transaction"`
ResultCode int64 `json:"result_code"`
}
-32
View File
@@ -1,32 +0,0 @@
package payssion
import (
"fmt"
"testing"
)
func TestCreateOrder(t *testing.T) {
client := Client{
ApiKey: "",
PmId: "",
SecretKey: "",
QueryUrl: "http://sandbox.payssion.com/api/v1/payment/getDetail",
CreateUrl: "http://sandbox.payssion.com/api/v1/payments",
}
order := Order{
Name: "shop",
OrderNo: "123",
Amount: 1000,
}
createOrder, err := client.CreateOrder(order)
if err != nil {
t.Error(err)
return
}
fmt.Println(createOrder)
queryOrder, err := client.QueryOrder(order.OrderNo)
if err != nil {
t.Error(err)
}
fmt.Println(queryOrder.Transaction.State)
}
+9 -12
View File
@@ -1,6 +1,6 @@
package payment
import "github.com/perfect-panel/ppanel-server/internal/types"
import "github.com/perfect-panel/server/internal/types"
type Platform int
@@ -9,15 +9,15 @@ const (
AlipayF2F
EPay
Balance
Payssion
UNSUPPORTED
CryptoSaaS
UNSUPPORTED Platform = -1
)
var platformNames = map[string]Platform{
"CryptoSaaS": CryptoSaaS,
"Stripe": Stripe,
"AlipayF2F": AlipayF2F,
"EPay": EPay,
"Payssion": Payssion,
"balance": Balance,
"unsupported": UNSUPPORTED,
}
@@ -71,15 +71,12 @@ func GetSupportedPlatforms() []types.PlatformInfo {
},
},
{
Platform: Payssion.String(),
PlatformUrl: "",
Platform: CryptoSaaS.String(),
PlatformUrl: "https://t.me/CryptoSaaSBot",
PlatformFieldDescription: map[string]string{
"api_key": "api_key",
"secret_key": "secret_key",
"pm_id": "pm_id",
"currency": "currency",
"create_url": "Create URL",
"query_url": "Query URL",
"endpoint": "API Endpoint",
"account_id": "Account ID",
"secret_key": "Secret Key",
},
},
}
+16 -1
View File
@@ -5,7 +5,9 @@ import (
"fmt"
"strconv"
"github.com/perfect-panel/ppanel-server/pkg/logger"
"github.com/stripe/stripe-go/v81/webhookendpoint"
"github.com/perfect-panel/server/pkg/logger"
"github.com/stripe/stripe-go/v81"
"github.com/stripe/stripe-go/v81/customer"
"github.com/stripe/stripe-go/v81/ephemeralkey"
@@ -193,3 +195,16 @@ func (c *Client) RetrievePaymentMethod(id string) (*stripe.PaymentMethod, error)
stripe.Key = c.SecretKey
return paymentmethod.Get(id, nil)
}
// CreateWebhookEndpoint 创建 webhook endpoint
func (c *Client) CreateWebhookEndpoint(url string) (*stripe.WebhookEndpoint, error) {
stripe.Key = c.SecretKey
params := &stripe.WebhookEndpointParams{
URL: stripe.String(url),
EnabledEvents: []*string{
stripe.String("payment_intent.succeeded"),
stripe.String("payment_intent.payment_failed"),
},
}
return webhookendpoint.New(params)
}
+2 -2
View File
@@ -20,7 +20,7 @@ func TestStripeAlipay(t *testing.T) {
}
user := User{
UserId: 1,
Email: "tension@muran.org",
Email: "tension@ppanel.dev",
}
result, err := client.CreatePaymentSheet(&order, &user)
if err != nil {
@@ -45,7 +45,7 @@ func TestStripeWechat(t *testing.T) {
}
user := User{
UserId: 1,
Email: "tension@muran.org",
Email: "tension@ppanel.dev",
}
result, err := client.CreatePaymentSheet(&order, &user)
if err != nil {