Refresh entitlement after payment confirmation

This commit is contained in:
2569718930@qq.com
2026-05-30 16:26:32 +08:00
parent 91896b4dad
commit a03b8095ee
4 changed files with 60 additions and 17 deletions
+7 -5
View File
@@ -53,6 +53,7 @@ export interface UseBillingParams {
getValidAccessToken: () => Promise<string>;
buildAuthedHeaders: (withJson?: boolean, requireAuth?: boolean) => Promise<Record<string, string>>;
loadSnapshot: () => Promise<void>;
refreshEntitlementAfterPayment: () => Promise<void>;
loadPaymentSnapshot: () => Promise<void>;
// User for metadata points
@@ -86,6 +87,7 @@ export function useBilling(params: UseBillingParams) {
getValidAccessToken,
buildAuthedHeaders,
loadSnapshot,
refreshEntitlementAfterPayment,
loadPaymentSnapshot,
user,
} = params;
@@ -203,7 +205,7 @@ export function useBilling(params: UseBillingParams) {
if (json.ok) {
setPaymentInfo(copy.walletRecoveryDone);
setPaymentError("");
await loadSnapshot();
await refreshEntitlementAfterPayment();
await loadPaymentSnapshot();
return true;
}
@@ -215,7 +217,7 @@ export function useBilling(params: UseBillingParams) {
}
}, [
authIsAuthenticated, buildAuthedHeaders, copy.walletRecoveryDone,
loadPaymentSnapshot, loadSnapshot, reconcileBusy,
loadPaymentSnapshot, refreshEntitlementAfterPayment, reconcileBusy,
]);
// ── handleSubmit409 ────────────────────────────────────
@@ -226,7 +228,7 @@ export function useBilling(params: UseBillingParams) {
const ok = await reconcileLatestPayment();
if (ok) return;
setPaymentInfo(copy.orderAlreadyPaid);
await loadSnapshot();
await refreshEntitlementAfterPayment();
await loadPaymentSnapshot();
return;
}
@@ -246,7 +248,7 @@ export function useBilling(params: UseBillingParams) {
const txHash = intentJson.intent?.tx_hash || txHashNorm;
setPaymentInfo(`支付已确认,交易: ${shortAddress(txHash)}`);
setPaymentError("");
await loadSnapshot();
await refreshEntitlementAfterPayment();
await loadPaymentSnapshot();
return;
}
@@ -257,7 +259,7 @@ export function useBilling(params: UseBillingParams) {
}
throw new Error(copy.submitTxFailed.replace("{raw}", raw));
},
[buildAuthedHeaders, copy, loadPaymentSnapshot, loadSnapshot, reconcileLatestPayment],
[buildAuthedHeaders, copy, loadPaymentSnapshot, refreshEntitlementAfterPayment, reconcileLatestPayment],
);
// ── openTelegramBotBindLink ──────────────────────────────