Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public struct CreditsOrderStatusResponse
public const string STATUS_PROCESSING = "processing";
public const string STATUS_CREDITED = "credited";
public const string STATUS_FAILED = "failed";
public const string STATUS_ABANDONED = "abandoned";

public string status;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ private enum PollOutcome
Failed,
TimedOut,
Cancelled,
Abandoned
Comment thread
davidejensen marked this conversation as resolved.
Outdated
}

private static readonly TimeSpan FOREGROUND_POLL_INTERVAL = TimeSpan.FromSeconds(1.5);
Expand Down Expand Up @@ -92,7 +93,7 @@ public void CancelTopUp()

public void AcknowledgeTerminalState()
{
if (CurrentStatus.Stage is CreditsTopUpStage.Credited or CreditsTopUpStage.Failed)
if (CurrentStatus.Stage is CreditsTopUpStage.Credited or CreditsTopUpStage.Failed or CreditsTopUpStage.Abandoned)
SetStatus(CreditsTopUpStatus.Idle());
}

Expand Down Expand Up @@ -153,6 +154,9 @@ private async UniTaskVoid RunTopUpAsync(CreditPack pack, CancellationToken ct)
case PollOutcome.Failed:
SetStatus(CreditsTopUpStatus.GrantFailed(pack, orderId, order.error));
break;
case PollOutcome.Abandoned:
SetStatus(CreditsTopUpStatus.Abandoned(pack, orderId));
break;
}
}
catch (OperationCanceledException) { }
Expand Down Expand Up @@ -182,6 +186,8 @@ private async UniTaskVoid RunTopUpAsync(CreditPack pack, CancellationToken ct)
return (PollOutcome.Credited, result.Value);
case CreditsOrderStatusResponse.STATUS_FAILED:
return (PollOutcome.Failed, result.Value);
case CreditsOrderStatusResponse.STATUS_ABANDONED:
return (PollOutcome.Abandoned, result.Value);
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public enum CreditsTopUpStage
PendingTimeout,
Credited,
Failed,
Abandoned,
}

public readonly struct CreditsTopUpStatus
Expand Down Expand Up @@ -52,5 +53,8 @@ public static CreditsTopUpStatus CheckoutFailed(CreditPack pack, CreditsCheckout

public static CreditsTopUpStatus GrantFailed(CreditPack pack, string orderId, string? errorMessage) =>
new (CreditsTopUpStage.Failed, pack, orderId, errorMessage: errorMessage);

public static CreditsTopUpStatus Abandoned(CreditPack pack, string orderId) =>
new (CreditsTopUpStage.Abandoned, pack, orderId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ private void ApplyStatus(in CreditsTopUpStatus status)
viewInstance.FailedReasonText.text = reason;
viewInstance.RetryButton.gameObject.SetActive(allowRetry);
break;
case CreditsTopUpStage.Abandoned:
viewInstance.FailedReasonText.text = "Purchase cancelled — you were not charged.";
Comment thread
davidejensen marked this conversation as resolved.
Outdated
viewInstance.RetryButton.gameObject.SetActive(true);
break;
}
}

Expand Down Expand Up @@ -357,6 +361,7 @@ private static ModalState MapStage(CreditsTopUpStage stage) =>
CreditsTopUpStage.PendingTimeout => ModalState.Pending,
CreditsTopUpStage.Credited => ModalState.Success,
CreditsTopUpStage.Failed => ModalState.Failed,
CreditsTopUpStage.Abandoned => ModalState.Failed,
Comment thread
davidejensen marked this conversation as resolved.
_ => ModalState.PackSelection,
};

Expand Down
Loading