11<script setup lang="ts">
22import { parseQuery } from ' ufo'
3+ import { PaymentStatus } from ' @base/server/db/schemas'
34
45definePageMeta ({
56 middleware(to ) {
@@ -29,9 +30,30 @@ const checkoutInfo = computed(() => {
2930 return query
3031})
3132
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+ })
3557 </script >
3658
3759<template >
@@ -61,12 +83,12 @@ function handleCheckStatus() {
6183 <span class =" text-lg font-medium text-gray-500 dark:text-gray-400" >{{ $t('Bank Name') }}</span >
6284 <span class =" text-lg font-semibold text-gray-900 dark:text-white" >{{ checkoutInfo.bank }}</span >
6385 </div >
64- < UDivider />
86+
6587 <div class =" flex justify-between items-center" >
6688 <span class =" text-lg font-medium text-gray-500 dark:text-gray-400" >{{ $t('Amount') }}</span >
6789 <span class =" text-xl font-bold text-primary-500 dark:text-primary-400" >{{ checkoutInfo.amount }}</span >
6890 </div >
69- < UDivider />
91+
7092 <div class =" flex justify-between items-start" >
7193 <span class =" text-lg font-medium text-gray-500 dark:text-gray-400" >{{ $t('Description') }}</span >
7294 <span class =" text-lg text-gray-700 dark:text-gray-300 text-right" >{{ checkoutInfo.des }}</span >
@@ -80,7 +102,7 @@ function handleCheckStatus() {
80102 <div >
81103 <UButton
82104 class =" w-full font-semibold mt-4" size =" xl"
83- @click =" handleCheckStatus"
105+ @click =" handleCheckStatus() "
84106 >
85107 {{ $t('I have transfered the money! (Click here)') }}
86108 </UButton >
0 commit comments