1
1
<script setup lang="ts">
2
2
import { parseQuery } from ' ufo'
3
+ import { PaymentStatus } from ' @base/server/db/schemas'
3
4
4
5
definePageMeta ({
5
6
middleware(to ) {
@@ -29,9 +30,30 @@ const checkoutInfo = computed(() => {
29
30
return query
30
31
})
31
32
32
- function handleCheckStatus() {
33
- //
34
- }
33
+ const paymentApi = useApiPayment ()
34
+
35
+ const { data, error, execute : handleCheckStatus } = useAsyncData (
36
+ ' checkoutInfo' ,
37
+ () => paymentApi .checkStatus (' sepay' , String (checkoutInfo .value .des )),
38
+ { server: false , immediate: false },
39
+ )
40
+
41
+ whenever (error , (err ) => {
42
+ notifyError ({
43
+ content: getErrorMessage (err ),
44
+ })
45
+ })
46
+
47
+ whenever (data , (response ) => {
48
+ if (response ?.data ?.status === PaymentStatus .RESOLVED ) {
49
+ navigateTo ({ name: ' app' })
50
+ }
51
+ else {
52
+ notifyError ({
53
+ content: ' We have not received your payment yet. Please try again later, or contact support if the issue persists.' ,
54
+ })
55
+ }
56
+ })
35
57
</script >
36
58
37
59
<template >
@@ -61,12 +83,12 @@ function handleCheckStatus() {
61
83
<span class =" text-lg font-medium text-gray-500 dark:text-gray-400" >{{ $t('Bank Name') }}</span >
62
84
<span class =" text-lg font-semibold text-gray-900 dark:text-white" >{{ checkoutInfo.bank }}</span >
63
85
</div >
64
- < UDivider />
86
+
65
87
<div class =" flex justify-between items-center" >
66
88
<span class =" text-lg font-medium text-gray-500 dark:text-gray-400" >{{ $t('Amount') }}</span >
67
89
<span class =" text-xl font-bold text-primary-500 dark:text-primary-400" >{{ checkoutInfo.amount }}</span >
68
90
</div >
69
- < UDivider />
91
+
70
92
<div class =" flex justify-between items-start" >
71
93
<span class =" text-lg font-medium text-gray-500 dark:text-gray-400" >{{ $t('Description') }}</span >
72
94
<span class =" text-lg text-gray-700 dark:text-gray-300 text-right" >{{ checkoutInfo.des }}</span >
@@ -80,7 +102,7 @@ function handleCheckStatus() {
80
102
<div >
81
103
<UButton
82
104
class =" w-full font-semibold mt-4" size =" xl"
83
- @click =" handleCheckStatus"
105
+ @click =" handleCheckStatus() "
84
106
>
85
107
{{ $t('I have transfered the money! (Click here)') }}
86
108
</UButton >
0 commit comments