|
|
@ -27,9 +27,11 @@ import { AccountTmpPassword, InputInvoice, InputPaymentCredentials, LabeledPrice |
|
|
|
import I18n, { i18n, LangPackKey, _i18n } from "../../lib/langPack"; |
|
|
|
import I18n, { i18n, LangPackKey, _i18n } from "../../lib/langPack"; |
|
|
|
import { ApiError } from "../../lib/mtproto/apiManager"; |
|
|
|
import { ApiError } from "../../lib/mtproto/apiManager"; |
|
|
|
import wrapEmojiText from "../../lib/richTextProcessor/wrapEmojiText"; |
|
|
|
import wrapEmojiText from "../../lib/richTextProcessor/wrapEmojiText"; |
|
|
|
|
|
|
|
import wrapRichText from "../../lib/richTextProcessor/wrapRichText"; |
|
|
|
import rootScope from "../../lib/rootScope"; |
|
|
|
import rootScope from "../../lib/rootScope"; |
|
|
|
import AvatarElement from "../avatar"; |
|
|
|
import AvatarElement from "../avatar"; |
|
|
|
import Button from "../button"; |
|
|
|
import Button from "../button"; |
|
|
|
|
|
|
|
import CheckboxField from "../checkboxField"; |
|
|
|
import PeerTitle from "../peerTitle"; |
|
|
|
import PeerTitle from "../peerTitle"; |
|
|
|
import { putPreloader } from "../putPreloader"; |
|
|
|
import { putPreloader } from "../putPreloader"; |
|
|
|
import Row from "../row"; |
|
|
|
import Row from "../row"; |
|
|
@ -240,10 +242,6 @@ export default class PopupPayment extends PopupElement { |
|
|
|
|
|
|
|
|
|
|
|
// console.log(paymentForm, lastRequestedInfo);
|
|
|
|
// console.log(paymentForm, lastRequestedInfo);
|
|
|
|
|
|
|
|
|
|
|
|
await peerTitle.update({peerId: paymentForm.bot_id.toPeerId()}); |
|
|
|
|
|
|
|
preloaderContainer.remove(); |
|
|
|
|
|
|
|
this.element.classList.remove('is-loading'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const wrapAmount = (amount: string | number, skipSymbol?: boolean) => { |
|
|
|
const wrapAmount = (amount: string | number, skipSymbol?: boolean) => { |
|
|
|
return paymentsWrapCurrencyAmount(amount, currency, skipSymbol); |
|
|
|
return paymentsWrapCurrencyAmount(amount, currency, skipSymbol); |
|
|
|
}; |
|
|
|
}; |
|
|
@ -251,6 +249,13 @@ export default class PopupPayment extends PopupElement { |
|
|
|
const {invoice} = paymentForm; |
|
|
|
const {invoice} = paymentForm; |
|
|
|
const currency = invoice.currency; |
|
|
|
const currency = invoice.currency; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isRecurring = invoice.pFlags.recurring && !isReceipt; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await peerTitle.update({peerId: paymentForm.bot_id.toPeerId()}); |
|
|
|
|
|
|
|
const peerTitle2 = isRecurring ? await wrapPeerTitle({peerId: paymentForm.bot_id.toPeerId()}) : undefined; |
|
|
|
|
|
|
|
preloaderContainer.remove(); |
|
|
|
|
|
|
|
this.element.classList.remove('is-loading'); |
|
|
|
|
|
|
|
|
|
|
|
const makeLabel = () => { |
|
|
|
const makeLabel = () => { |
|
|
|
const labelEl = document.createElement('div'); |
|
|
|
const labelEl = document.createElement('div'); |
|
|
|
labelEl.classList.add(pricesClassName + '-price'); |
|
|
|
labelEl.classList.add(pricesClassName + '-price'); |
|
|
@ -669,9 +674,23 @@ export default class PopupPayment extends PopupElement { |
|
|
|
shippingEmailRow, |
|
|
|
shippingEmailRow, |
|
|
|
shippingPhoneRow, |
|
|
|
shippingPhoneRow, |
|
|
|
].filter(Boolean); |
|
|
|
].filter(Boolean); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const acceptTermsCheckboxField = isRecurring && new CheckboxField({ |
|
|
|
|
|
|
|
text: 'Payments.Recurrent.Accept', |
|
|
|
|
|
|
|
textArgs: [wrapRichText(invoice.recurring_terms_url), peerTitle2] |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const acceptTermsRow = isRecurring && createRow({ |
|
|
|
|
|
|
|
checkboxField: acceptTermsCheckboxField, |
|
|
|
|
|
|
|
noCheckboxSubtitle: true |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const recurringElements = isRecurring ? [document.createElement('hr'), acceptTermsRow.container] : []; |
|
|
|
|
|
|
|
|
|
|
|
this.scrollable.append(...[ |
|
|
|
this.scrollable.append(...[ |
|
|
|
document.createElement('hr'), |
|
|
|
document.createElement('hr'), |
|
|
|
...rows.map((row) => row.container) |
|
|
|
...rows.map((row) => row.container), |
|
|
|
|
|
|
|
...recurringElements |
|
|
|
].filter(Boolean)); |
|
|
|
].filter(Boolean)); |
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
///
|
|
|
@ -779,7 +798,11 @@ export default class PopupPayment extends PopupElement { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
let payButton: HTMLElement; |
|
|
|
const onChange = () => { |
|
|
|
|
|
|
|
payButton.disabled = !!(acceptTermsCheckboxField && !acceptTermsCheckboxField.checked); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let payButton: HTMLButtonElement; |
|
|
|
if(isReceipt) { |
|
|
|
if(isReceipt) { |
|
|
|
payButton = PaymentButton({ |
|
|
|
payButton = PaymentButton({ |
|
|
|
onClick: () => this.hide(), |
|
|
|
onClick: () => this.hide(), |
|
|
@ -792,6 +815,11 @@ export default class PopupPayment extends PopupElement { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onChange(); |
|
|
|
|
|
|
|
if(acceptTermsCheckboxField) { |
|
|
|
|
|
|
|
acceptTermsCheckboxField.input.addEventListener('change', onChange); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.body.append(this.btnConfirmOnEnter = payButton); |
|
|
|
this.body.append(this.btnConfirmOnEnter = payButton); |
|
|
|
|
|
|
|
|
|
|
|
this.onContentUpdate(); |
|
|
|
this.onContentUpdate(); |
|
|
|