更新充值支付接口
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
'use server'
|
'use server'
|
||||||
import {callByUser, callPublic} from '@/actions/base'
|
import {callByUser, callPublic} from '@/actions/base'
|
||||||
|
|
||||||
export async function RechargeByPay(props: {
|
export async function RechargePrepare(props: {
|
||||||
amount: string
|
amount: string
|
||||||
platform: number
|
platform: number
|
||||||
method: number
|
method: number
|
||||||
@@ -12,25 +12,10 @@ export async function RechargeByPay(props: {
|
|||||||
}>('/api/user/recharge/prepare', props)
|
}>('/api/user/recharge/prepare', props)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function RechargeByAlipayConfirm(props: {
|
export async function RechargeComplete(props: {
|
||||||
trade_no: string
|
trade_no: string
|
||||||
}) {
|
}) {
|
||||||
return callByUser('/api/user/recharge/confirm/alipay', props)
|
return callByUser('/api/user/recharge/complete', 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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function Identify(props: {
|
export async function Identify(props: {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import {useState} from 'react'
|
import {useState, MouseEvent} from 'react'
|
||||||
import {Dialog, DialogContent} from '@/components/ui/dialog'
|
import {Dialog, DialogContent} from '@/components/ui/dialog'
|
||||||
import {Button} from '@/components/ui/button'
|
import {Button} from '@/components/ui/button'
|
||||||
import {CheckCircle, AlertCircle, ClockIcon} from 'lucide-react'
|
import {CheckCircle, AlertCircle, ClockIcon} from 'lucide-react'
|
||||||
@@ -25,7 +25,7 @@ export function PaymentStatusCell({trade}: {
|
|||||||
const [paymentFailed, setPaymentFailed] = useState(false)
|
const [paymentFailed, setPaymentFailed] = useState(false)
|
||||||
const platform = usePlatformType()
|
const platform = usePlatformType()
|
||||||
|
|
||||||
const handleClick = (e: React.MouseEvent) => {
|
const handleClick = (e: MouseEvent) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
if (!trade?.pay_url) return
|
if (!trade?.pay_url) return
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ export function PaymentStatusCell({trade}: {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-center mt-4">
|
<div className="flex justify-center mt-4">
|
||||||
<Button className="w-full max-w-[200px]" onClick={() => setPaymentFailed(false)} >完成</Button>
|
<Button className="w-full max-w-[200px]" onClick={() => setPaymentFailed(false)}>完成</Button>
|
||||||
</div>
|
</div>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|||||||
@@ -15,11 +15,9 @@ import {RadioGroup} from '@/components/ui/radio-group'
|
|||||||
import Image from 'next/image'
|
import Image from 'next/image'
|
||||||
import {zodResolver} from '@hookform/resolvers/zod'
|
import {zodResolver} from '@hookform/resolvers/zod'
|
||||||
import {toast} from 'sonner'
|
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 {useEffect, useMemo, useRef, useState} from 'react'
|
||||||
import {Loader} from 'lucide-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 * as qrcode from 'qrcode'
|
||||||
import {useProfileStore} from '@/app/stores'
|
import {useProfileStore} from '@/app/stores'
|
||||||
import {merge} from '@/lib/utils'
|
import {merge} from '@/lib/utils'
|
||||||
@@ -103,12 +101,7 @@ export default function RechargeModal(props: RechargeModelProps) {
|
|||||||
}
|
}
|
||||||
console.log(resp, 'resp')
|
console.log(resp, 'resp')
|
||||||
|
|
||||||
// const result = await RechargeByPay({
|
const result = await RechargePrepare(resp)
|
||||||
// amount: data.amount.toString(),
|
|
||||||
// platform: platform,
|
|
||||||
// method: parseInt(paymentMethod[0]) as PaymentMethod,
|
|
||||||
// })
|
|
||||||
const result = await RechargeByPay(resp)
|
|
||||||
console.log(result, 'result')
|
console.log(result, 'result')
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
@@ -136,7 +129,7 @@ export default function RechargeModal(props: RechargeModelProps) {
|
|||||||
try {
|
try {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case 'alipay':
|
case 'alipay':
|
||||||
const aliRes = await RechargeByAlipayConfirm({
|
const aliRes = await RechargeComplete({
|
||||||
trade_no: payInfo.trade_no,
|
trade_no: payInfo.trade_no,
|
||||||
})
|
})
|
||||||
if (!aliRes.success) {
|
if (!aliRes.success) {
|
||||||
@@ -144,7 +137,7 @@ export default function RechargeModal(props: RechargeModelProps) {
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 'wechat':
|
case 'wechat':
|
||||||
const weRes = await RechargeByWechatConfirm({
|
const weRes = await RechargeComplete({
|
||||||
trade_no: payInfo.trade_no,
|
trade_no: payInfo.trade_no,
|
||||||
})
|
})
|
||||||
if (!weRes.success) {
|
if (!weRes.success) {
|
||||||
|
|||||||
Reference in New Issue
Block a user