api doc
Some checks failed
Architecture Governance / architecture (push) Has been cancelled

This commit is contained in:
sdarbinyan
2026-07-20 01:02:36 +04:00
parent 08976de55a
commit fd5a436220
11 changed files with 930 additions and 10 deletions

View File

@@ -333,8 +333,9 @@ export class CartComponent implements OnDestroy {
this.closeTimeout = setTimeout(() => {
this.autoSubmitPurchase();
}, 5000);
this.recordOrder();
this.cartService.clearCart();
}
// Continue checking for 3 minutes regardless of other statuses
@@ -387,6 +388,36 @@ export class CartComponent implements OnDestroy {
}
}
/**
* Records the just-paid cart as a backoffice AdminOrder (POST /orders) so it shows up
* in Backoffice → Orders/Transactions. Best-effort and fire-and-forget: a failure here
* must never affect the already-confirmed payment or block autoSubmitPurchase.
*/
private recordOrder(): void {
const email = this.userEmail().trim();
const phone = this.userPhone().replace(/\D/g, '');
this.apiService.createOrder({
items: this.paidItems.map((item: CartItem) => ({
productId: String(item.itemID),
name: item.name,
quantity: item.quantity,
price: item.discount > 0 ? item.price * (1 - item.discount / 100) : item.price,
})),
customer: {
name: this.getTelegramUsername() || 'Guest',
email,
phone,
},
payment: {
method: this.selectedPaymentMethod(),
currency: 'RUB',
},
}).subscribe({
error: (err) => console.error('Error recording order:', err),
});
}
private autoSubmitPurchase(): void {
setTimeout(() => {
const lang = this.langService.currentLanguage();