@@ -121,6 +121,21 @@ async function onCancel() {
121121 }
122122}
123123
124+ async function onError(err : any ) {
125+ // Let the user know that something went wrong
126+ await sdkEmit (' error' , { message: ` ${err } ` });
127+ }
128+
129+ async function onStreamTimeout() {
130+ open .value = false ;
131+ await onError (' stream_timed_out' );
132+ }
133+
134+ async function onStreamClosed() {
135+ open .value = false ;
136+ await onError (' stream_closed' );
137+ }
138+
124139// Add an event listener for the 'visibilitychange' event
125140document .addEventListener (" visibilitychange" , async () => {
126141 if (document .visibilityState === " visible" ) {
@@ -149,13 +164,19 @@ document.addEventListener("visibilitychange", async () => {
149164 @channel-created =" onChannelCreated "
150165 @intent-submitted =" onSuccess "
151166 @client-rejected-payment =" onCancel "
167+ @error =" onError "
168+ @stream-timeout =" onStreamTimeout "
169+ @stream-closed =" onStreamClosed "
152170 />
153171
154172 <PaymentRequestModalDesktop
155173 v-else
156174 @channel-created =" onChannelCreated "
157175 @intent-submitted =" onSuccess "
158176 @client-rejected-payment =" onCancel "
177+ @error =" onError "
178+ @stream-timeout =" onStreamTimeout "
179+ @stream-closed =" onStreamClosed "
159180 />
160181 </div >
161182 <div v-else >
0 commit comments