mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-30 10:27:49 +00:00
fix(subscription): forward subscription_id to purchaseTariff to fix renew race
Companion to bedolaga-bot a527df23. Bot's purchase-tariff endpoint now accepts optional subscription_id to resolve the EXACT target row by ID instead of doing a (user_id, tariff_id) re-lookup that races with concurrent panel webhooks (produces 'Тариф уже активен' + refund + no extension). Frontend changes: * subscriptionApi.purchaseTariff() — new optional subscriptionId arg appended after trafficGb. Forwarded as subscription_id in POST body. * SubscriptionPurchase.tsx — forwards URL searchParam subscriptionId (set when user lands here from 'Renew this subscription'). * SubscriptionCardExpired.tsx — passes subscription.id when renewing an expired daily tariff (the .purchaseTariff(tariff_id, 1) call).
This commit is contained in:
@@ -59,8 +59,11 @@ export default function SubscriptionCardExpired({
|
||||
// Resume daily subscription via toggle pause endpoint
|
||||
await subscriptionApi.togglePause(subscription.id);
|
||||
} else if (isDaily && subscription.tariff_id) {
|
||||
// Expired daily tariff — purchase for 1 day
|
||||
await subscriptionApi.purchaseTariff(subscription.tariff_id, 1);
|
||||
// Expired daily tariff — purchase for 1 day. Pass subscription.id
|
||||
// so the backend resolves the EXACT row instead of doing a
|
||||
// (user_id, tariff_id) re-lookup that races with concurrent
|
||||
// panel webhooks (would surface as "Тариф уже активен" + refund).
|
||||
await subscriptionApi.purchaseTariff(subscription.tariff_id, 1, undefined, subscription.id);
|
||||
} else {
|
||||
await subscriptionApi.renewSubscription(30, subscription.id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user