Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions controller/topup.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,15 @@ func GetTopUpInfo(c *gin.Context) {
}

data := gin.H{
"enable_online_topup": isEpayTopUpEnabled(),
"enable_stripe_topup": isStripeTopUpEnabled(),
"enable_creem_topup": isCreemTopUpEnabled(),
"enable_oen_topup": enableOen,
"enable_waffo_topup": enableWaffo,
"enable_waffo_pancake_topup": enableWaffoPancake,
"enable_manual_bank_transfer_topup": isManualBankTransferTopUpEnabled(),
"enable_redemption": complianceConfirmed,
"payment_compliance_confirmed": complianceConfirmed,
"payment_compliance_terms_version": operation_setting.CurrentComplianceTermsVersion,
"enable_online_topup": isEpayTopUpEnabled(),
"enable_stripe_topup": isStripeTopUpEnabled(),
"enable_creem_topup": isCreemTopUpEnabled(),
"enable_oen_topup": enableOen,
"enable_waffo_topup": enableWaffo,
"enable_waffo_pancake_topup": enableWaffoPancake,
"enable_redemption": complianceConfirmed,
"payment_compliance_confirmed": complianceConfirmed,
"payment_compliance_terms_version": operation_setting.CurrentComplianceTermsVersion,
"waffo_pay_methods": func() interface{} {
if enableWaffo {
return setting.GetWaffoPayMethods()
Expand Down
18 changes: 9 additions & 9 deletions controller/topup_manual_bank_transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ import (
"github.com/shopspring/decimal"
)

type ManualBankTransferPayRequest struct {
Amount int64 `json:"amount"`
}
const manualBankTransferPaymentType = "manual_bank_transfer"

func isManualBankTransferTopUpEnabled() bool {
config := operation_setting.GetManualBankTransferConfig()
Expand All @@ -35,20 +33,22 @@ func appendManualBankTransferPayMethod(payMethods []map[string]string) []map[str
return payMethods
}
for _, method := range payMethods {
if method["type"] == model.PaymentMethodManualBankTransfer {
if method["type"] == manualBankTransferPaymentType {
return payMethods
}
}
return append(payMethods, map[string]string{
"name": "Manual Bank Transfer",
"type": model.PaymentMethodManualBankTransfer,
"type": manualBankTransferPaymentType,
"icon": "LuLandmark",
"color": "#0F766E",
"min_topup": strconv.FormatInt(getMinTopup(), 10),
})
}

func RequestManualBankTransferPay(c *gin.Context) {
// CreateManualBankTransferTopUp adapts manual transfers to the existing TopUp
// lifecycle. AdminCompleteTopUp remains the only path that credits the order.
func CreateManualBankTransferTopUp(c *gin.Context) {
if !requirePaymentCompliance(c) {
return
}
Expand All @@ -57,7 +57,7 @@ func RequestManualBankTransferPay(c *gin.Context) {
return
}

var request ManualBankTransferPayRequest
var request AmountRequest
if err := c.ShouldBindJSON(&request); err != nil {
common.ApiErrorMsg(c, "参数错误")
return
Expand Down Expand Up @@ -99,8 +99,8 @@ func RequestManualBankTransferPay(c *gin.Context) {
Amount: normalizedAmount,
Money: payMoney,
TradeNo: tradeNo,
PaymentMethod: model.PaymentMethodManualBankTransfer,
PaymentProvider: model.PaymentProviderManualBankTransfer,
PaymentMethod: manualBankTransferPaymentType,
PaymentProvider: manualBankTransferPaymentType,
CreateTime: time.Now().Unix(),
Status: common.TopUpStatusPending,
}
Expand Down
8 changes: 4 additions & 4 deletions controller/topup_manual_bank_transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"gorm.io/gorm"
)

func TestRequestManualBankTransferPayWaitsForAdminCompletionBeforeCreditingQuota(t *testing.T) {
func TestCreateManualBankTransferTopUpWaitsForAdminCompletionBeforeCreditingQuota(t *testing.T) {
oldDB := model.DB
oldLogDB := model.LOG_DB
oldMainDatabaseType := common.MainDatabaseType()
Expand Down Expand Up @@ -88,12 +88,12 @@ func TestRequestManualBankTransferPayWaitsForAdminCompletionBeforeCreditingQuota
ctx.Set("id", user.Id)
ctx.Request = httptest.NewRequest(
http.MethodPost,
"/api/user/manual-bank-transfer/pay",
"/api/user/topup/manual-bank-transfer",
strings.NewReader(`{"amount":10}`),
)
ctx.Request.Header.Set("Content-Type", "application/json")

RequestManualBankTransferPay(ctx)
CreateManualBankTransferTopUp(ctx)

assert.Equal(t, http.StatusOK, recorder.Code)
var response struct {
Expand All @@ -119,7 +119,7 @@ func TestRequestManualBankTransferPayWaitsForAdminCompletionBeforeCreditingQuota
assert.Equal(t, user.Id, topUp.UserId)
assert.Equal(t, int64(10), topUp.Amount)
assert.Equal(t, float64(350), topUp.Money)
assert.Equal(t, model.PaymentProviderManualBankTransfer, topUp.PaymentProvider)
assert.Equal(t, manualBankTransferPaymentType, topUp.PaymentProvider)
assert.Equal(t, common.TopUpStatusPending, topUp.Status)

var reloaded model.User
Expand Down
6 changes: 0 additions & 6 deletions model/topup_manual_bank_transfer.go

This file was deleted.

2 changes: 1 addition & 1 deletion router/api-router.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func SetApiRouter(router *gin.Engine) {
selfRoute.POST("/creem/pay", middleware.CriticalRateLimit(), controller.RequestCreemPay)
selfRoute.POST("/oen/amount", controller.RequestOenAmount)
selfRoute.POST("/oen/pay", middleware.CriticalRateLimit(), controller.RequestOenPay)
selfRoute.POST("/manual-bank-transfer/pay", middleware.CriticalRateLimit(), controller.RequestManualBankTransferPay)
selfRoute.POST("/topup/manual-bank-transfer", middleware.CriticalRateLimit(), controller.CreateManualBankTransferTopUp)
selfRoute.POST("/waffo/amount", controller.RequestWaffoAmount)
selfRoute.POST("/waffo/pay", middleware.CriticalRateLimit(), controller.RequestWaffoPay)
selfRoute.POST("/waffo-pancake/amount", controller.RequestWaffoPancakeAmount)
Expand Down
2 changes: 1 addition & 1 deletion web/src/features/wallet/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export async function requestOenPayment(
export async function requestManualBankTransferPayment(
request: AmountRequest
): Promise<ManualBankTransferPaymentResponse> {
const res = await api.post('/api/user/manual-bank-transfer/pay', request, {
const res = await api.post('/api/user/topup/manual-bank-transfer', request, {
skipBusinessError: true,
} as Record<string, unknown>)
return res.data
Expand Down
5 changes: 4 additions & 1 deletion web/src/features/wallet/components/recharge-form-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,14 @@ export function RechargeFormCard({
}
}

const hasManualBankTransfer = topupInfo?.pay_methods?.some(
(method) => method.type === PAYMENT_TYPES.MANUAL_BANK_TRANSFER
)
const hasConfigurableTopup =
topupInfo?.enable_online_topup ||
topupInfo?.enable_stripe_topup ||
topupInfo?.enable_oen_topup ||
topupInfo?.enable_manual_bank_transfer_topup ||
hasManualBankTransfer ||
enableWaffoTopup ||
enableWaffoPancakeTopup
const hasAnyTopup = hasConfigurableTopup || enableCreemTopup
Expand Down
8 changes: 0 additions & 8 deletions web/src/features/wallet/lib/payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,6 @@ export function getDefaultPaymentType(topupInfo: TopupInfo | null): string {
return PAYMENT_TYPES.OEN
}

if (topupInfo.enable_manual_bank_transfer_topup) {
return PAYMENT_TYPES.MANUAL_BANK_TRANSFER
}

if (topupInfo.enable_waffo_topup) {
return PAYMENT_TYPES.WAFFO
}
Expand Down Expand Up @@ -188,10 +184,6 @@ export function getMinTopupAmount(topupInfo: TopupInfo | null): number {
return topupInfo.oen_min_topup || DEFAULT_MIN_TOPUP
}

if (topupInfo.enable_manual_bank_transfer_topup) {
return topupInfo.min_topup || DEFAULT_MIN_TOPUP
}

if (topupInfo.enable_waffo_topup) {
return topupInfo.waffo_min_topup || DEFAULT_MIN_TOPUP
}
Expand Down
2 changes: 0 additions & 2 deletions web/src/features/wallet/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ export interface TopupInfo {
enable_stripe_topup: boolean
/** Whether OEN Payment topup is enabled */
enable_oen_topup?: boolean
/** Whether manual bank transfer topup is enabled */
enable_manual_bank_transfer_topup?: boolean
/** Available payment methods */
pay_methods: PaymentMethod[]
/** Minimum topup amount for online topup */
Expand Down