@@ -245,7 +245,7 @@ let retrieveStatus = (~headers, ~switchToCustomPod, pollID) => {
245
245
})
246
246
}
247
247
248
- let rec pollStatus = (~headers , ~switchToCustomPod , ~pollId , ~interval , ~count ) => {
248
+ let rec pollStatus = (~headers , ~switchToCustomPod , ~pollId , ~interval , ~count , ~ returnUrl ) => {
249
249
open Promise
250
250
retrieveStatus (~headers , ~switchToCustomPod , pollId )
251
251
-> then (json => {
@@ -254,14 +254,21 @@ let rec pollStatus = (~headers, ~switchToCustomPod, ~pollId, ~interval, ~count)
254
254
Promise .make ((resolve , _ ) => {
255
255
if status === "completed" {
256
256
resolve (json )
257
- } else if ! ( count > 0 ) {
257
+ } else if count === 0 {
258
258
handlePostMessage ([("fullscreen" , false -> JSON .Encode .bool )])
259
- postFailedSubmitResponse (~ errortype = "server_error" , ~ message = "Something went wrong" ) // redirect to return url
259
+ openUrl ( returnUrl )
260
260
} else {
261
261
delay (interval )
262
262
-> then (
263
263
_ => {
264
- pollStatus (~headers , ~switchToCustomPod , ~pollId , ~interval , ~count = count - 1 )
264
+ pollStatus (
265
+ ~headers ,
266
+ ~switchToCustomPod ,
267
+ ~pollId ,
268
+ ~interval ,
269
+ ~count = count - 1 ,
270
+ ~returnUrl ,
271
+ )
265
272
},
266
273
)
267
274
-> ignore
@@ -270,7 +277,7 @@ let rec pollStatus = (~headers, ~switchToCustomPod, ~pollId, ~interval, ~count)
270
277
})
271
278
-> catch (e => {
272
279
Console .log2 ("Unable to retrieve payment due to following error" , e )
273
- pollStatus (~headers , ~switchToCustomPod , ~pollId , ~interval , ~count = count - 1 )
280
+ pollStatus (~headers , ~switchToCustomPod , ~pollId , ~interval , ~count = count - 1 , ~ returnUrl )
274
281
})
275
282
}
276
283
0 commit comments