mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +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:
@@ -398,6 +398,14 @@ export const subscriptionApi = {
|
||||
tariffId: number,
|
||||
periodDays: number,
|
||||
trafficGb?: number,
|
||||
/**
|
||||
* Subscription ID being renewed. Pass this when the user clicked
|
||||
* "Renew" on an existing subscription so the backend can resolve
|
||||
* the target row by ID instead of doing a (user_id, tariff_id)
|
||||
* re-lookup that races with concurrent panel webhooks. Omit when
|
||||
* this is a fresh purchase from the catalog.
|
||||
*/
|
||||
subscriptionId?: number,
|
||||
): Promise<{
|
||||
success: boolean;
|
||||
message: string;
|
||||
@@ -411,6 +419,7 @@ export const subscriptionApi = {
|
||||
tariff_id: tariffId,
|
||||
period_days: periodDays,
|
||||
traffic_gb: trafficGb,
|
||||
subscription_id: subscriptionId,
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user