feat(purchase-status): enhance purchase status handling with polling and improved UI feedback
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user