feat(purchase-status): enhance purchase status handling with polling and improved UI feedback

This commit is contained in:
2026-07-07 12:51:01 -03:00
parent e2605116c5
commit c54eb105cb
5 changed files with 246 additions and 54 deletions

View File

@@ -243,23 +243,11 @@ export class CheckoutPageComponent implements OnInit {
protected async onFinalize(): Promise<void> {
const purchaseId = this.createdPurchaseId();
const tenant = this.tenantService.tenant();
if (!purchaseId || !tenant) {
if (!purchaseId) {
return;
}
try {
this.isGeneratingIntent.set(true); // Re-use this flag for loading state
await this.checkoutService.finalizePurchase(tenant.codigo, purchaseId);
void this.router.navigate(['/checkout/status', purchaseId]);
} catch (error) {
console.error('Failed to finalize purchase:', error);
// Even on failure, we probably want to navigate to the status page to show 'pending' or whatever state it is in.
// But maybe the endpoint returns error if not paid. For now, navigate anyway so the status page handles the state.
void this.router.navigate(['/checkout/status', purchaseId]);
} finally {
this.isGeneratingIntent.set(false);
}
void this.router.navigate(['/checkout/status', purchaseId]);
}
}