submited
This commit is contained in:
@@ -274,8 +274,13 @@ export class CartComponent implements OnDestroy {
|
|||||||
if (paymentStatus === 'COMPLETED' || paymentStatus === 'APPROVED' || paymentStatus === 'PAID' || paymentCode === 'SUCCESS') {
|
if (paymentStatus === 'COMPLETED' || paymentStatus === 'APPROVED' || paymentStatus === 'PAID' || paymentCode === 'SUCCESS') {
|
||||||
this.paymentStatus.set('success');
|
this.paymentStatus.set('success');
|
||||||
this.stopPolling();
|
this.stopPolling();
|
||||||
// Clear cart but don't close popup - wait for email submission
|
|
||||||
this.cartService.clearCart();
|
this.cartService.clearCart();
|
||||||
|
|
||||||
|
// Auto-submit purchase after 5 seconds
|
||||||
|
if (this.closeTimeout) clearTimeout(this.closeTimeout);
|
||||||
|
this.closeTimeout = setTimeout(() => {
|
||||||
|
this.autoSubmitPurchase();
|
||||||
|
}, 5000);
|
||||||
}
|
}
|
||||||
// Continue checking for 3 minutes regardless of other statuses
|
// Continue checking for 3 minutes regardless of other statuses
|
||||||
},
|
},
|
||||||
@@ -310,6 +315,51 @@ export class CartComponent implements OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private autoSubmitPurchase(): void {
|
||||||
|
const telegramUserId = this.getTelegramUserId();
|
||||||
|
|
||||||
|
// Telegram ID is mandatory
|
||||||
|
if (!telegramUserId) {
|
||||||
|
console.error('Cannot submit purchase: Telegram ID is required');
|
||||||
|
this.emailSubmitting.set(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.emailSubmitting.set(true);
|
||||||
|
|
||||||
|
const emailData = {
|
||||||
|
email: '',
|
||||||
|
phone: '',
|
||||||
|
telegramUserId: telegramUserId,
|
||||||
|
items: this.paidItems.map((item: CartItem) => ({
|
||||||
|
itemID: item.itemID,
|
||||||
|
name: item.name,
|
||||||
|
price: item.discount > 0
|
||||||
|
? item.price * (1 - item.discount / 100)
|
||||||
|
: item.price,
|
||||||
|
currency: item.currency,
|
||||||
|
quantity: item.quantity
|
||||||
|
}))
|
||||||
|
};
|
||||||
|
|
||||||
|
this.apiService.submitPurchaseEmail(emailData).subscribe({
|
||||||
|
next: () => {
|
||||||
|
this.emailSubmitting.set(false);
|
||||||
|
this.closePaymentPopup();
|
||||||
|
const lang = this.langService.currentLanguage();
|
||||||
|
this.router.navigate([`/${lang}`]);
|
||||||
|
},
|
||||||
|
error: (err) => {
|
||||||
|
console.error('Error submitting purchase:', err);
|
||||||
|
this.emailSubmitting.set(false);
|
||||||
|
// Still close popup and redirect even if submission fails
|
||||||
|
this.closePaymentPopup();
|
||||||
|
const lang = this.langService.currentLanguage();
|
||||||
|
this.router.navigate([`/${lang}`]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
copyPaymentLink(): void {
|
copyPaymentLink(): void {
|
||||||
const url = this.paymentUrl();
|
const url = this.paymentUrl();
|
||||||
if (url) {
|
if (url) {
|
||||||
|
|||||||
Reference in New Issue
Block a user