basklee-react 0.9.15 → 0.9.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/package.json +1 -1
- package/templates/app/_storefront/PaymentReturnPage.module.css +71 -0
- package/templates/app/_storefront/PaymentReturnPage.tsx +59 -0
- package/templates/app/accounts/orders/latest/[[...result]]/page.tsx +19 -0
- package/templates/app/layout.tsx +6 -1
- package/templates/components/basklee/cart/StorefrontCart.tsx +8 -0
- package/templates/components/basklee/orders/StorefrontOrders.tsx +8 -0
- package/templates/components/basklee/payments/PaymentReturnNotice.README.md +72 -0
- package/templates/components/basklee/payments/PaymentReturnNotice.module.css +117 -0
- package/templates/components/basklee/payments/PaymentReturnNotice.tsx +136 -0
- package/templates/components/basklee/wallet/StorefrontWallet.tsx +12 -0
- package/templates/lib/basklee/pageMetadata.ts +6 -0
- package/templates/lib/basklee/pageSeo.ts +15 -0
- package/templates/lib/basklee/paymentReturn.ts +199 -0
- package/templates/lib/basklee/paymentReturnLabels.ts +50 -0
package/README.md
CHANGED
|
@@ -127,7 +127,7 @@ starting the application. Imports then work at any component directory depth.
|
|
|
127
127
|
<!-- components:start (generated by scripts/generate-package-readme-components.mjs) -->
|
|
128
128
|
## Components
|
|
129
129
|
|
|
130
|
-
The starter includes **
|
|
130
|
+
The starter includes **127 storefront components**, copied into
|
|
131
131
|
`components/basklee/` of your project. Each one has a README in English and Russian
|
|
132
132
|
next to its source that describes its inputs, data and actions.
|
|
133
133
|
|
|
@@ -244,6 +244,7 @@ Profile, orders, addresses and account activity.
|
|
|
244
244
|
| **Wallet top-up form** | `WalletTopUpForm` | Amount, currency and payment-method selection for a wallet top-up. |
|
|
245
245
|
| **Payment panel** | `PaymentPanel` | Opens the payment link and lets the user refresh its status. |
|
|
246
246
|
| **Pagination** | `StorefrontPagination` | Previous and next controls with the current page for a returned list. |
|
|
247
|
+
| **Payment result** | `PaymentReturnNotice` | Back from the payment system: the result of the payment, once, on the page the payment was made for. |
|
|
247
248
|
|
|
248
249
|
### Subscriptions and support
|
|
249
250
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "basklee-react",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.17",
|
|
4
4
|
"description": "Next.js 16 storefront for your Basklee marketplace: setup CLI, server API gateway, typed store and ready-made catalog, cart, checkout and account components in English, Russian and Spanish, plus an Android app build. Powered by Basklee: https://basklee.com",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/* The page covers the storefront's header and footer: in the payment frame only the way back shows. */
|
|
2
|
+
.page {
|
|
3
|
+
position: fixed;
|
|
4
|
+
z-index: 2147483000;
|
|
5
|
+
inset: 0;
|
|
6
|
+
display: flex;
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
padding: 1.5rem 1rem;
|
|
11
|
+
overflow: auto;
|
|
12
|
+
color: var(--basklee-text);
|
|
13
|
+
background: var(--basklee-surface);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.box {
|
|
17
|
+
display: grid;
|
|
18
|
+
justify-items: center;
|
|
19
|
+
gap: 1rem;
|
|
20
|
+
max-width: 22.5rem;
|
|
21
|
+
text-align: center;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.text {
|
|
25
|
+
margin: 0;
|
|
26
|
+
font-size: 1.125rem;
|
|
27
|
+
line-height: 1.375;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.link {
|
|
31
|
+
display: inline-flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
gap: 0.25rem;
|
|
34
|
+
padding-bottom: 0.125rem;
|
|
35
|
+
border-bottom: 1px solid currentColor;
|
|
36
|
+
color: var(--basklee-text);
|
|
37
|
+
font-size: 0.75rem;
|
|
38
|
+
line-height: 1rem;
|
|
39
|
+
text-decoration: none;
|
|
40
|
+
text-transform: uppercase;
|
|
41
|
+
letter-spacing: 0.08em;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@media (hover: hover) {
|
|
45
|
+
.link:hover {
|
|
46
|
+
opacity: 0.7;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.spinner {
|
|
51
|
+
display: block;
|
|
52
|
+
box-sizing: border-box;
|
|
53
|
+
width: 1.75rem;
|
|
54
|
+
height: 1.75rem;
|
|
55
|
+
border: 3px solid var(--basklee-border);
|
|
56
|
+
border-top-color: var(--basklee-accent);
|
|
57
|
+
border-radius: 50%;
|
|
58
|
+
animation: payment-return-spin 0.8s linear infinite;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@keyframes payment-return-spin {
|
|
62
|
+
to {
|
|
63
|
+
transform: rotate(360deg);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@media (prefers-reduced-motion: reduce) {
|
|
68
|
+
.spinner {
|
|
69
|
+
animation: none;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { useBaskleeSelections } from '@/providers/BaskleeProvider';
|
|
5
|
+
import {
|
|
6
|
+
leavePaymentFrame,
|
|
7
|
+
parsePaymentReturnResult,
|
|
8
|
+
paymentReturnTarget,
|
|
9
|
+
rememberPaymentResult,
|
|
10
|
+
PAYMENT_RETURN_FALLBACK,
|
|
11
|
+
} from '@/lib/basklee/paymentReturn';
|
|
12
|
+
import { paymentReturnLabels } from '@/lib/basklee/paymentReturnLabels';
|
|
13
|
+
import styles from './PaymentReturnPage.module.css';
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
* The gateway's return page, often opened inside the payment frame. It covers
|
|
17
|
+
* the header and the footer and only finds the way back out to the page the
|
|
18
|
+
* payment was made for, which shows the result once (PaymentReturnNotice).
|
|
19
|
+
*/
|
|
20
|
+
export function PaymentReturnPage({ result }: { result?: string }) {
|
|
21
|
+
const locale = useBaskleeSelections((state) => state.localeCode);
|
|
22
|
+
const labels = paymentReturnLabels(locale);
|
|
23
|
+
const [target, setTarget] = useState(PAYMENT_RETURN_FALLBACK);
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const place = paymentReturnTarget();
|
|
27
|
+
|
|
28
|
+
setTarget(place);
|
|
29
|
+
rememberPaymentResult(parsePaymentReturnResult(result));
|
|
30
|
+
leavePaymentFrame(place, window);
|
|
31
|
+
}, [result]);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<main
|
|
35
|
+
className={styles.page}
|
|
36
|
+
data-payment-return
|
|
37
|
+
>
|
|
38
|
+
<div className={styles.box}>
|
|
39
|
+
<span
|
|
40
|
+
className={styles.spinner}
|
|
41
|
+
aria-hidden="true"
|
|
42
|
+
/>
|
|
43
|
+
<p
|
|
44
|
+
className={styles.text}
|
|
45
|
+
role="status"
|
|
46
|
+
>
|
|
47
|
+
{labels.wait}
|
|
48
|
+
</p>
|
|
49
|
+
<a
|
|
50
|
+
href={target}
|
|
51
|
+
target="_top"
|
|
52
|
+
className={styles.link}
|
|
53
|
+
>
|
|
54
|
+
{labels.open}
|
|
55
|
+
</a>
|
|
56
|
+
</div>
|
|
57
|
+
</main>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { notFound } from 'next/navigation';
|
|
2
|
+
import { PaymentReturnPage } from '@/app/_storefront/PaymentReturnPage';
|
|
3
|
+
|
|
4
|
+
// The gateway's Success URL / Fail URL: …/accounts/orders/latest,
|
|
5
|
+
// …/latest/success and …/latest/failed (one part at most, like Nuxt's
|
|
6
|
+
// [[result]]), no query. The page leaves the payment frame.
|
|
7
|
+
export default async function Page({
|
|
8
|
+
params,
|
|
9
|
+
}: {
|
|
10
|
+
params?: Promise<{ result?: string[] }>;
|
|
11
|
+
}) {
|
|
12
|
+
const { result = [] } = (await params) ?? {};
|
|
13
|
+
|
|
14
|
+
if (result.length > 1) {
|
|
15
|
+
notFound();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return <PaymentReturnPage result={result[0]} />;
|
|
19
|
+
}
|
package/templates/app/layout.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import type { ReactNode } from 'react';
|
|
|
3
3
|
import { BaskleeProvider } from '@/providers/BaskleeProvider';
|
|
4
4
|
import { getBaskleeAppLoad } from '@/lib/basklee/appLoadServer';
|
|
5
5
|
import { StorefrontShell } from '@/app/StorefrontShell';
|
|
6
|
+
import { PaymentReturnNotice } from '@/components/basklee/payments/PaymentReturnNotice';
|
|
6
7
|
import {
|
|
7
8
|
getBaskleeSavedChoices,
|
|
8
9
|
getBaskleeServerLocale,
|
|
@@ -63,7 +64,11 @@ export default async function RootLayout({
|
|
|
63
64
|
locale={language}
|
|
64
65
|
currency={currency}
|
|
65
66
|
>
|
|
66
|
-
<StorefrontShell>
|
|
67
|
+
<StorefrontShell>
|
|
68
|
+
{children}
|
|
69
|
+
{/* Back from a payment gateway: the result, once. */}
|
|
70
|
+
<PaymentReturnNotice />
|
|
71
|
+
</StorefrontShell>
|
|
67
72
|
</BaskleeProvider>
|
|
68
73
|
</body>
|
|
69
74
|
</html>
|
|
@@ -33,6 +33,10 @@ import {
|
|
|
33
33
|
type StorefrontCartData,
|
|
34
34
|
} from '@/lib/basklee/cartController';
|
|
35
35
|
import { cartSnapshotProducts } from '@/lib/basklee/cartSnapshot';
|
|
36
|
+
import {
|
|
37
|
+
orderPaymentPlace,
|
|
38
|
+
rememberPaymentPlace,
|
|
39
|
+
} from '@/lib/basklee/paymentReturn';
|
|
36
40
|
import {
|
|
37
41
|
cartShipmentOrigin,
|
|
38
42
|
cartShipmentTitle,
|
|
@@ -382,6 +386,10 @@ export function StorefrontCart({
|
|
|
382
386
|
});
|
|
383
387
|
aborted(signal);
|
|
384
388
|
const order = orderCreatedFromResponse(result);
|
|
389
|
+
// The gateway's return page comes back to the new order.
|
|
390
|
+
if (order.link) {
|
|
391
|
+
rememberPaymentPlace(orderPaymentPlace(order.order_id, locale));
|
|
392
|
+
}
|
|
385
393
|
setCreated(order);
|
|
386
394
|
setData(undefined);
|
|
387
395
|
setPaymentOpen(true);
|
|
@@ -31,6 +31,10 @@ import { cartSnapshotProducts } from '@/lib/basklee/cartSnapshot';
|
|
|
31
31
|
import { formatCurrency } from '@/lib/basklee/currency';
|
|
32
32
|
import { featureLabels } from '@/lib/basklee/featureLabels';
|
|
33
33
|
import { mergePagination } from '@/lib/basklee/featureData';
|
|
34
|
+
import {
|
|
35
|
+
orderPaymentPlace,
|
|
36
|
+
rememberPaymentPlace,
|
|
37
|
+
} from '@/lib/basklee/paymentReturn';
|
|
34
38
|
import { orderItemCount, orderLabels } from '@/lib/basklee/orderLabels';
|
|
35
39
|
import {
|
|
36
40
|
hasOrderAmount,
|
|
@@ -409,6 +413,10 @@ export function StorefrontOrders({
|
|
|
409
413
|
if (controller.signal.aborted || !result) {
|
|
410
414
|
return;
|
|
411
415
|
}
|
|
416
|
+
// The gateway's return page comes back to this order.
|
|
417
|
+
if (result.link) {
|
|
418
|
+
rememberPaymentPlace(orderPaymentPlace(paymentOrder, locale));
|
|
419
|
+
}
|
|
412
420
|
setPayment(result);
|
|
413
421
|
setPaymentOrder(undefined);
|
|
414
422
|
setNeedsRefresh(true);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# PaymentReturnNotice · React
|
|
2
|
+
|
|
3
|
+
## English
|
|
4
|
+
|
|
5
|
+
Shows the result of a payment once, after the payment system sends the
|
|
6
|
+
customer back to the shop.
|
|
7
|
+
|
|
8
|
+
## Contract and dependencies
|
|
9
|
+
|
|
10
|
+
A payment system opens the shop's return page after payment: its Success URL
|
|
11
|
+
`/accounts/orders/latest/success` or its Fail URL
|
|
12
|
+
`/accounts/orders/latest/failed` (no query; `/accounts/orders/latest` alone
|
|
13
|
+
works too). The page answers GET and POST. Inside the payment frame it moves
|
|
14
|
+
the whole window out of the frame; on its own page it replaces itself. It goes
|
|
15
|
+
back to the page the payment was opened for: the order for an order payment
|
|
16
|
+
(cart or order list), the wallet for a top-up or an invoice paid again from
|
|
17
|
+
the wallet. Without a remembered page it opens the wallet, which lists every
|
|
18
|
+
payment.
|
|
19
|
+
|
|
20
|
+
The return page leaves the result in the tab's `sessionStorage`. On the next
|
|
21
|
+
page this window reads it once (a result older than 10 minutes is dropped)
|
|
22
|
+
and says «Payment received» or «Payment not completed»; Continue closes it.
|
|
23
|
+
The status of the payment itself always comes from the order or the wallet.
|
|
24
|
+
|
|
25
|
+
The root layout renders the component on every page, inside the storefront
|
|
26
|
+
shell; it makes no API request. Source:
|
|
27
|
+
`components/basklee/payments/PaymentReturnNotice.tsx`; the return page is
|
|
28
|
+
`app/accounts/orders/latest/[[...result]]/page.tsx`, the shared logic
|
|
29
|
+
`lib/basklee/paymentReturn.ts`.
|
|
30
|
+
|
|
31
|
+
### Props
|
|
32
|
+
|
|
33
|
+
| Prop | Meaning |
|
|
34
|
+
| ----------------------------------- | ------------------------------------------------------------------------------ |
|
|
35
|
+
| `result?: 'success' \| 'failed'` | Shows this result instead of the one the return page left (previews, tests). |
|
|
36
|
+
| `modal?: boolean` | `false` keeps the window in the page instead of over it. Default: `true`. |
|
|
37
|
+
|
|
38
|
+
## Русский
|
|
39
|
+
|
|
40
|
+
Один раз показывает результат оплаты после того, как платёжная система
|
|
41
|
+
вернула покупателя в магазин.
|
|
42
|
+
|
|
43
|
+
Платёжная система после оплаты открывает страницу возврата магазина: Success
|
|
44
|
+
URL `/accounts/orders/latest/success` или Fail URL
|
|
45
|
+
`/accounts/orders/latest/failed` (без параметров; подходит и просто
|
|
46
|
+
`/accounts/orders/latest`). Страница отвечает на GET и POST. Внутри окна
|
|
47
|
+
оплаты она выводит из него всю вкладку, на отдельной странице заменяет саму
|
|
48
|
+
себя. Возврат идёт на страницу, для которой открывалась оплата: к заказу при
|
|
49
|
+
оплате заказа (корзина или список заказов), в кошелёк при пополнении или
|
|
50
|
+
повторной оплате счёта из кошелька. Если страница не запомнена, открывается
|
|
51
|
+
кошелёк — в нём видны все платежи.
|
|
52
|
+
|
|
53
|
+
Результат страница возврата оставляет в `sessionStorage` вкладки. На
|
|
54
|
+
следующей странице это окно читает его один раз (результат старше 10 минут не
|
|
55
|
+
показывается) и сообщает «Оплата получена» или «Оплата не прошла»; кнопка
|
|
56
|
+
«Продолжить» закрывает его. Состояние самого платежа всегда берётся из заказа
|
|
57
|
+
или кошелька.
|
|
58
|
+
|
|
59
|
+
Корневой макет выводит компонент на каждой странице внутри оболочки магазина;
|
|
60
|
+
API-запросов он не делает. Исходный файл:
|
|
61
|
+
`components/basklee/payments/PaymentReturnNotice.tsx`; страница возврата —
|
|
62
|
+
`app/accounts/orders/latest/[[...result]]/page.tsx`, общая логика —
|
|
63
|
+
`lib/basklee/paymentReturn.ts`.
|
|
64
|
+
|
|
65
|
+
### Свойства
|
|
66
|
+
|
|
67
|
+
| Свойство | Назначение |
|
|
68
|
+
| ----------------------------------- | --------------------------------------------------------------------------------------- |
|
|
69
|
+
| `result?: 'success' \| 'failed'` | Показывает этот результат вместо оставленного страницей возврата (превью, проверки). |
|
|
70
|
+
| `modal?: boolean` | `false` оставляет окно на странице, а не поверх неё. По умолчанию `true`. |
|
|
71
|
+
|
|
72
|
+
[English guide](https://docs.basklee.com/en/sandbox/components/react/payment-return-notice) · [Русский](https://docs.basklee.com/ru/sandbox/components/react/payment-return-notice)
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
.dialog {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
padding: 0;
|
|
4
|
+
border: 1px solid var(--basklee-border);
|
|
5
|
+
border-radius: 0;
|
|
6
|
+
color: var(--basklee-text);
|
|
7
|
+
background: var(--basklee-surface);
|
|
8
|
+
font: inherit;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.modal {
|
|
12
|
+
width: 420px;
|
|
13
|
+
max-width: calc(100vw - 32px);
|
|
14
|
+
margin: auto;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.inline {
|
|
18
|
+
position: relative;
|
|
19
|
+
width: 100%;
|
|
20
|
+
max-width: 420px;
|
|
21
|
+
margin: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.dialog::backdrop {
|
|
25
|
+
background: rgb(0 0 0 / 35%);
|
|
26
|
+
backdrop-filter: blur(2px);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.body {
|
|
30
|
+
display: grid;
|
|
31
|
+
gap: 1.25rem;
|
|
32
|
+
padding: 1.5rem;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.title {
|
|
36
|
+
margin: 0;
|
|
37
|
+
font-size: 1.125rem;
|
|
38
|
+
line-height: 1.75rem;
|
|
39
|
+
text-transform: uppercase;
|
|
40
|
+
letter-spacing: 0.04em;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.notice {
|
|
44
|
+
position: relative;
|
|
45
|
+
box-sizing: border-box;
|
|
46
|
+
margin: 0;
|
|
47
|
+
padding: 0.75rem 1rem 0.75rem 44px;
|
|
48
|
+
border: 1px solid var(--basklee-border);
|
|
49
|
+
color: var(--basklee-text);
|
|
50
|
+
background: var(--basklee-muted-surface);
|
|
51
|
+
font-size: 0.875rem;
|
|
52
|
+
line-height: 1.5rem;
|
|
53
|
+
overflow-wrap: anywhere;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.notice::before {
|
|
57
|
+
position: absolute;
|
|
58
|
+
top: 0.875rem;
|
|
59
|
+
left: 0.875rem;
|
|
60
|
+
width: 1.25rem;
|
|
61
|
+
height: 1.25rem;
|
|
62
|
+
content: "";
|
|
63
|
+
background: currentColor;
|
|
64
|
+
-webkit-mask: var(--payment-return-icon) center / contain no-repeat;
|
|
65
|
+
mask: var(--payment-return-icon) center / contain no-repeat;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.success {
|
|
69
|
+
--payment-return-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m8 12.5 2.5 2.5L16 9.5'/%3E%3C/svg%3E");
|
|
70
|
+
border-color: var(--basklee-success);
|
|
71
|
+
color: var(--basklee-success);
|
|
72
|
+
background: var(--basklee-success-surface);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.error {
|
|
76
|
+
--payment-return-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v6m0 4h.01'/%3E%3C/svg%3E");
|
|
77
|
+
border-color: var(--basklee-danger);
|
|
78
|
+
color: var(--basklee-danger);
|
|
79
|
+
background: var(--basklee-danger-surface);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.button {
|
|
83
|
+
display: inline-flex;
|
|
84
|
+
box-sizing: border-box;
|
|
85
|
+
justify-self: start;
|
|
86
|
+
align-items: center;
|
|
87
|
+
justify-content: center;
|
|
88
|
+
height: 2.75rem;
|
|
89
|
+
padding: 0 1.5rem;
|
|
90
|
+
border: 1px solid var(--basklee-accent);
|
|
91
|
+
color: var(--basklee-surface);
|
|
92
|
+
background: var(--basklee-accent);
|
|
93
|
+
font: inherit;
|
|
94
|
+
font-size: 0.75rem;
|
|
95
|
+
line-height: 1rem;
|
|
96
|
+
text-transform: uppercase;
|
|
97
|
+
letter-spacing: 0.08em;
|
|
98
|
+
cursor: pointer;
|
|
99
|
+
outline: none;
|
|
100
|
+
transition: opacity 150ms;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.button:focus-visible {
|
|
104
|
+
opacity: 0.85;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@media (hover: hover) {
|
|
108
|
+
.button:hover {
|
|
109
|
+
opacity: 0.85;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@media (prefers-reduced-motion: reduce) {
|
|
114
|
+
.button {
|
|
115
|
+
transition: none;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import '@/components/basklee/shared/dialogs.css';
|
|
4
|
+
import { useEffect, useId, useRef, useState } from 'react';
|
|
5
|
+
import type { MouseEvent } from 'react';
|
|
6
|
+
import { useBaskleeSelections } from '@/providers/BaskleeProvider';
|
|
7
|
+
import {
|
|
8
|
+
createPageScrollLock,
|
|
9
|
+
focusedElement,
|
|
10
|
+
restoreFocus,
|
|
11
|
+
} from '@/lib/basklee/modalWindow';
|
|
12
|
+
import {
|
|
13
|
+
isPaymentReturnPath,
|
|
14
|
+
takePaymentResult,
|
|
15
|
+
} from '@/lib/basklee/paymentReturn';
|
|
16
|
+
import type { TPaymentReturnResult } from '@/lib/basklee/paymentReturn';
|
|
17
|
+
import { paymentReturnLabels } from '@/lib/basklee/paymentReturnLabels';
|
|
18
|
+
import styles from './PaymentReturnNotice.module.css';
|
|
19
|
+
|
|
20
|
+
export interface PaymentReturnNoticeProps {
|
|
21
|
+
/** Shows this result instead of the one the return page left (documentation previews). */
|
|
22
|
+
result?: TPaymentReturnResult;
|
|
23
|
+
/** `false` keeps the window in the page instead of over it (documentation previews). */
|
|
24
|
+
modal?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
* The result of a payment, once, on the page the gateway's return page
|
|
29
|
+
* (…/accounts/orders/latest/success|failed) came back to.
|
|
30
|
+
*/
|
|
31
|
+
export function PaymentReturnNotice({
|
|
32
|
+
result,
|
|
33
|
+
modal = true,
|
|
34
|
+
}: PaymentReturnNoticeProps) {
|
|
35
|
+
const locale = useBaskleeSelections((state) => state.localeCode);
|
|
36
|
+
const labels = paymentReturnLabels(locale);
|
|
37
|
+
const id = useId();
|
|
38
|
+
const dialog = useRef<HTMLDialogElement>(null);
|
|
39
|
+
const opener = useRef<HTMLElement | undefined>(undefined);
|
|
40
|
+
const [pageScroll] = useState(() => createPageScrollLock());
|
|
41
|
+
const [shown, setShown] = useState<TPaymentReturnResult>();
|
|
42
|
+
const copy = shown === 'success' ? labels.success : labels.failed;
|
|
43
|
+
|
|
44
|
+
// The result is taken once: React's development mode runs effects twice.
|
|
45
|
+
const taken = useRef<{ result?: TPaymentReturnResult }>(undefined);
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (!taken.current) {
|
|
49
|
+
taken.current = {
|
|
50
|
+
result: isPaymentReturnPath(window.location.pathname)
|
|
51
|
+
? undefined
|
|
52
|
+
: takePaymentResult(),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
setShown(result ?? taken.current.result);
|
|
56
|
+
}, [result]);
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
const element = dialog.current;
|
|
60
|
+
|
|
61
|
+
if (!shown || !element || element.open) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (!modal) {
|
|
65
|
+
// Opened by its attribute, not show(): the focus stays where it is.
|
|
66
|
+
element.setAttribute('open', '');
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
opener.current = focusedElement();
|
|
70
|
+
pageScroll.lock();
|
|
71
|
+
element.showModal();
|
|
72
|
+
|
|
73
|
+
return () => pageScroll.unlock();
|
|
74
|
+
}, [modal, pageScroll, shown]);
|
|
75
|
+
|
|
76
|
+
function close() {
|
|
77
|
+
dialog.current?.close();
|
|
78
|
+
setShown(undefined);
|
|
79
|
+
if (pageScroll.locked) {
|
|
80
|
+
pageScroll.unlock();
|
|
81
|
+
restoreFocus(opener.current);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function backdrop(event: MouseEvent<HTMLDialogElement>) {
|
|
86
|
+
if (modal && event.target === dialog.current) {
|
|
87
|
+
close();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!shown) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<dialog
|
|
97
|
+
ref={dialog}
|
|
98
|
+
data-stable-modal="fit"
|
|
99
|
+
data-payment-return-notice={shown}
|
|
100
|
+
aria-labelledby={`${id}-title`}
|
|
101
|
+
aria-describedby={`${id}-text`}
|
|
102
|
+
className={`${styles.dialog} ${modal ? styles.modal : styles.inline}`}
|
|
103
|
+
onCancel={(event) => {
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
close();
|
|
106
|
+
}}
|
|
107
|
+
onClick={backdrop}
|
|
108
|
+
>
|
|
109
|
+
<div className={styles.body}>
|
|
110
|
+
<h2
|
|
111
|
+
id={`${id}-title`}
|
|
112
|
+
className={styles.title}
|
|
113
|
+
>
|
|
114
|
+
{copy.title}
|
|
115
|
+
</h2>
|
|
116
|
+
<p
|
|
117
|
+
id={`${id}-text`}
|
|
118
|
+
className={`${styles.notice} ${
|
|
119
|
+
shown === 'success' ? styles.success : styles.error
|
|
120
|
+
}`}
|
|
121
|
+
role="status"
|
|
122
|
+
>
|
|
123
|
+
{copy.text}
|
|
124
|
+
</p>
|
|
125
|
+
<button
|
|
126
|
+
type="button"
|
|
127
|
+
className={styles.button}
|
|
128
|
+
data-payment-return-continue
|
|
129
|
+
onClick={close}
|
|
130
|
+
>
|
|
131
|
+
{labels.continue}
|
|
132
|
+
</button>
|
|
133
|
+
</div>
|
|
134
|
+
</dialog>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
@@ -23,6 +23,10 @@ import type { ITransformValue } from '@/interfaces/basklee/shared/ITransformValu
|
|
|
23
23
|
import { formatCurrency } from '@/lib/basklee/currency';
|
|
24
24
|
import { featureLabels } from '@/lib/basklee/featureLabels';
|
|
25
25
|
import { mergePagination } from '@/lib/basklee/featureData';
|
|
26
|
+
import {
|
|
27
|
+
rememberPaymentPlace,
|
|
28
|
+
walletPaymentPlace,
|
|
29
|
+
} from '@/lib/basklee/paymentReturn';
|
|
26
30
|
import { getAvailableNestedValueFromObject } from '@/lib/basklee/presentation';
|
|
27
31
|
import {
|
|
28
32
|
walletComment,
|
|
@@ -218,6 +222,14 @@ export function StorefrontWallet({
|
|
|
218
222
|
const [error, setError] = useState(initialError);
|
|
219
223
|
const [fields, setFields] = useState<Record<string, string>>({});
|
|
220
224
|
|
|
225
|
+
// A top-up, or an unpaid invoice paid again from the list: the gateway's
|
|
226
|
+
// return page comes back to the wallet.
|
|
227
|
+
useEffect(() => {
|
|
228
|
+
if (payment?.link) {
|
|
229
|
+
rememberPaymentPlace(walletPaymentPlace(selections.localeCode));
|
|
230
|
+
}
|
|
231
|
+
}, [payment, selections.localeCode]);
|
|
232
|
+
|
|
221
233
|
async function run(
|
|
222
234
|
work: (controller: AbortController) => Promise<void>,
|
|
223
235
|
withFields = false,
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
type StorefrontSeoPage,
|
|
27
27
|
} from '@/lib/basklee/pageSeo';
|
|
28
28
|
import { structuredDataJson } from '@/lib/basklee/productStructuredData';
|
|
29
|
+
import { isPaymentReturnPath } from '@/lib/basklee/paymentReturn';
|
|
29
30
|
import { getProductSocialMeta, getStorefrontSeo } from '@/lib/basklee/seo';
|
|
30
31
|
import { findCatalogCategory } from '@/lib/basklee/catalog';
|
|
31
32
|
import { blogPostCover } from '@/lib/basklee/blogPresentation';
|
|
@@ -46,6 +47,7 @@ const privatePages = new Set([
|
|
|
46
47
|
'cart',
|
|
47
48
|
'logout',
|
|
48
49
|
'orders',
|
|
50
|
+
'paymentReturn',
|
|
49
51
|
'profile',
|
|
50
52
|
'subscriptions',
|
|
51
53
|
'tickets',
|
|
@@ -90,6 +92,10 @@ export function storefrontSeoPage(pathname: string): StorefrontSeoPage {
|
|
|
90
92
|
if (!section) {
|
|
91
93
|
return 'home';
|
|
92
94
|
}
|
|
95
|
+
// The gateway's return page: …/accounts/orders/latest[/<result>].
|
|
96
|
+
if (isPaymentReturnPath(pathname) && segments.length <= 4) {
|
|
97
|
+
return 'paymentReturn';
|
|
98
|
+
}
|
|
93
99
|
if (segments.length === 1 && staticPages.has(section)) {
|
|
94
100
|
return section as StorefrontSeoPage;
|
|
95
101
|
}
|
|
@@ -117,6 +117,11 @@ const pageCopy = {
|
|
|
117
117
|
'Завершение сеанса и возврат на главную страницу.',
|
|
118
118
|
'аккаунт, выход, сеанс',
|
|
119
119
|
],
|
|
120
|
+
paymentReturn: [
|
|
121
|
+
'Возврат после оплаты',
|
|
122
|
+
'Возврат из платёжной системы в магазин.',
|
|
123
|
+
'оплата, платёж, возврат',
|
|
124
|
+
],
|
|
120
125
|
notFound: [
|
|
121
126
|
'Страница не найдена',
|
|
122
127
|
'По этому адресу в магазине нет страницы.',
|
|
@@ -252,6 +257,11 @@ const pageCopy = {
|
|
|
252
257
|
'End the current session and return to the homepage.',
|
|
253
258
|
'account, sign out, session',
|
|
254
259
|
],
|
|
260
|
+
paymentReturn: [
|
|
261
|
+
'Back from payment',
|
|
262
|
+
'The return from the payment system to the shop.',
|
|
263
|
+
'payment, checkout, return',
|
|
264
|
+
],
|
|
255
265
|
notFound: [
|
|
256
266
|
'Page not found',
|
|
257
267
|
'The store has no page at this address.',
|
|
@@ -387,6 +397,11 @@ const pageCopy = {
|
|
|
387
397
|
'Fin de la sesión y vuelta a la página principal.',
|
|
388
398
|
'cuenta, cerrar sesión, sesión',
|
|
389
399
|
],
|
|
400
|
+
paymentReturn: [
|
|
401
|
+
'Vuelta del pago',
|
|
402
|
+
'Regreso del sistema de pago a la tienda.',
|
|
403
|
+
'pago, cobro, vuelta',
|
|
404
|
+
],
|
|
390
405
|
notFound: [
|
|
391
406
|
'Página no encontrada',
|
|
392
407
|
'No hay ninguna página de la tienda en esta dirección.',
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Back from a payment gateway. The gateway's Success URL and Fail URL (set in
|
|
3
|
+
* its merchant cabinet) are the same plain addresses on every Basklee
|
|
4
|
+
* storefront, with no query: …/accounts/orders/latest/success and
|
|
5
|
+
* …/accounts/orders/latest/failed (…/latest alone works too). The gateway may
|
|
6
|
+
* have run inside the payment frame: the return page then takes the whole
|
|
7
|
+
* window out of the frame, back to the page the payment was made for, which
|
|
8
|
+
* shows the result once.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export const PAYMENT_RETURN_PATH = '/accounts/orders/latest';
|
|
12
|
+
|
|
13
|
+
export type TPaymentReturnResult = 'success' | 'failed';
|
|
14
|
+
|
|
15
|
+
type TStore = Pick<Storage, 'getItem' | 'setItem' | 'removeItem'>;
|
|
16
|
+
|
|
17
|
+
type TFrameWindow = Pick<Window, 'self' | 'top' | 'location'>;
|
|
18
|
+
|
|
19
|
+
// The page a payment was opened for waits in localStorage: a gateway that
|
|
20
|
+
// opens in a new tab comes back in that tab, which has its own session.
|
|
21
|
+
const PLACE_KEY = 'basklee:payment-place';
|
|
22
|
+
const PLACE_MAX_AGE = 24 * 60 * 60 * 1000;
|
|
23
|
+
// The result waits for that page in this browser tab (a same-site payment
|
|
24
|
+
// frame shares it with the window around it).
|
|
25
|
+
const RESULT_KEY = 'basklee:payment-return';
|
|
26
|
+
const RESULT_MAX_AGE = 10 * 60 * 1000;
|
|
27
|
+
|
|
28
|
+
/** The page every payment can be followed on when no other one is known. */
|
|
29
|
+
export const PAYMENT_RETURN_FALLBACK = '/wallet';
|
|
30
|
+
|
|
31
|
+
/** `success` or `failed` from the last part of the address; `undefined` for anything else. */
|
|
32
|
+
export function parsePaymentReturnResult(
|
|
33
|
+
value: unknown,
|
|
34
|
+
): TPaymentReturnResult | undefined {
|
|
35
|
+
const item = Array.isArray(value) ? value[0] : value;
|
|
36
|
+
|
|
37
|
+
if (item === 'success') {
|
|
38
|
+
return 'success';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return item === 'failed' || item === 'fail' ? 'failed' : undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** True for …/accounts/orders/latest and every address under it. */
|
|
45
|
+
export function isPaymentReturnPath(path: string): boolean {
|
|
46
|
+
const clean = path.replace(/\/+$/, '');
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
clean === PAYMENT_RETURN_PATH ||
|
|
50
|
+
clean.startsWith(`${PAYMENT_RETURN_PATH}/`)
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** A page of this storefront: one leading slash, not the return page itself. */
|
|
55
|
+
function storefrontPath(value: unknown): string | undefined {
|
|
56
|
+
if (
|
|
57
|
+
typeof value !== 'string' ||
|
|
58
|
+
!value.startsWith('/') ||
|
|
59
|
+
value.startsWith('//') ||
|
|
60
|
+
value.includes('\\')
|
|
61
|
+
) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return isPaymentReturnPath(value.split(/[?#]/)[0] ?? '') ? undefined : value;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The address of an order's own page in the given language. */
|
|
69
|
+
export function orderPaymentPlace(orderId: number, locale: string): string {
|
|
70
|
+
const query = new URLSearchParams({ order: String(orderId) });
|
|
71
|
+
|
|
72
|
+
if (locale) {
|
|
73
|
+
query.set('locale', locale);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return `/orders?${query}`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The wallet page in the given language. */
|
|
80
|
+
export function walletPaymentPlace(locale: string): string {
|
|
81
|
+
return locale
|
|
82
|
+
? `${PAYMENT_RETURN_FALLBACK}?${new URLSearchParams({ locale })}`
|
|
83
|
+
: PAYMENT_RETURN_FALLBACK;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function browserStorage(kind: 'localStorage' | 'sessionStorage'): TStore | undefined {
|
|
87
|
+
try {
|
|
88
|
+
return typeof window === 'undefined' ? undefined : window[kind];
|
|
89
|
+
} catch {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Remembers the page a payment was opened for, the way back from the gateway. */
|
|
95
|
+
export function rememberPaymentPlace(
|
|
96
|
+
path: string,
|
|
97
|
+
store: TStore | undefined = browserStorage('localStorage'),
|
|
98
|
+
now = Date.now(),
|
|
99
|
+
): void {
|
|
100
|
+
const place = storefrontPath(path);
|
|
101
|
+
|
|
102
|
+
try {
|
|
103
|
+
if (place) {
|
|
104
|
+
store?.setItem(PLACE_KEY, JSON.stringify({ path: place, at: now }));
|
|
105
|
+
}
|
|
106
|
+
} catch {
|
|
107
|
+
// Storage off: the gateway comes back to the wallet.
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** The remembered page of the last day, or the wallet page. */
|
|
112
|
+
export function paymentReturnTarget(
|
|
113
|
+
store: TStore | undefined = browserStorage('localStorage'),
|
|
114
|
+
now = Date.now(),
|
|
115
|
+
): string {
|
|
116
|
+
try {
|
|
117
|
+
const saved = store?.getItem(PLACE_KEY);
|
|
118
|
+
|
|
119
|
+
if (saved) {
|
|
120
|
+
const { path, at } = JSON.parse(saved) as { path?: unknown; at?: unknown };
|
|
121
|
+
const place = storefrontPath(path);
|
|
122
|
+
|
|
123
|
+
if (
|
|
124
|
+
place &&
|
|
125
|
+
typeof at === 'number' &&
|
|
126
|
+
now - at >= 0 &&
|
|
127
|
+
now - at <= PLACE_MAX_AGE
|
|
128
|
+
) {
|
|
129
|
+
return place;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
} catch {
|
|
133
|
+
// A damaged entry: the wallet lists every payment.
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return PAYMENT_RETURN_FALLBACK;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function rememberPaymentResult(
|
|
140
|
+
result: TPaymentReturnResult | undefined,
|
|
141
|
+
store: TStore | undefined = browserStorage('sessionStorage'),
|
|
142
|
+
now = Date.now(),
|
|
143
|
+
): void {
|
|
144
|
+
try {
|
|
145
|
+
if (result) {
|
|
146
|
+
store?.setItem(RESULT_KEY, JSON.stringify({ result, at: now }));
|
|
147
|
+
} else {
|
|
148
|
+
store?.removeItem(RESULT_KEY);
|
|
149
|
+
}
|
|
150
|
+
} catch {
|
|
151
|
+
// Storage off: the page opens without the result window.
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** The result left by the return page in the last 10 minutes, once: it is removed as it is read. */
|
|
156
|
+
export function takePaymentResult(
|
|
157
|
+
store: TStore | undefined = browserStorage('sessionStorage'),
|
|
158
|
+
now = Date.now(),
|
|
159
|
+
): TPaymentReturnResult | undefined {
|
|
160
|
+
try {
|
|
161
|
+
const saved = store?.getItem(RESULT_KEY);
|
|
162
|
+
|
|
163
|
+
if (!saved) {
|
|
164
|
+
return undefined;
|
|
165
|
+
}
|
|
166
|
+
store?.removeItem(RESULT_KEY);
|
|
167
|
+
const { result, at } = JSON.parse(saved) as { result?: unknown; at?: unknown };
|
|
168
|
+
|
|
169
|
+
return typeof at === 'number' && now - at >= 0 && now - at <= RESULT_MAX_AGE
|
|
170
|
+
? parsePaymentReturnResult(result)
|
|
171
|
+
: undefined;
|
|
172
|
+
} catch {
|
|
173
|
+
return undefined;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Opens `target` in the whole browser window. In the payment frame the top
|
|
179
|
+
* window goes there (one history entry, so Back returns to the page with the
|
|
180
|
+
* frame); on its own the page replaces itself, so Back does not land on this
|
|
181
|
+
* page again. A top window of another site refuses: the frame itself goes
|
|
182
|
+
* there then.
|
|
183
|
+
*/
|
|
184
|
+
export function leavePaymentFrame(
|
|
185
|
+
target: string,
|
|
186
|
+
view: TFrameWindow,
|
|
187
|
+
): 'top' | 'self' {
|
|
188
|
+
try {
|
|
189
|
+
if (view.top && view.top !== view.self) {
|
|
190
|
+
view.top.location.href = target;
|
|
191
|
+
return 'top';
|
|
192
|
+
}
|
|
193
|
+
} catch {
|
|
194
|
+
// Another site's window, or the browser refused to move it.
|
|
195
|
+
}
|
|
196
|
+
view.location.replace(target);
|
|
197
|
+
|
|
198
|
+
return 'self';
|
|
199
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const en = {
|
|
2
|
+
title: 'Back from payment',
|
|
3
|
+
wait: 'Please wait. Returning to the shop…',
|
|
4
|
+
open: 'Open the shop',
|
|
5
|
+
continue: 'Continue',
|
|
6
|
+
success: {
|
|
7
|
+
title: 'Payment received',
|
|
8
|
+
text: 'Thank you! The payment counts as soon as the payment system confirms it. Its status is shown on this page.',
|
|
9
|
+
},
|
|
10
|
+
failed: {
|
|
11
|
+
title: 'Payment not completed',
|
|
12
|
+
text: 'The payment was cancelled or declined. Try again or choose another payment method.',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const ru: typeof en = {
|
|
17
|
+
title: 'Возврат после оплаты',
|
|
18
|
+
wait: 'Подождите. Возвращаемся в магазин…',
|
|
19
|
+
open: 'Открыть магазин',
|
|
20
|
+
continue: 'Продолжить',
|
|
21
|
+
success: {
|
|
22
|
+
title: 'Оплата получена',
|
|
23
|
+
text: 'Спасибо! Оплата засчитается, как только платёжная система её подтвердит. Её статус — на этой странице.',
|
|
24
|
+
},
|
|
25
|
+
failed: {
|
|
26
|
+
title: 'Оплата не прошла',
|
|
27
|
+
text: 'Оплата отменена или отклонена. Попробуйте ещё раз или выберите другой способ оплаты.',
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const es: typeof en = {
|
|
32
|
+
title: 'Vuelta del pago',
|
|
33
|
+
wait: 'Espera. Volviendo a la tienda…',
|
|
34
|
+
open: 'Abrir la tienda',
|
|
35
|
+
continue: 'Continuar',
|
|
36
|
+
success: {
|
|
37
|
+
title: 'Pago recibido',
|
|
38
|
+
text: '¡Gracias! El pago cuenta en cuanto el sistema de pago lo confirma. Su estado está en esta página.',
|
|
39
|
+
},
|
|
40
|
+
failed: {
|
|
41
|
+
title: 'Pago no completado',
|
|
42
|
+
text: 'El pago se canceló o fue rechazado. Inténtalo de nuevo o elige otro método de pago.',
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export function paymentReturnLabels(locale: string) {
|
|
47
|
+
const code = locale.toLowerCase();
|
|
48
|
+
|
|
49
|
+
return code.startsWith('ru') ? ru : code.startsWith('es') ? es : en;
|
|
50
|
+
}
|