支持拉卡拉多渠道支付和测试充值

This commit is contained in:
yml
2026-06-06 21:46:41 +08:00
parent 4d40883da6
commit ba4c56c0cc
16 changed files with 1917 additions and 157 deletions
+26 -5
View File
@@ -1,6 +1,9 @@
package payment
import "errors"
import (
"errors"
"strings"
)
var (
ErrDependencyUnavailable = errors.New("dependency unavailable")
@@ -15,11 +18,19 @@ var (
const MinWalletRechargeAmount = 0.01
type Service struct {
repo *Repository
repo *Repository
walletRechargeEnabled bool
}
func NewService(repo *Repository) *Service {
return &Service{repo: repo}
func NewService(repo *Repository, appEnv ...string) *Service {
env := "production"
if len(appEnv) > 0 {
env = strings.ToLower(strings.TrimSpace(appEnv[0]))
}
return &Service{
repo: repo,
walletRechargeEnabled: env != "production",
}
}
func (s *Service) Start(userID uint64, orderID uint64, req StartPaymentRequest, clientIP string) (*PaymentDTO, error) {
@@ -46,7 +57,10 @@ func (s *Service) StartWalletRecharge(userID uint64, req WalletRechargePaymentRe
if s.repo == nil {
return nil, ErrDependencyUnavailable
}
return nil, ErrWalletRechargeDisabled
if !s.walletRechargeEnabled {
return nil, ErrWalletRechargeDisabled
}
return s.repo.StartWalletRecharge(userID, req, clientIP)
}
func (s *Service) QueryWalletRecharge(userID uint64, paymentID uint64) (*PaymentDTO, error) {
@@ -66,6 +80,13 @@ func (s *Service) HandleLeshuaNotify(params map[string]string, rawPayload string
return s.repo.HandleLeshuaNotify(params, rawPayload, contentType)
}
func (s *Service) HandleNotify(provider string, params map[string]string, rawPayload string, contentType string, authorization string) (*NotifyResult, error) {
if s.repo == nil {
return nil, ErrDependencyUnavailable
}
return s.repo.HandleNotify(provider, params, rawPayload, contentType, authorization)
}
func (s *Service) StartRefund(orderID uint64, refundAmountCent int64, bizType string, remark string) (*RefundDTO, error) {
if s.repo == nil {
return nil, ErrDependencyUnavailable