forked from Tadrisino/MathApp_frontend
- Text: kasra/fatha/damma/shadda/sukun/hamza-above and «هی» ezafe removed from every user-visible string (comments untouched); tanwin kept. Stale copy fixed (question packs are no longer sold), awkward onboarding sentences rewritten, سؤال → سوال. plainPersian() in MathText cleans the live tutor stream. - Home: the mascot + speech bubble header is gone; the selected companion hops beside the current island and sits at every third bend (CSS transform animations only). - Checkout: order summary, payment-method rows with Zarinpal/Bazaar icons and radio, amount on the pay button, lock trust line, darker overlay. paymentMethods in config.js per channel (web: zarinpal, app: zarinpal+bazaar by default). - Profile: «ورود با حساب دیگر» removed (it was logout); new «حساب کاربری» sheet shows phone/ID and holds «حذف حساب کاربری»; logout is a red row. Delete sheet tells Bazaar subscribers to cancel renewal in Bazaar. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
2.6 KiB
TypeScript
51 lines
2.6 KiB
TypeScript
import { resolveApiBaseUrl } from '@/config';
|
||
|
||
/**
|
||
* صفحهی واسطهی پرداخت (pay.html)، برای اپِ اندرویدی که درگاه را در مرورگرِ گوشی باز میکند.
|
||
*
|
||
* زرینپال صفحهی StartPay را فقط وقتی باز میکند که Referer از دامنهی ثبتشده باشد؛ بیآن میگوید «دسترسی از این
|
||
* دامنه مجاز نمیباشد» (روی سرور با درخواستِ بیReferer دیده شد، ۱۴۰۵-۰۷). مرورگری که اپِ دیگری بازش کرده Referer
|
||
* نمیفرستد. پس اپ اول همین صفحه را در مرورگر باز میکند و این صفحه کاربر را به لینکِ پرداخت میفرستد؛ حالا Referer
|
||
* از math.tadrisino2.ir است، درست مثلِ پرداخت از سایت.
|
||
*
|
||
* فقط لینکِ پرداختِ API خودمان پذیرفته میشود (پیشوندِ آدرسِ API + /payment/orders/<id>/pay)، تا این صفحه
|
||
* ریدایرکتِ باز به هر جایی نشود.
|
||
*/
|
||
const msg = document.getElementById('msg')!;
|
||
const spin = document.getElementById('spin')!;
|
||
const go = document.getElementById('go') as HTMLAnchorElement;
|
||
|
||
function fail(text: string) {
|
||
spin.style.display = 'none';
|
||
msg.textContent = text;
|
||
}
|
||
|
||
// در fragment میآید، نه query: اپ این صفحه را با http:// باز میکند (پایینِ SubscriptionScreen) و fragment هرگز
|
||
// به سرور فرستاده نمیشود، پس امضای لینکِ پرداخت روی آن یک گامِ بیرمز دیده نمیشود.
|
||
const raw = new URLSearchParams(location.hash.slice(1)).get('u') ?? '';
|
||
let target: URL | null = null;
|
||
try {
|
||
target = new URL(raw);
|
||
} catch {
|
||
target = null;
|
||
}
|
||
const api = new URL(resolveApiBaseUrl() + '/', location.origin);
|
||
const ok =
|
||
target !== null &&
|
||
target.protocol === 'https:' &&
|
||
target.origin === api.origin &&
|
||
new RegExp(`^${api.pathname.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}payment/orders/\\d+/pay$`).test(target.pathname);
|
||
|
||
if (!ok || !target) {
|
||
fail('این لینک پرداخت معتبر نیست. به اپ برگرد و دوباره «پرداخت» رو بزن.');
|
||
} else {
|
||
go.href = target.href;
|
||
location.replace(target.href);
|
||
// اگر مرورگر جابهجا نشد (مثلاً جلوی ریدایرکت را گرفت)، دکمهی دستی.
|
||
setTimeout(() => {
|
||
spin.style.display = 'none';
|
||
msg.textContent = 'اگه صفحه پرداخت باز نشد، این دکمه رو بزن:';
|
||
go.style.display = 'inline-block';
|
||
}, 2500);
|
||
}
|