> ## Documentation Index
> Fetch the complete documentation index at: https://vowena.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# reactivate

> Reactivates a paused subscription by re-approving the token allowance and attempting an immediate charge. Returns the subscription to active billing on success.

```rust theme={null}
fn reactivate(env: Env, subscriber: Address, sub_id: u64) -> Result<bool>
```

Reactivates a subscription that was paused due to failed charges. The function re-approves the token allowance and immediately attempts to charge the overdue period. If the charge succeeds, the subscription returns to `Active` status.

***

## Parameters

| Name         | Type      | Description                                                  |
| ------------ | --------- | ------------------------------------------------------------ |
| `subscriber` | `Address` | The subscriber's Stellar address. Must sign the transaction. |
| `sub_id`     | `u64`     | The subscription ID to reactivate.                           |

***

## Authorization

```rust theme={null}
subscriber.require_auth();
```

Only the subscriber can reactivate their own subscription. The subscriber's signature covers both the `reactivate()` call and the nested `token.approve()` to refresh the allowance.

***

## Return value

`Result<bool>` - `true` if the immediate charge succeeded, `false` if it did not (e.g., still insufficient balance). The subscription is reactivated regardless - the charge attempt is best-effort.

***

## Events emitted

| Event       | Topics                 | Data                 |
| ----------- | ---------------------- | -------------------- |
| `sub_react` | `subscriber`, `sub_id` | Reactivation details |

Additional events may be emitted from the implicit charge attempt (`charge_ok` or `charge_fail`).

***

## Error cases

| Code | Name           | Description                                                                               |
| ---- | -------------- | ----------------------------------------------------------------------------------------- |
| 8    | `SubNotFound`  | No subscription exists with the given `sub_id`.                                           |
| 9    | `Unauthorized` | Caller is not the subscriber on this subscription.                                        |
| 13   | `NotPaused`    | The subscription is not in `Paused` status. Only paused subscriptions can be reactivated. |

***

## Examples

<Tabs>
  <Tab title="SDK">
    ```typescript theme={null}
    import { VowenaClient, NETWORKS } from "@vowena/sdk";

    const client = new VowenaClient({
      contractId: NETWORKS.mainnet.contractId,
      rpcUrl: NETWORKS.mainnet.rpcUrl,
      networkPassphrase: NETWORKS.mainnet.networkPassphrase,
    });

    // Subscriber reactivates a paused subscription
    const tx = await client.buildReactivate(
      "GSUBSCRIBER...ADDR",   // Subscriber's address
      subscriptionId           // Subscription ID
    );

    const signedXdr = await signTransaction(tx);
    const result = await client.submitTransaction(signedXdr);
    console.log("Charged on reactivation:", result.charged); // true or false
    ```
  </Tab>

  <Tab title="Soroban CLI">
    ```bash theme={null}
    soroban contract invoke \
      --id CONTRACT_ID \
      --network mainnet \
      --source SUBSCRIBER_SECRET \
      -- \
      reactivate \
      --subscriber GSUBSCRIBER...ADDR \
      --sub_id 1
    ```
  </Tab>
</Tabs>

<Info>
  Before reactivating, make sure the subscriber's wallet has sufficient USDC balance. The reactivation will re-approve the token allowance and immediately attempt to charge the overdue period. If the balance is still insufficient, the subscription returns to `Active` status but the charge will fail again on the next `charge()` call.
</Info>
