diff --git a/src/api/gramjs/methods/payments.ts b/src/api/gramjs/methods/payments.ts index 07c283f54..96d524ab6 100644 --- a/src/api/gramjs/methods/payments.ts +++ b/src/api/gramjs/methods/payments.ts @@ -136,6 +136,7 @@ export async function getPaymentForm(inputInvoice: ApiRequestInputInvoice) { form: buildApiPaymentForm(result), invoice: buildApiInvoiceFromForm(result), users: result.users.map(buildApiUser).filter(Boolean), + botId: result.botId.toString(), }; } diff --git a/src/components/payment/Checkout.tsx b/src/components/payment/Checkout.tsx index f5c0b76a0..35eb91254 100644 --- a/src/components/payment/Checkout.tsx +++ b/src/components/payment/Checkout.tsx @@ -3,7 +3,7 @@ import React, { memo, useCallback } from '../../lib/teact/teact'; import { getActions } from '../../global'; import type { - ApiChat, ApiInvoice, ApiPaymentCredentials, + ApiInvoice, ApiPaymentCredentials, } from '../../api/types'; import type { FormEditDispatch } from '../../hooks/reducers/usePaymentReducer'; import type { LangCode, Price } from '../../types'; @@ -26,7 +26,6 @@ import Skeleton from '../ui/placeholder/Skeleton'; import styles from './Checkout.module.scss'; export type OwnProps = { - chat?: ApiChat; invoice?: ApiInvoice; checkoutInfo?: { paymentMethod?: string; @@ -35,6 +34,7 @@ export type OwnProps = { name?: string; phone?: string; shippingMethod?: string; + botName?: string; }; prices?: Price[]; totalPrice?: number; @@ -48,10 +48,10 @@ export type OwnProps = { onAcceptTos?: (isAccepted: boolean) => void; savedCredentials?: ApiPaymentCredentials[]; isPaymentFormUrl?: boolean; + botName?: string; }; const Checkout: FC = ({ - chat, invoice, prices, shippingPrices, @@ -66,6 +66,7 @@ const Checkout: FC = ({ hasShippingOptions, savedCredentials, isPaymentFormUrl, + botName, }) => { const { setPaymentStep } = getActions(); @@ -129,7 +130,7 @@ const Checkout: FC = ({ } function renderTosLink(url: string, isRtl?: boolean) { - const langString = lang('PaymentCheckoutAcceptRecurrent', chat?.title); + const langString = lang('PaymentCheckoutAcceptRecurrent', botName); const langStringSplit = langString.split('*'); return ( <> diff --git a/src/components/payment/PaymentModal.tsx b/src/components/payment/PaymentModal.tsx index b91d27ed9..4b15a5a74 100644 --- a/src/components/payment/PaymentModal.tsx +++ b/src/components/payment/PaymentModal.tsx @@ -70,6 +70,7 @@ type StateProps = { passwordValidUntil?: number; isExtendedMedia?: boolean; isPaymentFormUrl?: boolean; + botName?: string; }; type GlobalStateProps = Pick = ({ isOpen, onClose, step, - chat, shippingOptions, savedInfo, canSaveCredentials, @@ -113,6 +113,7 @@ const PaymentModal: FC = ({ passwordValidUntil, isExtendedMedia, isPaymentFormUrl, + botName, }) => { const { loadPasswordInfo, @@ -292,7 +293,6 @@ const PaymentModal: FC = ({ case PaymentStep.Checkout: return ( = ({ savedCredentials={savedCredentials} isTosAccepted={isTosAccepted} onAcceptTos={setIsTosAccepted} + botName={botName} /> ); case PaymentStep.SavedPayments: @@ -647,6 +648,7 @@ export default memo(withGlobal( temporaryPassword, isExtendedMedia, url, + botName, } = selectTabState(global).payment; let providerName = nativeProvider; @@ -700,6 +702,7 @@ export default memo(withGlobal( savedCredentials, passwordValidUntil: temporaryPassword?.validUntil, isExtendedMedia, + botName, }; }, )(PaymentModal)); diff --git a/src/global/actions/api/payments.ts b/src/global/actions/api/payments.ts index c34aa6cf4..d316f1fdb 100644 --- a/src/global/actions/api/payments.ts +++ b/src/global/actions/api/payments.ts @@ -33,6 +33,7 @@ import { selectSmartGlocalCredentials, selectStripeCredentials, selectTabState, + selectUser, } from '../../selectors'; addActionHandler('validateRequestedInfo', (global, actions, payload): ActionReturnType => { @@ -102,12 +103,17 @@ async function getPaymentForm( return undefined; } - const { form, invoice, users } = result; + const { + form, invoice, users, botId, + } = result; global = getGlobal(); + global = addUsers(global, buildCollectionByKey(users, 'id')); global = setPaymentForm(global, form, tabId); global = setPaymentStep(global, PaymentStep.Checkout, tabId); - global = addUsers(global, buildCollectionByKey(users, 'id')); + global = updatePayment(global, { + botName: selectUser(global, botId)?.firstName, + }, tabId); setGlobal(global); return invoice; diff --git a/src/global/types.ts b/src/global/types.ts index 881264885..5157f9667 100644 --- a/src/global/types.ts +++ b/src/global/types.ts @@ -490,6 +490,7 @@ export type TabState = { validUntil: number; }; url?: string; + botName?: string; }; chatCreation?: {