changed api
This commit is contained in:
@@ -79,7 +79,8 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (validId()) {
|
@if (settingsLoaded()) {
|
||||||
|
@if (hasPartnerId() && validId()) {
|
||||||
<button class="pay-btn" type="button" (click)="pay()" [disabled]="!canPay()">
|
<button class="pay-btn" type="button" (click)="pay()" [disabled]="!canPay()">
|
||||||
<span class="pay-btn__icon">
|
<span class="pay-btn__icon">
|
||||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||||
@@ -100,6 +101,7 @@
|
|||||||
{{ 'fastcheck.share_tg' | translate }}
|
{{ 'fastcheck.share_tg' | translate }}
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card__footer">
|
<div class="card__footer">
|
||||||
|
|||||||
@@ -146,9 +146,13 @@ export class FastcheckPage {
|
|||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
|
||||||
// ?id=<partnerId> — used by the "New" button URL; fallback to default id.
|
// ?id=<partnerId> — used by the "New" button URL; fallback to default id.
|
||||||
|
// hasPartnerId is true ONLY when a real ?id was provided AND it is not the
|
||||||
|
// default fallback. The Pay button is gated on this — without a real
|
||||||
|
// partner id we never call /settings and always show the Telegram button.
|
||||||
const idParam = params.get('id');
|
const idParam = params.get('id');
|
||||||
|
const isRealId = !!idParam && idParam !== this.defaultPartnerId;
|
||||||
this.partnerId.set(idParam ?? this.defaultPartnerId);
|
this.partnerId.set(idParam ?? this.defaultPartnerId);
|
||||||
this.hasPartnerId.set(!!idParam);
|
this.hasPartnerId.set(isRealId);
|
||||||
|
|
||||||
// ?iid=xxxxxx-xxxxxx-xxxxxx — auto-fill and trigger lookup
|
// ?iid=xxxxxx-xxxxxx-xxxxxx — auto-fill and trigger lookup
|
||||||
const iidParam = params.get('iid') ?? '';
|
const iidParam = params.get('iid') ?? '';
|
||||||
@@ -161,8 +165,16 @@ export class FastcheckPage {
|
|||||||
if (digits.length === 18) this.lookupFastcheck(masked);
|
if (digits.length === 18) this.lookupFastcheck(masked);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always call settings on each load — may return active check data to autofill.
|
// Call /settings on every load when we have a real partner id — it may
|
||||||
|
// return active check data to autofill, telegramID, and callbackurl.
|
||||||
|
// Without a real id we skip the request entirely: no Pay button can be
|
||||||
|
// shown anyway and we don't want a wasted call against the default id.
|
||||||
|
if (isRealId) {
|
||||||
this.loadSettings(!!created || !!iidParam);
|
this.loadSettings(!!created || !!iidParam);
|
||||||
|
} else {
|
||||||
|
this.settingsLoaded.set(true);
|
||||||
|
this.validId.set(false);
|
||||||
|
}
|
||||||
|
|
||||||
// Connectivity check — makes visible requests in DevTools and surfaces
|
// Connectivity check — makes visible requests in DevTools and surfaces
|
||||||
// backend availability issues early.
|
// backend availability issues early.
|
||||||
@@ -264,17 +276,13 @@ export class FastcheckPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pay button — redirect to the ready callback URL returned by /settings.
|
* Pay button — run the standard Accept-Fastcheck flow (Telegram login +
|
||||||
* Falls back to opening the legacy Telegram-accept popup if no URL is set.
|
* POST /fastcheck with code) and, on success, redirect the user to the
|
||||||
|
* callbackurl returned by /settings. If no callback was provided we keep
|
||||||
|
* the legacy return_url query-param behaviour via fireMerchantCallback().
|
||||||
*/
|
*/
|
||||||
pay(): void {
|
pay(): void {
|
||||||
if (!this.canPay()) return;
|
if (!this.canPay()) return;
|
||||||
const url = this.callbackUrl();
|
|
||||||
if (url) {
|
|
||||||
window.location.href = url;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// No callback was provided — keep the legacy Telegram-accept flow.
|
|
||||||
this.error.set('');
|
this.error.set('');
|
||||||
this.loginOnly.set(false);
|
this.loginOnly.set(false);
|
||||||
this.openPopup();
|
this.openPopup();
|
||||||
@@ -452,6 +460,14 @@ export class FastcheckPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fireMerchantCallback(): void {
|
private fireMerchantCallback(): void {
|
||||||
|
// Prefer the callbackurl returned by POST /fastcheck/settings/{id}; this
|
||||||
|
// is the merchant URL the partner expects us to land on after pay.
|
||||||
|
const cb = this.callbackUrl();
|
||||||
|
if (cb) {
|
||||||
|
setTimeout(() => { window.location.href = cb; }, 1500);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Legacy fallback: ?return_url=... query param.
|
||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
const returnUrl = params.get('return_url');
|
const returnUrl = params.get('return_url');
|
||||||
if (returnUrl) {
|
if (returnUrl) {
|
||||||
|
|||||||
Reference in New Issue
Block a user