w-funnel/docs/PAYMENT_TEMPLATE_VARIABLES.md
2025-10-23 02:03:31 +02:00

189 lines
6.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Payment Template Variables
## Доступные переменные для подстановки
В текстах экранов **TrialPayment** и **SpecialOffer** можно использовать следующие переменные через синтаксис `{{variableName}}`.
### Основные переменные
| Переменная | Описание | Пример значения |
|------------|----------|-----------------|
| `{{trialPrice}}` | Форматированная цена триала | `$1.00`, `€5.00` |
| `{{billingPrice}}` | Форматированная цена подписки | `$14.99`, `€49.99` |
| `{{trialPeriod}}` | Период триала с интервалом | `7 days`, `1 week`, `2 weeks` |
| `{{billingPeriod}}` | Период списания с интервалом | `1 week`, `1 month`, `3 months` |
| `{{trialPeriodHyphen}}` | Период триала через дефис | `7-day`, `1-week` |
### Дополнительные переменные
| Переменная | Описание | Пример значения | Шаблон |
|------------|----------|-----------------|---------|
| `{{oldPrice}}` | Старая цена (для скидки) | `$14.99` | TrialPayment |
| `{{discountPercent}}` | Процент скидки | `94` | TrialPayment, SpecialOffer |
| `{{oldTrialPrice}}` | Старая цена триала | `$14.99` | SpecialOffer |
| `{{oldTrialPeriod}}` | Старый период триала | `7 days` | SpecialOffer |
## Где использовать
### TrialPayment экран
Переменные работают во **ВСЕХ текстовых полях** экрана, включая:
#### `tryForDays.title`
```json
{
"text": "Try it for {{trialPeriod}}!"
}
```
#### `tryForDays.textList.items`
```json
{
"items": [
{ "text": "Start your {{trialPeriodHyphen}} trial for just {{trialPrice}}." },
{ "text": "Then only {{billingPrice}}/{{billingPeriod}} for full access." }
]
}
```
#### `totalPrice.priceContainer.price`
```json
{
"text": "{{trialPrice}}"
}
```
#### `totalPrice.priceContainer.oldPrice`
```json
{
"text": "{{oldPrice}}"
}
```
#### `totalPrice.priceContainer.discount`
```json
{
"text": "{{discountPercent}}% discount applied"
}
```
### SpecialOffer экран
Переменные работают во всех текстовых полях:
#### `text.title`
```json
{
"text": "SPECIAL {{discountPercent}}% DISCOUNT"
}
```
#### `text.subtitle`
```json
{
"text": "Only {{trialPrice}} for {{trialPeriod}}"
}
```
#### `text.description`
```json
{
"trialPrice": { "text": "{{trialPrice}}" },
"text": { "text": "for {{trialPeriod}}" },
"oldTrialPrice": { "text": "{{oldTrialPrice}}" }
}
```
## Policy текст (хардкоженный)
Policy текст автоматически подставляет значения **без** использования `{{}}`:
```tsx
You also acknowledge that your {trialPeriodHyphen} introductory plan to Wit Lab LLC,
billed at {formattedTrialPrice}, will automatically renew at {formattedBillingPrice}
every {billingPeriodText} unless canceled before the end of the trial period.
```
**Этот текст НЕ редактируется через админку** - значения подставляются автоматически из выбранного variant.
## Примеры использования
### Пример 1: Try For Days секция
```json
{
"tryForDays": {
"title": {
"text": "Try it for {{trialPeriod}}!"
},
"textList": {
"items": [
{ "text": "Receive a hand-drawn sketch of your soulmate." },
{ "text": "Reveal the path with the guide." },
{ "text": "Talk to live experts and get guidance." },
{ "text": "Start your {{trialPeriodHyphen}} trial for just {{trialPrice}}." },
{ "text": "Then {{billingPrice}} every {{billingPeriod}} for full access." },
{ "text": "Cancel anytime—just 24 hours before renewal." }
]
}
}
}
```
**Результат** (для variant с trialPrice=100, price=1499, trialInterval=7, billingInterval=1):
- "Try it for 7 days!"
- "Start your 7-day trial for just $1.00."
- "Then $14.99 every 1 week for full access."
### Пример 2: Total Price секция
```json
{
"totalPrice": {
"priceContainer": {
"price": { "text": "{{trialPrice}}" },
"oldPrice": { "text": "{{oldPrice}}" },
"discount": { "text": "{{discountPercent}}% discount applied" }
}
}
}
```
**Результат**:
- Price: "$1.00"
- Old Price: "$14.99"
- Discount: "94% discount applied"
## Форматирование цен
Цены автоматически форматируются с учетом валюты:
- USD: `$1.00`
- EUR: `€1.00`
- GBP: `£1.00`
## Форматирование периодов
Периоды форматируются на английском:
- `trialPeriod="DAY"`, `interval=1``"1 day"`
- `trialPeriod="DAY"`, `interval=7``"7 days"`
- `trialPeriod="WEEK"`, `interval=1``"1 week"`
- `trialPeriod="MONTH"`, `interval=3``"3 months"`
С дефисом (`trialPeriodHyphen`):
- `"1-day"`, `"7-day"`, `"1-week"`, `"3-month"`
## Важные замечания
1. **Регистр имеет значение**: используйте точное написание `{{trialPrice}}`, а не `{{TrialPrice}}`
2. **Пробелы не важны**: `{{ trialPrice }}` тоже сработает
3. **Несуществующие переменные**: если переменная не найдена, она остается как есть в тексте
4. **Пустые значения**: если значение не определено (например, `discountPercent` для variant без скидки), подставляется пустая строка
## Откуда берутся значения
Все значения загружаются из **Payment Placement API**:
- `GET /api/session/funnel/:funnelId/payment/:paymentId`
И зависят от **выбранного variant**:
- В **Trial Choice** пользователь выбирает variant → его ID сохраняется
- В **Trial Payment** используется выбранный variant (или первый по умолчанию)
- В **Special Offer** всегда используется первый variant из `main_secret_discount` placement