diff --git a/src/actions/user.ts b/src/actions/user.ts index 358c1e3..d72b7bc 100644 --- a/src/actions/user.ts +++ b/src/actions/user.ts @@ -1,7 +1,7 @@ 'use server' import {callByUser, callPublic} from '@/actions/base' -export async function RechargeByPay(props: { +export async function RechargePrepare(props: { amount: string platform: number method: number @@ -12,25 +12,10 @@ export async function RechargeByPay(props: { }>('/api/user/recharge/prepare', props) } -export async function RechargeByAlipayConfirm(props: { +export async function RechargeComplete(props: { trade_no: string }) { - return callByUser('/api/user/recharge/confirm/alipay', props) -} - -export async function RechargeByWechat(props: { - amount: string -}) { - return callByUser<{ - trade_no: string - pay_url: string - }>('/api/user/recharge/prepare/wechat', props) -} - -export async function RechargeByWechatConfirm(props: { - trade_no: string -}) { - return callByUser('/api/user/recharge/confirm/wechat', props) + return callByUser('/api/user/recharge/complete', props) } export async function Identify(props: { diff --git a/src/components/composites/payment/payment.tsx b/src/components/composites/payment/payment.tsx index 2c74a0b..fa8dfb2 100644 --- a/src/components/composites/payment/payment.tsx +++ b/src/components/composites/payment/payment.tsx @@ -1,5 +1,5 @@ 'use client' -import {useState} from 'react' +import {useState, MouseEvent} from 'react' import {Dialog, DialogContent} from '@/components/ui/dialog' import {Button} from '@/components/ui/button' import {CheckCircle, AlertCircle, ClockIcon} from 'lucide-react' @@ -25,7 +25,7 @@ export function PaymentStatusCell({trade}: { const [paymentFailed, setPaymentFailed] = useState(false) const platform = usePlatformType() - const handleClick = (e: React.MouseEvent) => { + const handleClick = (e: MouseEvent) => { e.preventDefault() if (!trade?.pay_url) return @@ -129,7 +129,7 @@ export function PaymentStatusCell({trade}: {
- +
diff --git a/src/components/composites/recharge/index.tsx b/src/components/composites/recharge/index.tsx index c564de3..01ef705 100644 --- a/src/components/composites/recharge/index.tsx +++ b/src/components/composites/recharge/index.tsx @@ -15,11 +15,9 @@ import {RadioGroup} from '@/components/ui/radio-group' import Image from 'next/image' import {zodResolver} from '@hookform/resolvers/zod' import {toast} from 'sonner' -import wechat from '@/components/composites/purchase/_assets/wechat.svg' -import alipay from '@/components/composites/purchase/_assets/alipay.svg' import {useEffect, useMemo, useRef, useState} from 'react' import {Loader} from 'lucide-react' -import {RechargeByPay, RechargeByAlipayConfirm, RechargeByWechat, RechargeByWechatConfirm} from '@/actions/user' +import {RechargeComplete, RechargePrepare} from '@/actions/user' import * as qrcode from 'qrcode' import {useProfileStore} from '@/app/stores' import {merge} from '@/lib/utils' @@ -103,12 +101,7 @@ export default function RechargeModal(props: RechargeModelProps) { } console.log(resp, 'resp') - // const result = await RechargeByPay({ - // amount: data.amount.toString(), - // platform: platform, - // method: parseInt(paymentMethod[0]) as PaymentMethod, - // }) - const result = await RechargeByPay(resp) + const result = await RechargePrepare(resp) console.log(result, 'result') if (result.success) { @@ -136,7 +129,7 @@ export default function RechargeModal(props: RechargeModelProps) { try { switch (method) { case 'alipay': - const aliRes = await RechargeByAlipayConfirm({ + const aliRes = await RechargeComplete({ trade_no: payInfo.trade_no, }) if (!aliRes.success) { @@ -144,7 +137,7 @@ export default function RechargeModal(props: RechargeModelProps) { } break case 'wechat': - const weRes = await RechargeByWechatConfirm({ + const weRes = await RechargeComplete({ trade_no: payInfo.trade_no, }) if (!weRes.success) {