@@ -15,6 +15,7 @@ import {
1515
1616export function MicroTransactionStore ( ) {
1717 const [ selectedPackage , setSelectedPackage ] = useState < string | null > ( null ) ;
18+ const [ isProcessing , setIsProcessing ] = useState < boolean > ( false ) ;
1819 const { data : gemPackages , isLoading } = useGetAllProducts ( ) ;
1920 const { mutate : validateUser } = useValidateUser ( ) ;
2021
@@ -35,19 +36,25 @@ export function MicroTransactionStore() {
3536 console . log ( "Payment link retrieved:" , paymentLink ) ;
3637 const paymentLinkSession = await BoltSDK . gaming . openCheckout ( paymentLink ) ;
3738
39+ setIsProcessing ( true ) ;
40+
3841 if ( ! paymentLinkSession ) {
3942 console . error ( "Failed to open payment link session" ) ;
43+ setIsProcessing ( false ) ;
4044 return ;
4145 } else if ( paymentLinkSession . status === "abandoned" ) {
4246 console . log ( "Purchase cancelled by user:" , pkg . name ) ;
47+ setIsProcessing ( false ) ;
4348 } else {
4449 console . log ( "Purchase pending for:" , pkg . name ) ;
4550 validateUser ( paymentLinkSession . paymentLinkId , {
4651 onSuccess : ( data ) => {
52+ setIsProcessing ( false ) ;
4753 toast . success ( `Successfully purchased ${ pkg . gemAmount } gems!` ) ;
4854 console . log ( "User validated:" , data ) ;
4955 } ,
5056 onError : ( error ) => {
57+ setIsProcessing ( false ) ;
5158 toast . error ( `Failed to validate purchase: ${ error . message } ` ) ;
5259 console . error ( "Validation error:" , error ) ;
5360 } ,
@@ -73,6 +80,13 @@ export function MicroTransactionStore() {
7380 />
7481 ) ) }
7582 </ div >
83+
84+ { isProcessing && (
85+ < div className = "processing-spinner" >
86+ < div className = "spinner" > </ div >
87+ < p > Processing your purchase...</ p >
88+ </ div >
89+ ) }
7690 </ div >
7791 < div className = "coin-store-footer" >
7892 < p >
0 commit comments